Youtube FX Scalping Strategy
Forums › ProRealTime English forum › ProOrder support › Youtube FX Scalping Strategy
- This topic has 12 replies, 3 voices, and was last updated 5 years ago by
nfulcher.
-
-
08/19/2019 at 7:34 PM #105089
I’m fairly new to the site and after discovering this FX Scalping strategy on Youtube I though I’d have a crack at coding it on PRC.
It uses a slower time-frame (2 hour) to identify a trend (for a few bars) and then enters long or short positions on the default (5 minute ) time-frame once the candlestick pulls back into the quickest MA. It then tightens the trailing stop once a certain profit level is reached and rides the trend until the trailing stop is activated.
The backtests I can do in demo mode (on GBP/USD) do not show fantastic results; the best I can get is 60% winning trades (out of only 5 trades) giving 4% gain.
Either my coding isn’t on point or the strategy is not as good as I’d hoped.
If anyone can help review it and run an extended backtest it would be very much appreciated.
FX Scalping Strategy123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165defparam cumulateorders = false// My VariablesTradeSize = 10 // £ per pointOrderDist = 3 // Set Order Distance in PipsMySL = 30 // Set Stop LossMyBars = 4 // No of candles to average to calc Entry PointEMA1 = 10 // Fast MAEMA3 = 35 // Slow MAk = 4 // No of bars to check EMA diverging//trailing stop functiontrailingstart = 30 //trailing will start @trailinstart points profittrailingstep = 10 //trailing step to move the "stoploss"//declare the conditions on the Wider Timeframe//************* Start of Wider Time frame *******************************timeframe(2h, updateonclose)h1EMA1 = ExponentialAverage[EMA1](close)// h1EMA2 = ExponentialAverage[13](close) // not used in Wider TFh1EMA3 = ExponentialAverage[EMA3](close)// Set variables to 0ly = 0sy = 0ld=0sd=0// MA Divergence checkld = h1ema1 - h1ema3 //EMAs diverging on uptrendsd = h1ema3 - h1ema1 //EMAs diverging on downtrend// checks last n bars for condition Bull or Bear Trend// are EMAs in correct orientation for last 3 bars??For t = 0 to k Doif h1ema1[t]>h1ema3[t] and close > h1ema1[t] thenly = ly + 1 // increment uptrend counterelsif h1ema1[t]<h1ema3[t] and close < h1ema1[t] thensy = sy + 1 // increment downtrend counterendifnext//If not onmarket thenBullTrend = 0BearTrend = 0// Check if the EMAs are diverging = spreading further apart?if ly=(k+1) and ld > ld[1] and ld[1] > ld[2] thenBullTrend = 1elsif sy = (k+1) and sd > sd[1] and sd[1] > sd[2] thenBearTrend = 1endif//************** End of Wider Timeframe ******************************timeframe(default)// Set variables to 0lz = 0sz = 0ldd=0sdd=0//orders management on the default timeframe// set markers to zeroIf not onmarket thenLongCond = 0LongStop = 0ShortCond = 0ShortStop = 0endif// Define default timezone EMAs for order triggerdfEMA1 = ExponentialAverage[10](close)dfEMA2 = ExponentialAverage[17](close)dfEMA3 = ExponentialAverage[25](close)ldd = dfema1 - dfema2sdd = dfema2 - dfema1// checks EMAs for relative position at last w bars and confirms low pulls back to touch fastest EMA but doesnt pull back onto middle EMAFor w = 1 to k Doif dfema1[w] > dfema2[w] and dfema2[w] > dfema3[w] and low[w] > dfema1[w] and low < dfema1 and low > dfema2 thenlz = lz + 1elsif dfema1[w]<dfema2[w] and dfema2[w] < dfema3[w] and high[w] < dfema1[w] and high > dfema1 and high < dfema2 thensz = sz + 1endifnext// Set long and short markers if conditions are trueif lz=k and ldd > ldd[1] and ldd[1] > ldd[2] thenLongCond = 1elsif sz =k and sdd > sdd[1] and sdd[1] > sdd[2] thenShortCond = 1endif// Set Price levels at which to enter trades = current bar plus order distanceLongStop = highest[MyBars](high) + OrderDistShortStop = Lowest[MyBars](low) - OrderDist// Conditions to enter positionsif LongCond and BullTrend thenBUY TradeSize Perpoint at LongStop STOPSET STOP PLOSS MySLendifif ShortCond and BearTrend thenSellshort TradeSize Perpoint at ShortStop STOPSET STOP PLOSS MySLendif// Conditions to adjust trailing stop and close positions//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//************************************************************************// Graph Variables// On Price Chart//graphonprice newSL coloured (255,0,0,255) AS "newSL"//graphonprice LongStop coloured (0,0,255,255) AS "LongStop"//graphonprice ShortStop coloured (0,0,255,255) AS "ShortStop"//graphonprice tradeprice coloured (0,0,0,255) AS "TradePrice"// Position Indicators//graph LongCond coloured (255,0,0,255) AS "LongCond"//graph ShortCond coloured (255,0,0,255) AS "ShortCond"//graph BullTrend coloured (0,0,255,255) AS "BullTrend"//graph BearTrend coloured (255,0,0,255) AS "BearTrend"//08/19/2019 at 8:09 PM #10509308/20/2019 at 1:26 PM #10511308/22/2019 at 4:36 PM #10531608/22/2019 at 10:37 PM #105345I tried to test on a longer period, but I didn’t get any orders. I still don’t know why.. looking for an explanation
That’s very strange, I have just tried to run backtests on 100k bars and I’m also getting no trades at all. This was working fine a few days ago???
08/23/2019 at 11:06 AM #105371This looks very promising!
A quick optimise and I got below, I’ll work on it more, but in view of your comments above – re no trades – I thought I’d add results now. Spread = 4. Be good to reduce value of losing trades somehow?
Thank you for your sharing your hard work @nfulcher
EDIT / PS
Just realised that lot size = 10 so dd not too scary if lot size = 1 ! 🙂
1234567TradeSize = 10 // £ per pointOrderDist = 3 // Set Order Distance in PipsMySL = A8 // Set Stop LossMyBars = 4 // No of candles to average to calc Entry PointEMA1 = A10 // Fast MAEMA3 = A11 // Slow MAk = 4 // No of bars to check EMA diverging08/23/2019 at 2:01 PM #105387Thanks, Grahal, pretty good results on the 5min DJI – and yes I need to reduce the Trading Size down a bit :-).
Can you please explain the alphanumeric values you’ve used for the variables below (A8, A10 and A11)? I was under the impression these needed to be numeric values.
1234MySL = A8 // Set Stop LossMyBars = 4 // No of candles to average to calc Entry PointEMA1 = A10 // Fast MAEMA3 = A11 // Slow MA08/23/2019 at 3:09 PM #105398please explain the alphanumeric values
Yeah I use the line numbers as the name of the variable.
The values are shown above the equity curve, so for A8 I chose 80 from the Optimiser, A10 – 12 and A11 – 20
1 user thanked author for this post.
08/23/2019 at 3:34 PM #10540108/25/2019 at 12:24 PM #105513Interesting results Grahal,I’ll set this running on my IG demo account.
Is it possible to Backtest with a variable to represent the wider timeframe which sets the trigger – it might be interesting to test whether a 2H, 1H, 4H or daily trigger gives the best signal.
Alos, and maybe this is a separate post but can you advise, are there any good resources on the forum that explain how best to code for the different market times? I’m thinking if I have a promising strategy and want to try it with different market types (Indices, FX, etc) is there an elegant way to insert code blocks to manage the different trading times, time zones etc?
Many thanks.
08/25/2019 at 4:01 PM #105520I stand to be corrected, but in short the answers to your 2 questions are … 🙂
- No
- No
What I do is to flash through various Timeframes and a few Markets doing a backtest on max 10k bars (for speed of bt) and if a half decent equity curve shows itself then I dig deeper with appropriate range of values of values for the TF chosen. By appropriate I mean, for example, TP and SL need to be larger values for 1 hour than 1 min etc.
PS
I’ve set that v1 .itf going on demo also … we may both get virtual money rich together! 🙂
1 user thanked author for this post.
08/25/2019 at 4:15 PM #105522is there an elegant way to insert code blocks to manage the different trading times, time zones etc?
I misread your question, sorry,
I’m sure some of the Wizards on here could do something along those lines, but you would have to manually un-comment the respective block of code to match your chosen Market.
1 user thanked author for this post.
08/25/2019 at 11:30 PM #105537I stand to be corrected, but in short the answers to your 2 questions are …
- No
- No
What I do is to flash through various Timeframes and a few Markets doing a backtest on max 10k bars (for speed of bt) and if a half decent equity curve shows itself then I dig deeper with appropriate range of values of values for the TF chosen. By appropriate I mean, for example, TP and SL need to be larger values for 1 hour than 1 min etc.
Thanks – makes sense.
PS
I’ve set that v1 .itf going on demo also … we may both get virtual money rich together!
Let’s hope so!
-
AuthorPosts
Find exclusive trading pro-tools on