ATR Stop Loss query

Forums ProRealTime English forum ProOrder support ATR Stop Loss query

Viewing 7 posts - 1 through 7 (of 7 total)
  • #116821

    Hi

    In the below code, is the ATR related stop loss level re-calculated after close of every bar when trade is on market? I want to use the ATR of the bar just before the trade was executed. Any ideas how this can be coded please?

    Thanks

    Sachin

     

    #116825

    you need to calculate and set SL only when not Onmarket, once a trade is opened it must no be set anymore.

    1 user thanked author for this post.
    #116826

    Try this (not tested). The ATR stop is fixed at the ATR value at the close of the decision bar which is the one before the trade is actually executed. Not sure if you mean this bar or the one before the decision bar so just change the [0] to [1] in AverageTrueRange[14](close[0]) if it is the the ATR of the bar before the decision bar that you mean.

     

    1 user thanked author for this post.
    #116827

    Roberto – you beat me by three minutes but your code will not set the stop loss until the trade has been open for one bar.

    2 users thanked author for this post.
    #116829

    Thanks Vonasi

    Yes, ATR at close of the decision bar. Your code will execute both rows 10 and 11? No need for AND or anything else after MARKET on row 10 and before SET on row 11?

    #116831

    No. Any time SET is read in the code it sends an order to your broker. That order stays on the market till it is either filled or it is cancelled or changed by another SET instruction being read in the code.

    1 user thanked author for this post.
    #116833

    Thank you Vonasi. Learnt something very useful today.

    FYI – I’ve done a quick test and it seems to work

Viewing 7 posts - 1 through 7 (of 7 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login