Trailing Stop – Automatic

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #83617 quote
    CA
    Participant
    New

    Hello,

     

    I am trying to make, somehow, the following:

     

    1. My trading system requires to have an initial stop loss of 150 points.
    2. Then I have a target, let’s say, at 300 points.
    3. However, instead of establishing a target on the 300 points I would like just to create a new stop once the 300 points with a trailing stop of 50 points, that way I can still having benefits from the trend.

     

    I have been trying several codes for this pourpose but I have not been able to code it!

     

    Any ideas? Is it actually possible?

    #83775 quote
    Nicolas
    Keymaster
    Master
    Hi,

    >> Please update your country flag in your profile. Thank you 🙂 <<

    Many times already this question has been answered 😉 You’ll find many trailing stop function on the website, in all sections (forums, library, blog). You can start with the ones from the blog: Complete trailing stop code function Trailing stop with the Max Favorable Excursion (MFE)
    #83793 quote
    CA
    Participant
    New
    Hi Nicolas,   Thank you for your reply. Although you answer actually solve my question (I read the posts you refered me to) what I actually need to do is a bit diferente and I thought it would be similar to what I asked (trying to simplify the question) but after I read your posts it turned out that it actually does not solve it (sorry!).   Actually, what I need is related to ADX indicator. So for instance, I have a initial stop of, lets say, 150 points and an ADX level of 20. I would hold my positivo until ADX leve goes upto level of 40. There is were I need to move up the stop and start making a trailing stop of 20 points. Is it possible to code this? Can I link an stoploss + trailing to ADX?   I would appreciate your answer!! Regards,
    #83804 quote
    Nicolas
    Keymaster
    Master
    Of course you can link the trailing stop activation to any other condition. Make a simple test with ADX to allow or not the trailing stop to operate:
    if adx[14]>20 then 
     allowtrailing = 1
    else
     allowtrailing = 0
    endif 
    
    if allowtrailing then 
     //put trailing stop function here 
    endif
    #83814 quote
    CA
    Participant
    New
    Thank you Nicolas!! It worked!!!
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Trailing Stop – Automatic


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
CA @camilo_acevedo Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by CA
7 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/27/2018
Status: Active
Attachments: No files
Logo Logo
Loading...