Hi,
I would need help on this one.
I am testing a strategy with a trailing stop. When the trailing stop is active I want to increase the position size by buying one more contract.
I am using the following code but backtests results are exactly the same whether I add it or not:
//Increase position size
IF LONGONMARKET and trailingstart >0 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
I am using this version of trailing stop:
//trailing stop function
trailingstart = 20 //trailing will start @trailingstart points profit
trailingstep = 5 //trailing step to move the "stoploss"
//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 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 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
Any idea on how to increasing the size of position while already on market?
Thanks
Try …
//Increase position size
IF LONGONMARKET and NewSL > 0 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
It still does not work.
By the way I apologise as I used your suggestion in first place. I wrote my post too fast.
I am wondering if it is possible to increase the size of the position when already on market.
if it is possible to increase the size of the position when already on market.
Yes as long as in the same direction as the existing position.
I can’t see how my suggestion cannot work, but maybe we will both learn something when somebody tells us!? 😀
Thanks.
I am sure I am screwing something obvious up but I cannot find out what.
Which of these are you using …
Defparam Cumulate Orders = True
OR
Defparam Cumulate Orders = False
False…
I thought when set to true it only prevented concurrent orders, I did not know about this requirement to increase a position size.
Time to sleep I guess.
So it’s working now as you want (as we expected) now you are using True?
Results are better but I need further investigation to ensure this is the expected outcome. I keep you posted.
don’t forget if you want to increasing the size of position while already on market, you have to use PricePosition and not use TradePrice like on your code, you can see on this link a good example with explanation or Roberto
Thanks, I will have a look.
I also need to check the work you are doing on that Yen Strategy, it seems interesting. This Pro Builder/Order platform is so exciting, I cannot find enough time to explore all the gems available in the forum.