Coding for first pullback after price crossed MA50
06/11/2019 at 4:50 PM #10044106/11/2019 at 6:47 PM #10045006/11/2019 at 10:30 PM #10046506/12/2019 at 12:12 PM #100487
RiaanvN you will need to state a % closeness to MA50 (after retrace) for your entry condition.
Also I guess an exit condition would be if Close carries on through the MA50 … as it did on the last retrace / black MA50?06/13/2019 at 9:24 AM #100524
I would appreciated coding help for following criterias to be met.
- SMA50 upward sloping for the past 10 bars.
- SMA50 was downward sloping for at least 10 bars, 50 bars ago. (Range thus between  and .)
- Highest pivot low (swing low) for past 50 bars.
Thanks. Hope to hear from you soon.06/13/2019 at 9:50 AM #100525
I’ll leave the coding to @alexf so much better than me! (I struggle with my own coding! 🙂 )
I was only getting you to specify when exactly the entry trigger should occur when I asked … < % closeness to MA50.
I doubt you would want a specific entry point, e.g. MA50 + 5 points or = MA50 as it might not get to that point and then turn around zoom upwards while waving goodbye to you waiting there to enter … just like you predicted but you didn’t pull the trigger soon enough!? 🙂06/13/2019 at 12:58 PM #10054306/13/2019 at 1:07 PM #100544
Yea thats the hard part of coding those types of systems. Price might cross over 50MA 3 candles ago and retrace, or 10 candles or 50 candles then retrace.
You need to define that price
- WAS under ma50
- WAS “high” above ma50
- is currently not very high above ma50/retracing back to ma50, without it crossing under it(?)
edit: just a thought: multiple MA’s?06/13/2019 at 11:36 PM #100602
This is very basic:MA crossing after previous crossing & pullback1234567891011121314DEFPARAM CumulateOrders = falseMinLookBack = 2 //2 crossing must have occured at least these bars before PullBackMaxLookBack = 17 //17 crossing must have occured at most these bars before PullBackMA50 = average[50,1](close)//50,1x = close crosses over ma50IF x OR (close > MA50 AND low < MA50) THEN //when a pullback occurs...IF summation[MinLookBack](x) = 0 THENIF summation[MaxLookBack](x[MinLookBack + 1]) AND Not OnMarket AND close > open THENBUY 1 CONTRACT AT MARKETSET STOP pLOSS 50 //50SET TARGET pPROFIT 300 //300ENDIFENDIFENDIF
When it detects a crossover it is interpreted as a crossover due to pullback if there has been a previous crossover AT LEAST min candles before and AT MOST max candles before.06/14/2019 at 3:32 PM #10067406/15/2019 at 11:18 AM #10071806/15/2019 at 11:26 AM #10071906/15/2019 at 12:20 PM #10072506/15/2019 at 12:41 PM #10073106/15/2019 at 12:49 PM #100732
Good results on 10k bars on 1 min TF! Spread = 4
Optimise weekly and / or when Gain / Loss ratio drops much below 2.
The variable settings I chose are well down from the top Gain and are out of sight on attached. Variable name is Line No (or should be!?).
I’ll set it going on Demo Fwd Test on Monday.
Roberto any chance you could do the same on the Short side please pretty please? Then the whole code will be yours!
You must be logged in to access attached files.