AbzParticipant
Veteran
Hello,
i am trying to use the attached code for backtesting strategies and it produces a lot of “EVEN” trades this only happens if i run it on prorealtime if i run prorealtime trough IG it does not happen. Anyone why this happens?
////trailing stop function
trailingstart = 3 //trailing will start @trailinstart points profit 25
trailingstep = 1 //trailing step to move the "stoploss" 30 21 & 9
slDistance = 0.6 // <--- to compensate for SL distance reqs emposed by the dealer.
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize+slDistance THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize+slDistance THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
set stop ploss 5
AbzParticipant
Veteran
*solved*
instead of using pipsize i used pointsize then it worked
Are you sure you didn’t change anything else?
Because PointSize and PipSize are two different names for the same thing, as from language doc https://www.prorealcode.com/documentation/pipsize/.
Indeed a tried a simple debugging strategy and, despite I wanted to GRAPH both, ProOrder displayed only one of them (the same is true for PipValue and PointValue as well).
AbzParticipant
Veteran
i only changed that and the backtest worked prfectly
Well, then there must be a bug either in the DOC or in ProOrder!