RSI strategy on PRO RealCode giving only BUY signals
Forums › ProRealTime English forum › General trading discussions › RSI strategy on PRO RealCode giving only BUY signals
- This topic has 9 replies, 6 voices, and was last updated 5 years ago by Nicolas.
-
-
12/18/2016 at 7:57 PM #18747
Hi All,
Below is modified RSI strategy from PRORealcode pdf document but its giving only Long signals on any instrument i want to demo test it on on EURUSD and DAX
Can someone experienced look into it and suggest what might be wrong in below approach and why its always profitable this is blowing my mind.
Many Thanks
Code as below
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152ONCE NbBarLimit = 5ONCE ProfitTarget = 5ONCE xStopLoss = 4ONCE yStopLoss = 2ONCE OrderSize = 1ONCE CountofShares = 10MyRSI = RSI[14](Close)MyBollingerDown = BollingerDown[25](Close)MyBollingerUp = BollingerUp[25](Close)IF MyRSI < 30 AND Close < MyBollingerDown THENMyLimitBuy =closeMyBuyIndex = barindexENDIFIF MyRSI > 70 AND Close > MyBollingerUp THENMyLimitSell=closeMySellIndex = barindexENDIFIf BarIndex >= MyBuyIndex + NbBarLimit THENMyLimitBuy = 0EndIFIf BarIndex >= MySellIndex + NbBarLimit THENMyLimitSell = 0EndIFIF MyLimitSell > 0 AND COUNTOFSHORTSHARES < CountofShares THENIF LongOnMarket THENSELL (CountOfPosition + OrderSize) SHARES AT MyLimitSell LIMITELSESELL OrderSize SHARES AT MyLimitSell LIMITENDIFSET STOP %LOSS xStopLoss %TRAILING yStopLossSET TARGET %PROFIT ProfitTargetENDIFIF MyLimitBuy > 0 AND COUNTOFLONGSHARES < CountofShares THENIF ShortOnMarket THENBUY (CountOfPosition + OrderSize) SHARES AT MyLimitBuy LIMITELSEBUY OrderSize SHARES AT MyLimitBuy LIMITENDIFSET STOP %LOSS xStopLoss %TRAILING yStopLossSET TARGET %PROFIT ProfitTargetENDIFIf Strategyprofit < -2000 THENQUITENDIFMODERATORS EDIT: Code tidied up using ‘Insert PRT Code’ button.
12/18/2016 at 9:36 PM #18752Hi Fes
Please use the insert PRT Code button cos I just copied all your code to try it for you but it has pasted with no format into my PRT and it would be time consuming for me to sort it out etc.
Below is how your code pastes into PRT?
Hope that makes sense?
PS I cant see a SellShort in the code anyway?
Cheers
GraHalNbBarLimit = 5 ONCE ProfitTarget = 5 ONCE xStopLoss = 4 ONCE yStopLoss = 2 ONCE OrderSize = 1 ONCE CountofShares = 10 MyRSI = RSI[14](Close) MyBollingerDown = BollingerDown[25](Close) MyBollingerUp = BollingerUp[25](Close) IF MyRSI < 30 AND Close < MyBollingerDown THEN MyLimitBuy =close MyBuyIndex = barindex ENDIF IF MyRSI > 70 AND Close > MyBollingerUp THEN MyLimitSell=close MySellIndex = barindex ENDIF If BarIndex >= MyBuyIndex + NbBarLimit THEN MyLimitBuy = 0 EndIF If BarIndex >= MySellIndex + NbBarLimit THEN MyLimitSell = 0 EndIF IF MyLimitSell > 0 AND COUNTOFSHORTSHARES < CountofShares THEN IF LongOnMarket THEN SELL (CountOfPosition + OrderSize) SHARES AT MyLimitSell LIMIT ELSE SELL OrderSize SHARES AT MyLimitSell LIMIT ENDIF SET STOP %LOSS xStopLoss %TRAILING yStopLoss SET TARGET %PROFIT ProfitTarget ENDIF IF MyLimitBuy > 0 AND COUNTOFLONGSHARES < CountofShares THEN IF ShortOnMarket THEN BUY (CountOfPosition + OrderSize) SHARES AT MyLimitBuy LIMIT ELSE BUY OrderSize SHARES AT MyLimitBuy LIMIT ENDIF SET STOP %LOSS xStopLoss %TRAILING yStopLoss SET TARGET %PROFIT ProfitTarget ENDIF If Strategyprofit < -2000 THEN QUIT ENDIF
12/18/2016 at 10:08 PM #18753Here you go
Thanks GraHal for looking into this.
Basically its RSI + Bollinger bar strategy as seen on PRO pdf
If RSI <30 and Bollinger25 is Down then Go Long limit order at Daily Close
If RSI>70 and Bollinger25 is Up then go short limit order at Daily Close
But its giving only long positions never short ones. if i remove the Short If condition it says you need to buy or sell. i havent used SellShort but used Sell. Is it not the opposite of Buy?
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556ONCE NbBarLimit = 5ONCE ProfitTarget = 5ONCE xStopLoss = 7ONCE yStopLoss = 2ONCE OrderSize = 1ONCE CountofShares = 10MyRSI = RSI[14](Close)MyBollingerDown = BollingerDown[25](Close)MyBollingerUp = BollingerUp[25](Close)IF MyRSI < 30 AND Close < MyBollingerDown THENMyLimitBuy =closeMyBuyIndex = barindexENDIFIF MyRSI > 70 AND Close > MyBollingerUp THENMyLimitSell=closeMySellIndex = barindexENDIFIf BarIndex >= MyBuyIndex + NbBarLimit THENMyLimitBuy = 0EndIFIf BarIndex >= MySellIndex + NbBarLimit THENMyLimitSell = 0EndIF//Go ShortIF MyLimitSell > 0 AND COUNTOFSHORTSHARES < CountofShares THENIF LongOnMarket THENSELL (CountOfPosition + OrderSize) SHARES AT MyLimitSell LIMITELSESELL OrderSize SHARES AT MyLimitSell LIMITENDIFSET STOP %LOSS xStopLoss %TRAILING yStopLossSET TARGET %PROFIT ProfitTargetENDIF//IF MyLimitBuy > 0 AND NOT LongOnMarket THEN//Go LongIF MyLimitBuy > 0 AND COUNTOFLONGSHARES < CountofShares THENIF ShortOnMarket THENBUY (CountOfPosition + OrderSize) SHARES AT MyLimitBuy LIMITELSEBUY OrderSize SHARES AT MyLimitBuy LIMITENDIFSET STOP %LOSS xStopLoss %TRAILING yStopLossSET TARGET %PROFIT ProfitTargetENDIFIf Strategyprofit < -2000 THENQUITENDIF12/18/2016 at 10:20 PM #1875412/19/2016 at 12:22 AM #18757Just want to tell ya all
after i fixed the above issue my strategy went from 28% in profit to -20% drawdown
guess it depends on market some markets who are trending a lot can give good results using above strategy but only from buyside and closing the trades by goofup using sell orders 🙂
Market is not perfect so why should algorithmic strategy to be perfect by adding this defect its giving me good results in a range of markets.
Cheers
06/21/2019 at 4:29 PM #101176Hello, I’m a beginner in trading, and your strategy seems really interesting in the backtests. When I try to activate it as a demo, PRT tells me several messages: ” trailings stops defined in percentage can not be used in proorder.
– Trading systems with instructions that may result in a partial closing of position may not be sent to proorder. Please make sure that no quantity is specified in the instructions for closing positions
– combined stops can not be used with proorder.
Your code looks great, I would love to test it. Thanks for your help
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556ONCE NbBarLimit = 5ONCE ProfitTarget = 5ONCE xStopLoss = 7ONCE yStopLoss = 2ONCE OrderSize = 1ONCE CountofShares = 10MyRSI = RSI[14](Close)MyBollingerDown = BollingerDown[25](Close)MyBollingerUp = BollingerUp[25](Close)IF MyRSI < 30 AND Close < MyBollingerDown THENMyLimitBuy =closeMyBuyIndex = barindexENDIFIF MyRSI > 70 AND Close > MyBollingerUp THENMyLimitSell=closeMySellIndex = barindexENDIFIf BarIndex >= MyBuyIndex + NbBarLimit THENMyLimitBuy = 0EndIFIf BarIndex >= MySellIndex + NbBarLimit THENMyLimitSell = 0EndIF//Go ShortIF MyLimitSell > 0 AND COUNTOFSHORTSHARES < CountofShares THENIF LongOnMarket THENSELL (CountOfPosition + OrderSize) SHARES AT MyLimitSell LIMITELSESELL OrderSize SHARES AT MyLimitSell LIMITENDIFSET STOP %LOSS xStopLoss %TRAILING yStopLossSET TARGET %PROFIT ProfitTargetENDIF//IF MyLimitBuy > 0 AND NOT LongOnMarket THEN//Go LongIF MyLimitBuy > 0 AND COUNTOFLONGSHARES < CountofShares THENIF ShortOnMarket THENBUY (CountOfPosition + OrderSize) SHARES AT MyLimitBuy LIMITELSEBUY OrderSize SHARES AT MyLimitBuy LIMITENDIFSET STOP %LOSS xStopLoss %TRAILING yStopLossSET TARGET %PROFIT ProfitTargetENDIFIf Strategyprofit < -2000 THENQUITENDIF06/21/2019 at 4:48 PM #101178To write code, please use the <> “insert PRT code” button, to make code easier to read.
Thank you.
06/21/2019 at 6:53 PM #10118306/22/2019 at 7:11 PM #101212The strategy partially closes positions. Currently in PRT it is possible to back test strategies that do this but it is not possible to forward test them on either live or demo. This is why you get the messages.
Also the code that you have posted still has the error that it is using SELL where it should use SELLSHORT.
06/24/2019 at 7:18 AM #101260 -
AuthorPosts
Find exclusive trading pro-tools on