Determine next trade long or short if previous trade exited due to stop loss

Forums ProRealTime English forum ProOrder support Determine next trade long or short if previous trade exited due to stop loss

Viewing 9 posts - 1 through 9 (of 9 total)
  • #111297

    Hi

    My trading strategy alternates between long and short trades i.e. long closes and short opens at the same time and vice versa. If a long trade is closed early due to a stop loss being triggered, I want the next trade to be a short trade (and vice versa if a short trade is closed early due to a stop loss being triggered).

    Please, how do I code to check whether the previous trade was long or short and whether it was exited due to a stop loss being triggered?

    Something like:

    I can then use the above a and b as conditions to enter the next trade but I do not know how to code the bits in the square brackets. Please help

    Thanks

    Sachin

     

    #111314

    I already used this snippet to identify what was the last order type and if it was in gain, so it could be adapted to make the opposite:

     

    1 user thanked author for this post.
    #111315

    Added as Log 181 here …

    Snippet Link Library

    #111565

    Thanks Nicolas

    Is the below code valid and would it give me result of a = 1 if the previous trade was long and b =1 if the previous trade was short?

     

    #111595

    Hi Nicolas

    Thinking about it further, BARINDEX starts ascending from left to right and ONMARKET starts ascending from right to left. So is the below code correct instead of my reply earlier to give a result of a = 1 if the previous trade was long and b = 1 if the previous trade was short?

    Thanks

    Sachin

    #111662

    Why don’t you GRAPH Longonmarket and GRAPH a then you will see what the code gives you on the BT results?

    If you don’t know what GRAPH involves just say?

    1 user thanked author for this post.
    #111670

    That could work but offset must be in brackets and not parenthesis !

    1 user thanked author for this post.
    #112353

    Thanks Nicolas

    Yes, I should check when to use [] or ()

    #112354

    Thanks GraHal

    I was aware of RETURN but completely missed GRAPH. I’ll have a look and come back if I need assistance. Thanks again

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

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