auto goes opposite from backtest
Forums › ProRealTime English forum › ProOrder support › auto goes opposite from backtest
- This topic has 9 replies, 3 voices, and was last updated 6 years ago by
Nicolas.
-
-
11/22/2018 at 4:24 PM #85499
Hope someone can help me out with this, PING NICOLAS!
My backtest takes a short while when putting it on automatic trading it took a long today (see picture) Happened several times now.
This is the code im using:
open dax123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236//-------------------------------------------------------------------------// Main code : Open DAX 5 optimerad//-------------------------------------------------------------------------//-------------------------------------------------------------------------// Main code : Open DAX 5 optimerad//-------------------------------------------------------------------------//-------------------------------------------------------------------------// Main Code : Straddle Dayopen V2.0//-------------------------------------------------------------------------// Test On DAX 30 Cash 10 Minute Timeframe 200k bars or from 1/1/2015// Common RulesDefparam Cumulateorders = FalseDefparam Preloadbars = 1000// On/offExtratradecriteria = 0 // I.e. Long; Only Enters When The Current Bar High Is Lower Then The Lowest Daily High From Today, Yesterday And Day Before.Usepercentage = 0 // The Minimum Difference In Percentage [[1] From Dayopen Or In Points [0] From DayopenMfetrailing = 1 // Mfe Trailing StopWtrailing = 1 // Williams 3 Bar Trailing StopBreakevenstop = 1 // Breakevenstop, Move Stoploss When Position Is In Profit.Excludefirsttwoweeks = 1 // Exclude The First 2 Weeks Of Every Year (Weeknumber 1 And 2)// SettingsPositionsize = 1SL = 0.6 // % StoplossPT = 1.5 // % Profit TargetMFETS = 0.35 // % Mfe Trailing StopBES = 0.35 // % Break Even StopBESMP = 0.05 // % Break Even Stop Minimum ProfitWTSMP = 0.50 // % Williams Trailing Stop Minimum Profit If Mfe Trailing Stop Is Not UsedETD = 0 // Exclude a Trade Day; Sunday = 0If Usepercentage ThenNopl=((Dayopen*0.15)/100)/pointsizeNops=((Dayopen*0.15)/100)/pointsizeElseNopl=16 //number of points longNops=12 //number of points shortEndif// Day & TimeOnce Entertime = 090000Once Lasttime = 100000Once Closetime = 172500 // Greater Then 23.59 Means It Continues Position OvernightOnce Closetimefr=173500If Excludefirsttwoweeks=1 ThenIf Year=2015 And Month=1 And (Day>=1 And Day<=18) ThenNotrading = 1Elsif Year=2016 And Month=1 And (Day>=1 And Day<=24) ThenNotrading = 1Elsif Year=2017 And Month=1 And (Day>=1 And Day<=22) ThenNotrading = 1Elsif Year=2018 And Month=1 And (Day>=1 And Day<=21) ThenNotrading = 1Elsif Year=2019 And Month=1 And (Day>=1 And Day<=20) ThenNotrading = 1ElseNotrading = 0EndifEndifTt1 = Time >= EntertimeTt2 = Time <= LasttimeTradetime = Tt1 And Tt2 and Notrading = 0 And Dayofweek <> ETD// Reset At StartIf Intradaybarindex = 0 ThenLongtradecounter = 0Shorttradecounter = 0Tradecounter = 0Mclong = 0Mcshort = 0Endif// [pc] Position CriteriaPclong = Countoflongshares < 1 And Longtradecounter < 1 And Tradecounter < 1Pcshort = Countofshortshares < 1 And Shorttradecounter < 1 And Tradecounter < 1// [mc] Main CriteriaIf Time = Entertime ThenDayopen=openEndifIf High > Dayopen+nopl ThenMclong=1ElseMclong=0EndifIf Low < Dayopen-nops ThenMcshort=1ElseMcshort=0Endif// [ec] Extra CriteriaIf Extratradecriteria ThenMin1 = Min(Dhigh(0),dhigh(1))Min2 = Min(Dhigh(1),dhigh(2))Max1 = Max(Dlow(0),dlow(1))Max2 = Max(Dlow(1),dlow(2))Eclong = High < Min(Min1,min2)Ecshort = Low > Max(Max1,max2)elseEclong=1Ecshort=1Endif// Long & Short EntryIf Tradetime ThenIf Pclong and Mclong And Eclong ThenBuy Positionsize Contract At MarketLongtradecounter=longtradecounter + 1Tradecounter=tradecounter+1EndifIf Pcshort and Mcshort And Ecshort ThenSellshort Positionsize Contract At MarketShorttradecounter=shorttradecounter + 1Tradecounter=tradecounter+1EndifEndif// Break Even StopIf Breakevenstop ThenIf Not Onmarket ThenNewsl=0EndifIf Longonmarket And close-tradeprice(1)>=((Tradeprice/100)*BES)*pipsize ThenNewsl = Tradeprice(1)+((Tradeprice/100)*BESMP)*pipsizeEndifIf Shortonmarket And Tradeprice(1)-close>=((Tradeprice/100)*BES)*pipsize ThenNewsl = Tradeprice(1)-((Tradeprice/100)*BESMP)*pipsizeEndifIf Newsl>0 ThenSell At Newsl StopExitshort At Newsl StopEndifEndif// Exit Mfe Trailing StopIf Mfetrailing ThenTrailingstop = (Tradeprice/100)*MFETSIf Not Onmarket ThenMaxprice = 0Minprice = ClosePriceexit = 0EndifIf Longonmarket ThenMaxprice = Max(Maxprice,close)If Maxprice-tradeprice(1)>=trailingstop*pipsize ThenPriceexit = Maxprice-trailingstop*pipsizeEndifEndifIf Shortonmarket ThenMinprice = Min(Minprice,close)If Tradeprice(1)-minprice>=trailingstop*pipsize ThenPriceexit = Minprice+trailingstop*pipsizeEndifEndifIf Onmarket And Wtrailing=0 And Priceexit>0 ThenSell At MarketExitshort At MarketEndifEndif// Exit Williams Trailing StopIf Wtrailing ThenCount=1I=0J=i+1Tot=0While Count<4 DoTot=tot+1If (Low[j]>=low[i]) And (High[j]<=high[i]) ThenJ=j+1ElseCount=count+1I=i+1J=i+1EndifWendBasso=lowest[tot](Low)Alto=highest[tot](High)If Close>alto[1] ThenRef=bassoEndifIf Close<basso[1] ThenRef=altoEndifIf Onmarket And Mfetrailing=0 And Positionperf>WTSMP ThenIf Low[1]>ref And High<ref ThenSell At MarketEndifIf High[1]<ref And Low>ref ThenExitshort At MarketEndifEndifIf Onmarket And Mfetrailing=1 And Priceexit>0 ThenIf High<ref ThenSell At MarketEndifIf Low>ref ThenExitshort At MarketEndifEndifEndif// Exit At ClosetimeIf Onmarket ThenIf Time >= Closetime ThenSell At MarketExitshort At MarketEndifEndif// Exit At Closetime FridayIf Onmarket ThenIf (Currentdayofweek=5 And Time>=closetimefr) ThenSell At MarketExitshort At MarketEndifEndif// Build-in ExitSet Stop %loss SLSet Target %profit PT//graph 0 Coloured(300,0,0) As "Zeroline"//graph (Positionperf*100)coloured(0,0,0,255) As "Positionperformance"11/22/2018 at 5:04 PM #8550411/22/2018 at 5:14 PM #85509Did you start it today? Customized trading hours on your chart or not?
started it like a week ago. Yes have customized trading hours on chart to be able to see gaps. +1 timezon and showing 08:00-16:30 (shows std at 0 timezon) since DAX opens at 09-17,30
11/26/2018 at 2:57 PM #8574111/28/2018 at 12:01 AM #8587811/28/2018 at 10:00 AM #85889Are you making it as easy as you possibly can for somebody to see at a glance what the symptoms of your problem are?
For example, why don’t you show 2 screenshots side by side with arrows pointing to the 2 trade positions that are in opposite directions?
Folks are busy and there are so many draws on our time, life even – outside of PRT 🙂 , that we need the symptoms to jump out of the screen at us then we may go looking for the source of the symptoms (the problem).
If you have done above and I am still missing it then apologies.
What is the screen shot attached (copied from your original post) supposed to show / tell us? There is no trade running at all at time of the screen shot indicated by the red arrow?
11/28/2018 at 11:07 AM #85903According to the first picture, and if I have understood it clearly, the BUY and SELLSHORT are not happening on the same candlestick but one later? IMO, it is a problem of custom trading hours. Do you have or not weekend data displayed? If not, you should.
What happen if you are not using custom trading hours at all, but with the real market time?
11/28/2018 at 7:27 PM #85935Are you making it as easy as you possibly can for somebody to see at a glance what the symptoms of your problem are?
For example, why don’t you show 2 screenshots side by side with arrows pointing to the 2 trade positions that are in opposite directions?
Folks are busy and there are so many draws on our time, life even – outside of PRT
, that we need the symptoms to jump out of the screen at us then we may go looking for the source of the symptoms (the problem).
If you have done above and I am still missing it then apologies.
What is the screen shot attached (copied from your original post) supposed to show / tell us? There is no trade running at all at time of the screen shot indicated by the red arrow?
it shows that its that strategy im running, showing im not backtesting another strategy and another running on auto..
11/28/2018 at 7:43 PM #85936Nicolas wrote:
According to the first picture, and if I have understood it clearly, the BUY and SELLSHORT are not happening on the same candlestick but one later? IMO, it is a problem of custom trading hours. Do you have or not weekend data displayed? If not, you should.
What happen if you are not using custom trading hours at all, but with the real market time?
ill try to make it more clearly.
- The strategy defines open at 09, if price moves x points ABOVE open its a long, if y points DOWN from open its a short.
- When i backtest the strategy on pic 1. the orange arrow shows a SHORT, price went down y points from open. BUT, on live trading (auto) it took a LONG (the green arrow)
- Look at pic 2, ive tried custom trading options and no custom, still same results. Often the backtest and the auto goes in opposite direction.
- Pic 3 shows the auto is on the same timezon as settings. And custom hours at set in the strategy coding and not on PRT.
11/29/2018 at 9:06 AM #85973 -
AuthorPosts
Find exclusive trading pro-tools on