first hit of a moving average
Forums › ProRealTime English forum › ProOrder support › first hit of a moving average
- This topic has 31 replies, 3 voices, and was last updated 6 years ago by
GraHal.
-
-
07/06/2018 at 8:31 AM #75423
If by ‘next bar’ you really mean the current bar that is being checked to see whether the order should be sent to market then the problem is that you are using DHIGH which is the daily high when you should be using HIGH which is the current bars high.
I can highly recommend reading everything in the documentation here to help with understanding PRT coding more fully:
07/06/2018 at 8:44 AM #75427Thank you Im currently reading those documents.
What I mean is. After the gap criteria has been meet. If price than crosses under the 50ma for the first time (a low will do). Than the next bar’s high must be higher than the 50ma. Than on the open of the following bar take the trade. So Im looking for confirmation the 50ma will hold as support. What Im trying to avoid is if prices just fall straight through the 50ma I dont want to take that trade.
Let me know if that clears it up? Cheers
07/06/2018 at 9:39 AM #7543407/06/2018 at 9:48 AM #7543707/06/2018 at 10:23 AM #75441123456789101112131415161718192021222324252627282930313233starttime = 000000startday = 1gapneeded = 20 * pipsizema20 = average[20](close)ma50 = average[50](close)ma200 = average[200](close)magap = ma20 - ma200if (opentime = starttime and opendayofweek = startday) or onmarket thencrossflag = 0gapflag = 0endifif ma20 crosses over ma200 thencrossflag = 1endifif crossflag and magap > gapneeded thengapflag = 1endifif ma20 crosses under ma200 thencrossflag = 0gapflag = 0endifif not onmarket and crossflag[1] and gapflag[1] and low[1] < ma50 and high > ma50 thenbuy 1 contract at marketendifSET STOP pLOSS 25SET TARGET pPROFIT 2507/06/2018 at 11:15 AM #7544907/09/2018 at 9:58 AM #75619I’ve got code below on Fwd Test on Demo, attached is equity curve for an open trade which was at > 55 gain and yet my Set TP = 30 didn’t trigger.
Anybody any ideas why TP not triggered (or do I need more coffee 🙂 )?
123456789101112131415161718192021222324252627282930313233343536373839//-------------------------------------------------------------------------// Main code : MA Hit DAX 5M v1.0//-------------------------------------------------------------------------//https://www.prorealcode.com/topic/first-hit-of-a-moving-average/page/2/DEFPARAM CUMULATEORDERS = Falsestarttime = 000000startday = 1gapneeded = 2 * pipsizema20 = average[20](close)ma50 = average[50](close)ma200 = average[200](close)magap = ma20 - ma200if (opentime = starttime and opendayofweek = startday) or onmarket thencrossflag = 0gapflag = 0endifif ma20 crosses over ma200 thencrossflag = 1endifif crossflag and magap > gapneeded thengapflag = 1endifif ma20 crosses under ma200 thencrossflag = 0gapflag = 0endifif not onmarket and crossflag[1] and gapflag[1] and low[1] < ma50 and high > ma50 thenbuy 1 contract at marketendifSET STOP pLOSS 25SET TARGET pPROFIT 3007/09/2018 at 10:34 AM #7562607/09/2018 at 10:39 AM #7562707/09/2018 at 10:51 AM #7562907/09/2018 at 11:17 AM #75633Don’t know if Technical Report went before the freeze up or not and of course there is no acknowledgment sent out!
I had to use Task Manager to close Platform!
Anyway the SAME trade has gone above gain of 30 AGAIN (I’m liking this strategy! 🙂 ) but the Set TP 30 has not triggered for the second time … well weird ???
07/09/2018 at 11:42 AM #7563507/09/2018 at 11:53 AM #7563807/09/2018 at 12:02 PM #75641FYI – depending on where you live (I live in Australia), don’t set the start time @ 000000
I had this system on real trading and it took the first candle at the open which was a wide range bar with a very wide spread.
In fact, I couldn’t even see the price trade at the level I was stopped out at the same time I entered? very strange.
In any case I changed the start time to 100000 to avoid the opening mess
07/09/2018 at 12:03 PM #75642 -
AuthorPosts
Find exclusive trading pro-tools on