Forex Engulfing Strategy
Forums › ProRealTime English forum › ProOrder support › Forex Engulfing Strategy
- This topic has 22 replies, 6 voices, and was last updated 7 years ago by victormork.
-
-
01/24/2017 at 8:56 PM #22362
Hi There
I am trying to implement a Forex Engulfing strategy that I use in my live trading. I would like to create a backtest for that strategy.
The strategy is simple at structure/ support and resistance points look for a engulfing signal the enter long or short on the open of next candle.
The strategy involves drawing in your own structure points.
Looking at he following post the Murray Math Levels Coincide exactly with these structure points.
https://www.prorealcode.com/prorealtime-indicators/murray-math-levels/
How do you implement Custom indicators in your back-testing strategies
The code will work something like this I just need to know how to implement the custom indicator then I can work out the formula for the buy and sell levels
123456789101112131415161718192021222324252627282930// timeframe: h1// instrument: FX// pairs: EURUSD//DEFPARAM CumulateOrders = FALSE//Need to to implement Muray math levelsBullishEngulfing= OPEN[1] > CLOSE[1] AND CLOSE > OPEN AND CLOSE[1] >= OPEN AND CLOSE >= OPEN[1]bearishengulfing = CLOSE[1] > OPEN[1] AND OPEN > CLOSE AND OPEN[1] >= CLOSE AND OPEN >= CLOSE[1]darkcloudcover = CLOSE[1] < OPEN[1] AND OPEN < CLOSE[1] AND CLOSE > OPEN[1]piercing = CLOSE[1]<OPEN[1] AND OPEN< CLOSE[1] AND CLOSE>(CLOSE[1]+(OPEN[1]-CLOSE[1])/2) AND CLOSE < OPEN[1]MurrayBuy = Low < Murray[sup] and Low > Murray[sup]IF MurrayBuy and (BullishEngulfing or piercing) THENBUY 2 CONTRACT AT MARKETSET STOP PLOSS 10ENDIFMurraySell = High > Murray[res1] and high < Murray[res2]IF MurraySell and (bearishengulfing or darkcloudcover) THENSELLSHORT 2 CONTRACT AT MARKETSET STOP PLOSS 10ENDIFI have attached images of the ideal sell and buy points.
The horizontal lines that I have drawn in are the manual structure points that I added.
Thanks
01/25/2017 at 5:52 PM #22460Post your indicator as well, easier that way.
01/25/2017 at 8:07 PM #22480You can implement custom indicators with the CALL instruction.
Even if it’s always a better idea to copy/paste (recode) the whole indicator into ProBacktest, use of CALL can save time while development process.
04/26/2017 at 3:30 PM #3351904/26/2017 at 3:37 PM #33521Hi Grahal
I have sort of put this on the backburner.
Its exactly how I trade forex manually. But I normally look to see if the the candle is near a major support or resistance zone and then look for a engulfing candle.
I am trying to work on something that adds the daily support and resistance lines then trade it on the hour chart.
The murray math levels move according to your timeframe which is not ideal.
04/26/2017 at 3:55 PM #33522Here are some of my videos of how this strategy works
Engulfing strategy
Price action drawing support and resistance lines.
04/27/2017 at 8:57 AM #3362904/27/2017 at 9:24 AM #33633Yes I agree Stanton .. that is what we need! Seems so basic / daft not to be able to!
Maybe @Nicolas may have a few ideas when he sees your question above?
GraHal
PS I put Nicolas as a hyperlink in case he has a method of doing a pull where he has been hyperlinked! Doubt it, but a good idea to try and get him here quick! 🙂04/27/2017 at 12:44 PM #33673Hi guys,
Just saw this. How are you getting on with it? I think the general premise might have legs but you’ll need a few entry / exit filters to make it stable and usable in the long run. On its own it will just spin its wheels (but that’s actually a good thing which is why I say it probably has legs).
Here is a quick a dirty solution for you (long only – let’s start just on one side). I did a quick optimization on EUR/USD M30. It’s super rough and probably a bit curve fitted so keep that in mind. Nevertheless the parts are there for you to build on. You can have a play now with various some filters and rules and share results if you like. I might come back to this again if I have some time.
All the best,
M
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687// timeframe: M30// instrument: FX// pairs: EUR_USDDEFPARAM CumulateOrders = FALSE// period = 32 //64// Murray Indicatoronce Top = undefinedonce Btm = undefinedonce MP = undefinedonce h5 = undefinedonce h4 = undefinedonce h3 = undefinedonce h2 = undefinedonce h1 = undefinedonce l1 = undefinedonce l2 = undefinedonce l3 = undefinedonce l4 = undefinedonce l5 = undefined//once cc = undefinedmData = close // open / low / typical etcif barIndex >= period thenh5 = h4 + ( Top - Btm )/ 8h4 = Top + ( Top - Btm )/ 8Top = highest[period](mData)h3 = Top - ( Top - Btm )/8h2 = h3 - ( Top - Btm )/8h1 = h2 - ( Top - Btm )/8MP = h1 - ( Top - Btm )/8l1 = MP - ( Top - Btm )/8l2 = l1 - ( Top - Btm )/8l3 = l2 - ( Top - Btm )/8Btm = lowest[period](mData)l4 = Btm - ( Top - Btm )/8l5 = l4 - ( Top - Btm )/8//cc = customcloseendif// -- candle pattern logic --bullishEngulfing = OPEN[1] > CLOSE[1] AND CLOSE > OPEN AND CLOSE[1] >= OPEN AND CLOSE >= OPEN[1]bearishEngulfing = CLOSE[1] > OPEN[1] AND OPEN > CLOSE AND OPEN[1] >= CLOSE AND OPEN >= CLOSE[1]darkcloudcover = CLOSE[1] < OPEN[1] AND OPEN < CLOSE[1] AND CLOSE > OPEN[1]piercing = CLOSE[1]<OPEN[1] AND OPEN< CLOSE[1] AND CLOSE>(CLOSE[1]+(OPEN[1]-CLOSE[1])/2) AND CLOSE < OPEN[1]//MA = average[200, 1](Close)MurrayBuy = low < L1 and low > L2MurraySell = high > H1 and high < H2// -- long entry rules --bc1 = not longOnmarket and murrayBuybc1 = bc1 and (BullishEngulfing or piercing)//bc1 = bc1 and MA > MA[2]// -- short entry rulessc1 = not shortOnMarket and murraySellsc1 = sc1 and (bearishengulfing or darkcloudcover)// -- long exit rules --le1 = longOnMarketle1 = (le1 and bearishEngulfing ) or (le1 and darkCloudCover)le1 = le1 or sc1if bc1 thenBUY 2 CONTRACT AT MARKETSET STOP PLOSS 10set target pProfit (MP-close)*pipsizeENDIFif le1 thensell at marketendif// just looking at long for now//IF MurraySell and (bearishengulfing or darkcloudcover) THEN//SELLSHORT 2 CONTRACT AT MARKET//SET STOP PLOSS 10//ENDIF// ignore (just so the interpreter doesn't crap out)if l3 or h4 or l5 or h5 then// ignoreendif04/27/2017 at 5:55 PM #33711Thanks for that Maz very nice code.
I have tested with the Murray math levels but its not exactly what I have looking for.
I have attached 2 images the first is the daily chart. I have draw horizontal lines at the areas where the price has been tested more than 2 times.
When you switch to the hourly chart image 2 those lines of support and resistance still hold up.I am looking for code that that draws horizontal lines at places where the price either was rejected at the support or resistance more than 2 times.
04/27/2017 at 6:54 PM #33727I am looking for code that that draws horizontal lines at places where the price either was rejected at the support or resistance more than 2 times.
This indicator should help: https://www.prorealcode.com/topic/swing-lines-indicator/
But of course, these levels are not stored anywhere since we do not have arrays to store them 🙁 sadly ..
1 user thanked author for this post.
04/27/2017 at 7:54 PM #33756Thanks Nicolas will check it out.
Working on this guys.
Would be great to get some input @grahal @Maz look at this on hour time frame.
1234567891011121314151617181920212223242526272829303132333435margin = 10numberofrejections = 4FOR i = 1 TO 365 DOrescounter = 0supcounter = 0dayhigh = DHigh(i)daylow = DLow(i)resareatop = dayhigh + margin*pipsizeresareabot = dayhigh - margin*pipsizesuptop = daylow + margin*pipsizesupbot = daylow - margin*pipsizeFOR i = 2 TO 365 DOif DHigh(i) > resareabot and DHigh(i) < resareatop thenrescounter = rescounter + 1endifif DLow(i) < suptop and DLow(i) > supbot thensupcounter = supcounter + 1endifnextif rescounter > numberofrejections thenDRAWHLINE(dayhigh)coloured(255,0,0)endifif supcounter > numberofrejections thenDRAWHLINE(daylow)coloured(0, 255, 0)endifNEXTreturn1 user thanked author for this post.
04/27/2017 at 11:29 PM #3378804/28/2017 at 11:46 AM #33837I hope we can get this coded up into an Algo.
I’m looking at 3 different Algos that have taken Long positions for me Live in the last 30 mins or so (see attached) … all after a good run up, so unless the retrace is 23.60% and then onward and upward it leaves me working out the Elliott Waves and getting hot under the collar watching and waiting!
But see the 2 price rejections (red arrows on attached) followed by a breakout … if only there was an Algo that could track such market structure? Happens all the time, all timeframes, and loads on the low TFs … which is good for a quick in and out! 🙂
GraHal
04/28/2017 at 12:39 PM #33845 -
AuthorPosts
Find exclusive trading pro-tools on