Algo tests well, but doesn’t run when live
Forums › ProRealTime English forum › ProOrder support › Algo tests well, but doesn’t run when live
- This topic has 5 replies, 3 voices, and was last updated 3 years ago by Nicolas.
-
-
11/19/2020 at 11:13 AM #150944
Hi All,
First time post for me. I wouldn’t turn to this forum unless I had tried everything myself first. I have created an algo that reflects my current strategy. It’s not a ‘World Beating’ strategy by any means.
As you will see by the code – I’m probably less than a rookie and have pieced this together with a base level code from the ‘builder’ and slowly added and tweaked it to fit my individual needs from others (JuanJ, Nicholas). But I guess that’s the point of the network! 😀
It tests well, and hits my current personal targets when backtesting, but when I have unleashed it, it hasn’t yet made a trade. Of course, this could be due to the parameters not being met, but when I then backtest, it shows trades being made that were not reflected in real time when the algo was on.
I wondered if I could have an eye cast to double check I hadn’t done anything silly. It seems to have not yet made a trade, since I added the breakeven addition (created by the infamous Nicholas). It’s likely due to me not including it properly.
Hugely appreciate any guidance.
Best Tom
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154// Definition of code parametersDEFPARAM CumulateOrders = FALSE // Cumulating positions deactivated// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 000000timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 240000timeEnterAfter = time < noEntryAfterTime// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0If dayofweek >= 5 and hour > 22 ThenIf longonmarket ThenSell at marketElsIf shortonmarket ThenExitshort at marketEndIfEndIfAA = periodATR = AverageTrueRange[2](close)//Breakeven functionalitystartBreakeven = 30//pips to gain before breakeven functionalityPointsToKeep = 5 //pips to keep in profit above or below entry price when breakeven is activated// Conditions to enter long positionsindicator1 = Average[100](close)c1 = (close > indicator1)indicator2 = RSI[2](close)c2 = (indicator2 > 70)indicator3 = Average[AA](close)+1.618*std[AA](close)c3 = (close[1] > indicator3)indicator4 = Average[AA](close)+1.618*std[AA](close)c4 = (close > indicator4)c5 = (open > open[2])IF (c1 AND c2 AND c3 AND c4 AND c5) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENBUY 5 CONTRACT AT MARKETSET STOP pTRAILING 50ENDIF// Conditions to enter long positions #2indicator5 = Average[100](close)c6 = (close < indicator5)indicator6 = RSI[2](close)c7 = (indicator6 > 50)indicator7 = Average[AA](close)-1.618*std[AA](close)c8 = (close[1] < indicator7)indicator8 = Average[AA](close)-1.618*std[AA](close)c9 = (close > indicator8)IF c6 AND c7 AND c8 AND c9 THENBUY 5 CONTRACT AT MARKETSET STOP pTRAILING 50ENDIFIF NOT ONMARKET THENbreakevenLevel=0EndifIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIFIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIF// Conditions to exit long positionsindicator9 = Average[AA](close)+1.618*std[AA](close)c10 = (close[2] > indicator9)indicator10 = Average[AA](close)+1.618*std[AA](close)c11 = (close[1] > indicator10)indicator11 = Average[AA](close)+1.618*std[AA](close)c12 = (close < indicator11)indicator12 = Average[AA](close)+1.618*std[AA](close)c13 = (high[1] > indicator12)indicator13 = Average[AA](close)+1.618*std[AA](close)c14 = (high < indicator13)IF c10 AND c11 AND c12 AND c13 AND c14 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator10 = Average[100](close)c11 = (close > indicator10)indicator11 = RSI[2](close)c12 = (indicator11 < 50)indicator12 = Average[AA](close)+1.618*std[AA](close)c13 = (close[1] > indicator12)indicator13 = Average[AA](close)+1.618*std[AA](close)c14 = (close < indicator13)IF (c11 AND c12 AND c13 AND c14) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENSELLSHORT 5 CONTRACT AT MARKETSET STOP pTRAILING 50ENDIF//Conditions to enter short positions #2indicator14 = Average[100](close)c15 = (close < indicator14)indicator15 = RSI[2](close)c16 = (indicator15 < 40)indicator16 = Average[AA](close)-1.618*std[AA](close)c17 = (close[1] < indicator16)indicator17 = Average[AA](close)-1.618*std[AA](close)c18 = (close < indicator17)c19 = (open < open[2])IF c15 AND c16 AND c17 AND c18 AND c19 THENSELLSHORT 5 CONTRACT AT MARKETSET STOP pTRAILING 50ENDIFIF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)-PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENEXITSHORT AT breakevenLevel STOPENDIF// Conditions to exit short positionsindicator14 = Average[AA](close)-1.618*std[AA](close)c15 = (close[2] < indicator14)indicator15 = Average[AA](close)-1.618*std[AA](close)c16 = (close[1] < indicator15)indicator16 = Average[AA](close)-1.618*std[AA](close)c17 = (low[2] < indicator16)indicator17 = Average[AA](close)-1.618*std[AA](close)c18 = (low[1] > indicator17)IF c15 AND c16 AND c17 AND c18 THENEXITSHORT AT MARKETENDIFIf (indicator2 > 95) ThenSell at marketElsIf ((close > close[1] + ATR) or SHORTONMARKET) and indicator2 < 5 ThenExitshort at marketEndIf11/19/2020 at 11:20 AM #15094611/19/2020 at 11:58 AM #150949Hi Nicholas,
Thanks for coming back so quickly – real pleasure to get your support.
AA is the variable label I use for the bollinger band period – I run an optimisation from 1 to 100 to understand the best n period for that pair.
I do a maximum of 2 contracts currently – I plucked it from the air tbh.
I hope I explained that clearly.
Tom
11/19/2020 at 12:22 PM #15095111/19/2020 at 12:53 PM #15095211/19/2020 at 1:57 PM #150963 -
AuthorPosts