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
ONCE NbBarLimit = 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
MODERATORS EDIT: Code tidied up using ‘Insert PRT Code’ button.
Hi 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
GraHal
NbBarLimit = 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
Here 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?
ONCE NbBarLimit = 5
ONCE ProfitTarget = 5
ONCE xStopLoss = 7
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
//Go Short
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 NOT LongOnMarket THEN
//Go Long
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
Thanks GraHal
Thanks for he;ping me out
Sell was to close Long position
and SellShort to initiate Short
should have looked at appendix and documentation
Cheers
Thanks for looking into this
Just 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
Hello, 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
ONCE NbBarLimit = 5
ONCE ProfitTarget = 5
ONCE xStopLoss = 7
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
//Go Short
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 NOT LongOnMarket THEN
//Go Long
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
@shady5700
To write code, please use the <> “insert PRT code” button, to make code easier to read.
Thank you.
Hi Shady
Try attached … same code as in your post, I just added the cumulateorders = False … works fine, see attached.
Spread = 4
You need to Import the .itf file onto your Platform
The 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.
Combining 2 stoploss instructions as at line 38 is also not permitted. You should replace the trailing stop instruction by a coded version instead.