Cumulative Pyramiding help!!!
Forums › ProRealTime English forum › ProBuilder support › Cumulative Pyramiding help!!!
- This topic has 6 replies, 3 voices, and was last updated 1 year ago by Nicolas.
-
-
02/06/2023 at 12:25 AM #209177
Hi all,
Grateful for any help. I am trying to put together a code that lets me add more positions (up to a maximum of 4 positions) in an automatic trade.
I’m looking to enter long / short when current price is greater that 0.5% in my favour.
I am also looking to exit the position when the current position moves 3% against me. So far, I have the following but I am not sure this is right. For some reason, it also doesn’t add the additional positions:
12345678910111213141516171819202122232425262728293031323334353637383940414243// Definition of code parametersDEFPARAM CumulateOrders = True // Cumulating positions activated// Conditions to enter long positionsc1 = (close > close[21])c2 = longonmarket AND Close => (1.005 * TradePrice)IF c1 OR c2 THENBUY 0.5 PERPOINT AT MARKETENDIF// Conditions to exit long positionsindicator1 = ExponentialAverage[30](close)c3 = (DClose(0) CROSSES UNDER indicator1[9])indicator2 = RSI[10](RSI[21](close))c4 = (indicator2 CROSSES OVER 70)indicator3 = DonchianChannelCenter[30]c5 = (DClose(0) CROSSES UNDER indicator3)c6 = PositionPerf[0] <= -3IF c3 AND c4 AND c5 OR (c6) THENSELL AT MARKETENDIF// Conditions to enter short positionsc6 = (DClose(0) < close[21])c7 = shortonmarket AND Close <= (TradePrice / 1.005)IF c6 OR c7 THENSELLSHORT 0.5 PERPOINT AT MARKETENDIF// Conditions to exit short positionsc8 = (DClose(0) > close[13])indicator4 = DonchianChannelCenter[30]c9 = (DClose(0) CROSSES OVER indicator4[11])indicator5 = RSI[10](RSI[21](close))c10 = (indicator5 CROSSES UNDER 30)c11 = PositionPerf[0] <= -3IF c8 AND c9 AND c10 or (c11) THENEXITSHORT AT MARKETENDIF02/06/2023 at 1:03 AM #20917902/06/2023 at 9:20 AM #209196Thanks! Also looking for help on inserting this limit.
Also does anyone know why you can backtest the stop loss and trailing stop together and as a percentage, but ProOrder won’t let you do both or add percentages?
02/06/2023 at 10:30 AM #209205Hi,
To add a limit to the number of contracts, you can use:
If c1 or c2 and CountOfLongShares<=4 then
If c6 and c7 and CountOfShortShares<=4 then
1 user thanked author for this post.
02/06/2023 at 10:39 AM #209206Here is a link to a trailing stop function that can be used as an alternative to the standard TS in ProBackTest…
https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
1 user thanked author for this post.
02/10/2023 at 3:28 PM #209515Do you know if this works in an automatic trade. Doesn’t seem to be working for me
02/13/2023 at 11:44 AM #209596Yes, it works, it has been used many times since years for traders in their strategies 🙂
For a specific trailing stop in percentage, you can look at these snippets:
https://www.prorealcode.com/topic/cannot-set-trailing-stop-as-through-ig/#post-83701
-
AuthorPosts
Find exclusive trading pro-tools on