variables:
longstoploss
longprofit
shortstoploss
shortprofit
i have setstoploss and setprofit in on bar update, ie:
if(xxxxxxx)
{
golong;
setstoploss(longstoploss)
setprofit(longprofit)
}
if(xxxxxxx)
{
goshort;
setstoploss(shortstoploss)
setprofit(shortprofit)
}
**NOTE: please ignore the incorrect code that i'm posting above, the code i have in strategy is correct.
question: it seems that my positions are exiting prior to stoploss/profit target being hit, rather, when the opposite signal becomes true, the position is entered on the opposite side. for example, i'm long with X profit target and Y stoploss, Xprofit target and Xstoploss has not been hit, but short signal becomes valid, system exits the position and goes short.
how can i avoid the above? what i'm trying to do is, stay in the trade, once entered, and only exit once stoploss or profit target is hit. once either stoploss or profit target is hit, the system evaluates the data series for the next long/short trade.
thank you in advance.
Comment