Hi guys,
I would appreciate some assistance. My favorite trade setup is pulback to MA50 after price crossed MA50 and MA50 is sloping up. Thus an established new trend.
Any ideas how to code this?
Thanks!
Could you post some images to clarify?
Hi Alex, see attached example of retrace.
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?
Hello Grahal,
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 [60] and [50].)
- Highest pivot low (swing low) for past 50 bars.
Thanks. Hope to hear from you soon.
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!? 🙂
The issue is I don’t see a clear definition of retracement.
In the picture posted it is clear to human eyes, but an algo need some more specific rules… Like “bitening” of Ma or a new lowest after x bars f. e.
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?
This is very basic:
DEFPARAM CumulateOrders = false
MinLookBack = 2 //2 crossing must have occured at least these bars before PullBack
MaxLookBack = 17 //17 crossing must have occured at most these bars before PullBack
MA50 = average[50,1](close)//50,1
x = close crosses over ma50
IF x OR (close > MA50 AND low < MA50) THEN //when a pullback occurs...
IF summation[MinLookBack](x[1]) = 0 THEN
IF summation[MaxLookBack](x[MinLookBack + 1]) AND Not OnMarket AND close > open THEN
BUY 1 CONTRACT AT MARKET
SET STOP pLOSS 50 //50
SET TARGET pPROFIT 300 //300
ENDIF
ENDIF
ENDIF
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.
Thanks Roberto! I’m definitely going to try this.
Pretty expressive GraHal!
@RobertoGozzi … You knew I was just making some humour for a Saturday morning, right??
Perhaps I should have added … You ain’t seen my basic! 🙂
I knew that, I was on the same line of humor.
I wrote BASIC because it lacks trailing stop/break even, money/position management and other amenities!
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!