Add new position
Forums › ProRealTime English forum › ProOrder support › Add new position
- This topic has 6 replies, 4 voices, and was last updated 7 years ago by Abz.
-
-
05/10/2017 at 10:07 PM #35137
Hello
i want to check my position on market i want to add one more shares to it with seperat profit target and stop loss. for example if iam longonmarket and my position is in -20points i want to buy 5 more shares. and same for if i am short on market and the trade is against me i want to short more shares. i want seperat target and stopp loss for these ekstra shares.
i did try this but cant get it to work
12345678910if longonmarket and close - tradeprice < -20*pointsize thenbuy 5 SHARES AT MARKETSET STOP ploss 30//20SET TARGET pPROFIT 20 //54endifif shortonmarket and close - tradeprice > 20*pointsize thensellshort 5 SHARES AT MARKETSET STOP ploss 30//20SET TARGET pPROFIT 20 //54endif12345678910111213141516171819202122232425262728293031// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedDEFPARAM FLATBEFORE = 170000DEFPARAM FLATAFTER = 220000// indicatorsPSAR = SAR[0.02,0.02,0.2]MA = Average[41](close)Rs = RSI[15](close)c13 = Time < 192000// Conditions to enter Long positionsc1 = (close > PSAR)c2 = (close crosses over MA)c3 = Rs <= 60IF not onmarket AND c13 AND c1 AND c2 AND c3 THENBuy 2 SHARES AT MARKETENDIF// Conditions to enter Short positionsc6 = (close < PSAR)c7 = (close < MA)c8 = Rs >= 50IF not onmarket AND c13 AND c6 AND c7 AND c8 THENSellshort 2 SHARES AT MARKETENDIFSET STOP pLOSS 50SET TARGET pPROFIT 5005/10/2017 at 11:17 PM #35140You First need to set this to true else no new positions will be entered
1234<span class="token keyword">DEFPARAM</span> <span class="token keyword">CumulateOrders</span> <span class="token operator">=</span> True<span class="token comment" spellcheck="true">// Cumulating positions deactivated</span>05/10/2017 at 11:29 PM #351411Tested on EURUSD 1h Not sure if this is what you looking for not bad results12345678910111213141516171819202122232425262728293031323334353637383940414243// Definition of code parametersDEFPARAM CumulateOrders = True // Cumulating positions deactivatedDEFPARAM FLATBEFORE = 170000DEFPARAM FLATAFTER = 220000// indicatorsPSAR = SAR[0.02,0.02,0.2]MA = Average[41](close)Rs = RSI[15](close)c13 = Time < 192000// Conditions to enter Long positionsc1 = (close > PSAR)c2 = (close crosses over MA)c3 = Rs <= 60IF not onmarket AND c13 AND c1 AND c2 AND c3 THENBuy 2 SHARES AT MARKETsl = 50tp = 50ELSIF longonmarket and close - tradeprice < -20*pointsize thenbuy 5 SHARES AT MARKETsl = 30tp = 20ENDIF// Conditions to enter Short positionsc6 = (close < PSAR)c7 = (close < MA)c8 = Rs >= 50IF not onmarket AND c13 AND c6 AND c7 AND c8 THENSellshort 2 SHARES AT MARKETsl = 50tp = 50ELSIF shortonmarket and close - tradeprice > 20*pointsize thenSellshort 5 SHARES AT MARKETsl = 30tp = 20ENDIFSET STOP pLOSS slSET TARGET pPROFIT tp105/11/2017 at 10:07 AM #35172Hiya,
Not a terrible idea here. You should probably separate indicator variables for long and short entries though.
Obviously a good amount of work needs to be done here to make it a viable strategy in PRT (dynamic stops and targets, more filtering, proper position size management, time management etc) but for now I’ve done a little tweak for you here. The optimization may make up for PRT’s lack of multi-position management tools such as multiple stops and limits – which is what I believe you were after, @Abz.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970// Definition of code parametersDEFPARAM CumulateOrders = True // Cumulating positions deactivatedDEFPARAM FLATBEFORE = 160000DEFPARAM FLATAFTER = 210000// Variablesonce optimization = 2if optimization = 1 then // originalrsiPeriodLongs = 15rsiPeriodShorts = 15maPeriodLongs = 41maPeriodShorts = 41maType = 0rsiLongThresh = 60rsiShrtThresh = 50elsif optimization = 2 then //EUR_USD H1rsiPeriodLongs = 18rsiPeriodShorts = 18rsiLongThresh = 63rsiShrtThresh = 49maType = 5maPeriodLongs = 41maPeriodShorts = 30endiftradingTime = time < 182000// indicatorsPSAR = sar[0.02,0.02,0.2]MALongs = average[maPeriodLongs, maType](close)MAShorts = average[maPeriodShorts, maType](close)rLongs = rsi[rsiPeriodLongs](close)rShorts = rsi[rsiPeriodShorts](close)// Conditions to enter Long positionsc1 = (close > PSAR)c2 = (close crosses over MALongs)c3 = rLongs <= rsiLongThreshIF (not onmarket) AND tradingTime AND c1 AND c2 AND c3 THENBuy 2 SHARES AT MARKETsl = 50tp = 50ELSIF longonmarket and close - tradeprice < -20*pointsize thenbuy 5 SHARES AT MARKETsl = 30tp = 20ENDIF// Conditions to enter Short positionsc6 = (close < PSAR)c7 = (close < MAShorts)c8 = rShorts >= rsiShrtThreshIF not onmarket AND tradingTime AND c6 AND c7 AND c8 THENSellshort 2 SHARES AT MARKETsl = 50tp = 50ELSIF shortonmarket and close - tradeprice > 20*pointsize thenSellshort 5 SHARES AT MARKETsl = 30tp = 20ENDIFSET STOP pLOSS slSET TARGET pPROFIT tpNote this is just very quick and rough – not for production – but do continue tweaking. This version was wrapped around EUR_USD H1 and has at least a year of spinning its wheels (take the equity curve with a pinch of salt). I have also changed timezone for my locale so do change the times to your own locale.
Best,
M
05/11/2017 at 12:21 PM #3519705/11/2017 at 2:43 PM #3521705/11/2017 at 9:57 PM #35256 -
AuthorPosts
Find exclusive trading pro-tools on