Increase position size x % after winning trade
Forums › ProRealTime English forum › ProOrder support › Increase position size x % after winning trade
- This topic has 12 replies, 5 voices, and was last updated 3 years ago by robertogozzi.
-
-
05/21/2020 at 10:13 PM #132718
Hi all newbie looking for some help as am learning the ProOrder ropes.
I have read the manual and have some very simple code tested and working –
123456789101112// Conditions to enter long positionsc1 = (RSIind < 30)//RSI upward momentum// Conditions to enter long positionsIF NOT LongOnMarket AND c1 THENBUY 1 CONTRACTS AT MARKETSet target pprofit TPSET STOP pLOSS SLENDIFTP =30SL =100I am trying to work out how to increase the position size but only after a winning trade – I want to increase it by 20% i.e x 1.2
So if trade at 1 pp hits profit target and closes, the next position is at 1.2 pp, then 1.44, then 1.73 and so on. Position size to stay the same after a losing trade has closed.
I had a look at martingales etc and tried to reverse that, but cannot work it out. Any ideas?!
Thanks
05/21/2020 at 11:42 PM #132724I have been thinking about this a bit more and think I can explain it better, by removing IF NOT LongOnMarket – i.e I want the position to open whether I am long or not.
I want to open the position size 1 when RSI < 30. If next candle is still <33 another position opens sized 1, and again sized 1 etc until either RSI > 30 or target profit hit (+30), or stop hit (-100).
So if three candles are RSI < 30 I will have a total position size of for example 3 @ 98, but entry point might be 1 @ 99, 1 @ 98, 1 @ 97.
What I am trying to achieve is
- have the target and stop + 30 & – 100 from 98, rather than 99, 98 and 97.
- If RSI rises above 30, and positions are open and then RSI reaches < 30 I want the new positions to open at the same size the sequence started – i.e in this case 1
- If positions are closed in winning trade, next open position I want to be 20% higher = i.e 1.2, and that sequence to continue.
- If positions are closed in losing trade, next open position I want to be the same size as the the start of the sequence that was the losing trade.
Does that make sense, and if so is it possible?
Thanks!
05/22/2020 at 12:48 AM #132733Code from your first post:
123456789101112131415ONCE LotSize = 1ONCE PereCent = 1.2ONCE TP = 30ONCE SL = 100IF StrategyProfit > StrategyProfit[1] THENLotSize = LotSize * PerCentENDIF// Conditions to enter long positionsc1 = (RSIind < 30) //RSI upward momentum// Conditions to enter long positionsIF NOT LongOnMarket AND c1 THENBUY LotSize CONTRACTS AT MARKETSet target pprofit TPSET STOP pLOSS SLENDIF1 user thanked author for this post.
05/22/2020 at 7:30 AM #132743Hi thanks, but could not get that to work. Noticed the ‘perecent’ typo, and corrected it. Code is accepted but when I test it, it seems like it opens a position but never shuts it. Results re trades are N/A
Strategy profit pointer is helpful thanks, I will have a closer look at the manual re that.
05/22/2020 at 7:37 AM #13274505/22/2020 at 7:47 AM #132746I am trying to increase position size if previous trade was profitable.
You need to use PositionPerf(n) where n = 0 if no current open positions or n = 1 if there is a position open and you want the performance of the previous trade.
1 user thanked author for this post.
05/22/2020 at 9:23 AM #132768It never exits until you tell it to properly. This would be fine on Dax, Sp500 or the like, where pips are 1:1 with price, it’ll not work on fx pairs where that ratio is 10000:1.
Aleays use PipSize to multiply values at lines 3-4.
STRATEGYPROFIT is what you need, it returns the whole strategy report, when a trade is closed, comparing the current value against the previous one will tell you if any trade has been closed and if it was profitable or not.
POSITIONPERF only returns, in percentage, not money, the status of a current position, which can be profitable at times but could be losing in the end.
05/22/2020 at 9:40 AM #13277312/25/2020 at 8:47 AM #1551781234567891011121314151617181920212223242526272829Once TradeON = 1Once count1 = 0If IntraDayBarIndex = 0 thenTradeON = 1Count1 = 0EndifIf StrategyProfit < StrategyProfit[1] thenCount1 = Count1 + 1positionsize=positionsize * 0.5Elsif StrategyProfit > StrategyProfit[1] thenpositionsize=positionsize*1.25Count1 = 0EndifIf Count1 >= 5 thenTradeON = 0EndifIF NOT SHORTONMARKET And Entry and tradeon and (gobuy or (gobuy[1] )) THENBUY Positionsize CONTRACT AT MARKETset stop Loss sl//set target $profit 50ENDIFI was trying to limit trading for the day once 5 consequetive losses are hit. Also trying to reduce position size if previous trade lost and increase it when previous trade won. This code does not seem to be doing anything. My cumulative order is true. Any help would be great
12/25/2020 at 9:24 AM #155179I am not able to test it now, but code seems logically correct.
What does “This code does not seem to be doing anything” mean? Doesn’t it open any trade? Doesn’t it increase/decrease position size? Doesn’t it stop trading after 5 consecutive losses?
12/25/2020 at 9:37 AM #15518012/25/2020 at 11:38 AM #1551831234567equity = Capital + StrategyProfitmaxrisk = round(equity*Risk)PositionSize = abs(((maxrisk/SL)/PointValue)*pipsize)if tradeprice(1+n)>0 thenn=n+1endifThe above code is calculating the positionsize.
Its not doing anything means, with or without code the result is same. Its neither increasing or decreasing size . The TradeOn part to not trade after few losses does not do anything as well
12/26/2020 at 1:07 AM #155215The issue is at line 9, as you halve PositionSize, it will become less than the minimum size required, change it to:
1positionsize=max(0.5,positionsize * 0.5) //Min. size=0.5 or greater -
AuthorPosts
Find exclusive trading pro-tools on