Dax Trend following, h2 Time zone:uk
Forums › ProRealTime English forum › ProOrder support › Dax Trend following, h2 Time zone:uk
- This topic has 11 replies, 6 voices, and was last updated 4 years ago by nonetheless.
-
-
01/14/2019 at 11:29 AM #884711234567891011121314151617181920defparam cumulateorders = falsen=2soglia = 0.02timestart = 90000timeend = 180000profitti = 275perdite = 350timeok = time>=timestart and time<=timeendc = (sin(atan((close-open[n])/open[n]*100/n)))if c crosses over soglia and timeok thenbuy 1 contract at marketendifif c crosses under -soglia and timeok thensellshort 1 contract at marketendifset target pprofit profittiset stop ploss perdite01/14/2019 at 2:18 PM #8856701/14/2019 at 2:27 PM #8857101/15/2019 at 8:55 AM #8865001/16/2019 at 10:55 AM #8875601/16/2019 at 10:58 AM #88757
The first
1234567891011121314151617181920defparam cumulateorders = falsen=2soglia = 0.02timestart = 90000timeend = 180000profitti = 275perdite = 350timeok = time>=timestart and time<=timeendc = (sin(atan((close–open[n])/open[n]*100/n)))if c crosses over soglia and timeok thenbuy 1 contract at marketendifif c crosses under –soglia and timeok thensellshort 1 contract at marketendifset target pprofit profittiset stop ploss perditeis optimized over the whole set of data.
the second post shows walk forward 75/25
Hope this answer your question
Regards
01/17/2019 at 1:31 PM #88923Strategy added into the library: DAX Trend following: 2-hours timeframe
1 user thanked author for this post.
01/17/2019 at 1:36 PM #8892601/20/2019 at 4:49 PM #89167Ciao, i had very different result with 200k bars, but anyway i changed something in the code.
i have 2 questions
in this function1c = (sin(atan((close–open[n])/open[n]*100/n)))i never seen the command SIN AND ATAN what are they? and how you found them? i the function search of PRT they aren’t presents. Thank you.
This is my version of your code, hoping could help.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100defparam cumulateorders = false//1/TRAILING STOP//////////////////////////////////////////////////////once trailinstop= 1 //1 on - 0 offtrailingstart = 100 //trailing will start @trailinstart points profittrailingstep = 60 //trailing step to move the "stoploss"///2 BREAKEAVEN///////////once breakeaven = 1 //1 on - 0 offstartBreakeven = 50 //how much pips/points in gain to activate the breakeven function?PointsToKeep = 30 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)n=2soglia = 0.01sogliashort=-0.06timestart = 90000timeend = 180000profitti = 165entratalong=0entratashort=0timeok = time>=timestart and time<=timeendc = ((sin(atan((close-open[n])/open[n]*100/n)))*100)+closec2 = (sin(atan((close-open[n])/open[n]*100/n)))graphonprice cif c>close and c2 > soglia and timeok thenentratalong=high+1*pipsizesl = (entratalong - low) / pipsizebuy 1 contract at entratalong stop//marketentratalong=0set target pprofit profittiset stop ploss sl+10endifif c<close and c2<sogliashort and timeok thenentratashort=low-1*pipsizesl = (high - entratashort) * pipsizesellshort 1 contract at entratashort stopentratashort=0set target pprofit profittiset stop ploss sl+10endif///1/////////////////////////////////////////////////reset the breakevenLevel when no trade are on marketIF NOT ONMARKET THENbreakevenLevel=0ENDIF//2//////////////////////////////test if the price have moved favourably of "startBreakeven" points alreadyif breakeaven>0 thenIF onmarket AND close-tradeprice(1)>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIFendif//************************************************************************//trailing stop functionif trailinstop>0 then//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIFendif01/20/2019 at 5:06 PM #8917101/21/2019 at 3:39 PM #8925112/22/2019 at 11:22 PM #115397Ciao Francesco, I have added a trailing stop to your code which seems to help but I’m unclear about the WFE. See the screen shots below, does this look over-optimized?
This is my version:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859defparam cumulateorders = falsen=2soglia = 0.02timestart = 90000timeend = 180000profitti = 280perdite = 340timeok = time>=timestart and time<=timeendc = (sin(atan((close-open[n])/open[n]*100/n)))if c crosses over soglia and timeok thenbuy 1 contract at marketendifif c crosses under -soglia and timeok thensellshort 1 contract at marketendifset target pprofit profittiset stop ploss perdite//trailing stop functiontrailingstart = 57 //trailing will start @trailinstart points profittrailingstep = 1 //trailing step to move the "stoploss"//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF -
AuthorPosts
Find exclusive trading pro-tools on