Increasing a position size
Forums › ProRealTime English forum › ProOrder support › Increasing a position size
- This topic has 10 replies, 3 voices, and was last updated 1 year ago by KumoNoJuzza.
-
-
04/28/2023 at 5:51 PM #213831
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:
1234//Increase position sizeIF LONGONMARKET and trailingstart >0 THENBUY 1 CONTRACT AT MARKETENDIFI am using this version of trailing stop:
1234567891011121314151617181920212223242526272829303132333435363738//trailing stop functiontrailingstart = 20 //trailing will start @trailingstart points profittrailingstep = 5 //trailing step to move the "stoploss"//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIFAny idea on how to increasing the size of position while already on market?
Thanks
04/28/2023 at 6:34 PM #21383204/28/2023 at 7:30 PM #213833It 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.
04/28/2023 at 7:36 PM #213834if 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!? 😀04/28/2023 at 7:39 PM #213835Thanks.
I am sure I am screwing something obvious up but I cannot find out what.
04/28/2023 at 7:46 PM #213836Which of these are you using …
123Defparam Cumulate Orders = TrueORDefparam Cumulate Orders = False1 user thanked author for this post.
04/28/2023 at 8:38 PM #213837False…
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.
04/28/2023 at 8:54 PM #21383904/29/2023 at 8:15 AM #213845Results are better but I need further investigation to ensure this is the expected outcome. I keep you posted.
1 user thanked author for this post.
05/01/2023 at 11:17 PM #213953don’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
1 user thanked author for this post.
05/04/2023 at 10:44 AM #214116Thanks, 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.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on