How to set up

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

    Hi guys,

    I need help.

    I want to set up the stop loss or the exit condition to the open price of the preceding bar of the tradeindex(1) as per the blue dashes the attached pic. There must be an obvious way to do it but I am stuck.
    I am testing it on the following code:

     

    Thanks for your help

    #236162

    Hi, no attached pic ?

    #236163

    Sorry !! There you go

    #236165

    ok, so it’s the open of the bar when code is read, you can try to replace both line 24 and line 27 by :

    set stop price open

    if you run into issues of minimum distance, use min(open, minid)

    where minid would be your broker’s minimum distance for this asset

    1 user thanked author for this post.
    #236166

    Thanks @JC_Bywan.

    I want to keep the same SL value for the duration of the position. I don’t want to update the SL at each new bar.

    #236170

    By suggesting to add set stop price open in lines 24 and 27, that’s what should happen because they are inside the same if statement as the order launching, so SL would be set only then and not updated at each new bar. You can also try to do it through a variable SL in order to graph it and visualize if behaviour matches your expectations:

     

    2 users thanked author for this post.
    #236173

    Got it !! I ll play with it.

    Thanks

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