Forums › ProRealTime English forum › ProOrder support › Entry, Stop Loss and Profit Target coding question › Reply To: Entry, Stop Loss and Profit Target coding question
Hi Nicolas,
I’ll try to understand your comment. Maybe I’ll find another article that helps me understand it. First I need to fully understand the condition.
In a recent comment regarding (barindex–barorder>=1 and barorder>0) that you added to my code, you said:
” Because we want to make sure at least 1 bar is elapsed since the opening of the order and that we are trying to close the current running order and not an “old one”. ”
So, barindex–barorder>=1 makes sure at least 1 bar is elapsed?
And barorder>0 would close the current running order and not an “old one”? I guess I am struggling to understand this part. What if I set it to barorder>=0, would it still close the current running order? In my example mentioned, changing it to barorder>=0 closed the trade after the first candle in the trade, and leaving it at barorder>0 the trade was not exited. But I don’t understand why because I don’t understand the condition.
In the code your wrote barorder = barindex, so can barorder ever be 0?
I would say no as barindex is the current bar loaded buy a trading system, so I would think at the time of a trading signal the barindex is not 0.
I guess you can see that I am confused. I’m sorry.