NAS scalping strategy
Forums › ProRealTime English forum › ProOrder support › NAS scalping strategy
- This topic has 30 replies, 12 voices, and was last updated 3 years ago by nonetheless.
-
-
09/02/2021 at 12:35 PM #176659
Here’s a new algo I’ve had on forward testing for a while (US Tech 100), so far consistent with the BT results. It’s all on moving averages and more or less approximates what I do in manual trading, except where I normally work on a 1min chart, this drops down to 30sec to make up for the 1 candle delay at the entry.
FOR:
Very nice histogram, as good as it gets.
High number of trades in the BT (4 0r 5 per day)
Low drawdown
Spectacular ‘potential returns’ when MM is active (2nd pic – haha, dream on…🤣)
Against:
Very short BT, 17 months – assume it’s curve-fit to that period and would need regular reworking
Possibly over-optimized (???)
Stoploss is > Target profit, meaning that loss of worst trade is also > Gain of best trade – not good but unavoidable.
Very low gain per trade, easily eroded with slippage or at times of higher spread.
No WF, as I prefer to do out-of-sample testing in demo (closer to real trading conditions)
***Requires lengthy forward testing before going live***
As with most things in life – could be a winner, could crash and burn … who knows? Be sure to adjust the Tradetime for your time zone.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255// Definition of code parametersDEFPARAM CumulateOrders = false // Cumulating positions deactivatedDEFPARAM preloadbars = 10000//MONEY MANAGEMENT IIMM = 0 // = 0 for optimizationif MM = 0 thenpositionsize = 0.5ENDIFif MM thenMinSize = 0.5 // IG minimum position size allowedMaxSize = 2000 // IG tier 2 margin limitProfitAccrued = 0 // when restarting strategy, enter profit or loss to date in instrument currencyDD = 370 //MinSize drawdown in instrument currencyMultiplier = 3 //drawdown multiplierif ProfitAccrued + StrategyProfit >= DD*2 thenMultiplier = 2endifCapital = DD * MultiplierEquity = Capital + ProfitAccrued + StrategyProfitPositionSize = Max(MinSize, Equity * (MinSize/Capital))if positionsize > MaxSize thenpositionsize = MaxSizeendifPositionSize = Round(PositionSize*100)PositionSize = PositionSize/100ENDIFonce tradetype = 1 // [1] long/short [2]long [3]shortonce closeonreversal = 0DLS =(Date >= 20100314 and date <=20100328) or (Date >= 20101031 and date <=20101107) or (Date >= 20110313 and date <=20110327) or (Date >= 20111030 and date <=20111106) or (Date >= 20120311 and date <=20120325) or (Date >= 20121028 and date <=20121104) or (Date >= 20130310 and date <=20130331) or (Date >= 20131027 and date <=20131103) or (Date >= 20140309 and date <=20140330) or (Date >= 20141026 and date <=20141102) or (Date >= 20150308 and date <=20150329) or (Date >= 20151025 and date <=20151101) or (Date >= 20160313 and date <=20160327) or (Date >= 20161030 and date <=20161106) or (Date >= 20170312 and date <=20170326) or (Date >= 20171030 and date <=20171105) or (Date >= 20180311 and date <=20180325) or (Date >= 20181028 and date <=20181104) or (Date >= 20190310 and date <=20190331) or (Date >= 20191027 and date <=20191103) or (Date >= 20200308 and date <=20200329) or (Date >= 20201025 and date <=20201101) or (Date >= 20210314 and date <=20210328) or (Date >= 20211031 and date <=20211107) or (Date >= 20220313 and date <=20220327) or (Date >= 20221030 and date <=20221106) or (Date >= 20230312 and date <=20230326) or (Date >= 20231029 and date <=20231105) or (Date >= 20240310 and date <=20240331) or (Date >= 20241027 and date <=20241103)If DLS thenTradetime = time >=133000 and time <200000//UK timeelsif not DLS thenTradetime = time >=143000 and time <210000//UK timeendifTIMEFRAME(15 minutes)ma = average[a,t](typicalprice)cb1 = ma > ma[1]mb = average[p2,t2](typicalprice)cs1 = mb < mb[1]TIMEFRAME(5 minutes)mc = average[a3,t3](typicalprice)cb2 = (mc > ma)cb3 = mc > mc[1]md = average[a4,t4](typicalprice)cs2 = (md < mb)cs3 = md < md[1]TIMEFRAME(default)me = average[a5,t5](typicalprice)cb4 = me > me[1] and me[1] < me[2]mf = average[a6,t6](typicalprice)cs4 = mf < mf[1] and mf[1] > mf[2]CB = Tradetime and (cb1 or cb2) and cb3 and cb4CS = Tradetime and (cs1 or cs2) and cs3 and cs4// Conditions to enter long positionsif tradetype=1 or tradetype=2 thenIF not longonmarket and CB THENBUY positionsize CONTRACT AT MARKETSET STOP %LOSS slSET TARGET %PROFIT tpENDIFENDIFif tradetype=2 and longonmarket and closeonreversal and CS thensell at marketendif// Conditions to enter short positionsif tradetype=1 or tradetype=3 thenIF not shortonmarket and CS THENsellshort positionsize CONTRACT AT MARKETSET STOP %LOSS slsSET TARGET %PROFIT tpsENDIFENDIFif tradetype=3 and shortonmarket and closeonreversal and CB thenexitshort at marketendif//% Break even (high/low)once breakeven =1if breakeven thenbreakevenPC = be // longbreakevenPCS = bes // shortPointsToKeep = pkstartBreakeven = tradeprice(1)*(breakevenPC/100)startBreakevenS = tradeprice(1)*(breakevenPCS/100)//reset the breakevenLevel when no trade are on marketif breakeven>0 thenIF NOT ONMARKET THENbreakevenLevel=0ENDIF// --- BUY SIDE ---//test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND high-tradeprice(1)>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIF// --- end of BUY SIDE ---IF SHORTONMARKET AND tradeprice(1)-low>=startBreakevenS*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)-PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENEXITSHORT AT breakevenLevel STOPENDIFendifendif// trailing atr stoponce trailingstopATR = 1if trailingstopATR then//====================once tsincrements = tsi // set to 0 to ignore tsincrementsonce tsminatrdist = tsmonce tsatrperiod = tsa // ts atr parameteronce tsminstop = 4 // ts minimum stop distancetssensitivity = 2 // 1 = close 2 = High/Low 3 = Low/High 4 = typicalprice (not use once)//====================if barindex=tradeindex thentrailingstoplong = tsl // ts atr distancetrailingstopshort = tss // ts atr distanceelseif longonmarket thenif tsnewsl>0 thenif trailingstoplong>tsminatrdist thenif tsnewsl>tsnewsl[1] thentrailingstoplong=trailingstoplongelsetrailingstoplong=trailingstoplong-tsincrementsendifelsetrailingstoplong=tsminatrdistendifendifendifif shortonmarket thenif tsnewsl>0 thenif trailingstopshort>tsminatrdist thenif tsnewsl<tsnewsl[1] thentrailingstopshort=trailingstopshortelsetrailingstopshort=trailingstopshort-tsincrementsendifelsetrailingstopshort=tsminatrdistendifendifendifendiftsatr=averagetruerange[tsatrperiod]((close/10))/1000//tsatr=averagetruerange[tsatrperiod]((close/1)) // (forex)tgl=round(tsatr*trailingstoplong)tgs=round(tsatr*trailingstopshort)if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thentsmaxprice=0tsminprice=closetsnewsl=0mypositionpriceatr = 0endifpositioncountatr = abs(countofposition)if tsnewsl > 0 thenif positioncountatr > positioncountatr[1] thenif longonmarket thentsnewsl = max(tsnewsl,positionprice * tsnewsl / mypositionpriceatr)elsetsnewsl = min(tsnewsl,positionprice * tsnewsl / mypositionpriceatr)endifendifendifif tssensitivity=1 thentssensitivitylong=closetssensitivityshort=closeelsif tssensitivity=2 thentssensitivitylong=hightssensitivityshort=lowelsif tssensitivity=3 thentssensitivitylong=lowtssensitivityshort=highelsif tssensitivity=4 thentssensitivitylong=typicalpricetssensitivityshort=typicalpriceendifif longonmarket thentsmaxprice=max(tsmaxprice,tssensitivitylong)if tsmaxprice-positionprice>=tgl thenif tsmaxprice-positionprice>=tsminstop thentsnewsl=tsmaxprice-tglelsetsnewsl=tsmaxprice-tsminstopendifendifendifif shortonmarket thentsminprice=min(tsminprice,tssensitivityshort)if positionprice-tsminprice>=tgs thenif positionprice-tsminprice>=tsminstop thentsnewsl=tsminprice+tgselsetsnewsl=tsminprice+tsminstopendifendifendifif longonmarket thenif tsnewsl>0 thensell at tsnewsl stopendifif tsnewsl>0 thenif low crosses under tsnewsl thensell at market // when stop is rejectedendifendifendifif shortonmarket thenif tsnewsl>0 thenexitshort at tsnewsl stopendifif tsnewsl>0 thenif high crosses over tsnewsl thenexitshort at market // when stop is rejectedendifendifendifmypositionpriceatr = positionpriceendif//===================================RSIexit = 1 // in profitif RSIexit thenmyrsi=rsi[r](close)if myrsi<rl and barindex-tradeindex>1 and longonmarket and close>positionprice thensell at marketendifif myrsi>rs and barindex-tradeindex>1 and shortonmarket and close<positionprice thenexitshort at marketendifendifTotal of 12 users thanked author for this post. Here are last 10 listed.
09/02/2021 at 1:59 PM #17666609/02/2021 at 4:47 PM #17667509/02/2021 at 5:03 PM #176678Hi @nonetheless
Thanks for sharing this with us!
Do you have PRT version that is sponsored via prorealtime directly rather than the version IG provides? I need to move over to that version. I’m also curious about how it performs in 1minute compared to 30s.
09/02/2021 at 5:15 PM #17667909/02/2021 at 5:16 PM #176680Can that also be recoded to M1?
I haven’t tried. My guess is that it relies on getting an early entry as the MA changes direction. The margins are quite small (€2.55 per trade means an average gain of just 5 points) and could be wiped out by waiting another 30sec before opening the trade.
I’m going to be away for a couple of weeks but I’ll try it on 1 min when i get back.
1 user thanked author for this post.
09/02/2021 at 5:21 PM #176682Do you have PRT version that is sponsored via prorealtime
I have a PRT sponsored Premium account with IG. You have to open it through the PRT website. There’s no fee and you can do it even if you already have an IG account so it’s a no-brainer IMHO.
09/02/2021 at 5:29 PM #176683Thank you very much for sharing! A clean approach to trade entry. Very impressive 🙂
09/03/2021 at 7:43 AM #17670309/03/2021 at 8:00 AM #176708“Very short BT, 17 months”
Did you optimized it beginning at the first day and ended on last day?
The problem with the optimizations up to the present day is, that we don´t see how the algo is working in realtime. The problem with the optimizations up to the present day is, that we don’t see how the algo is working in realtime. I have so many algo´s working fine in backtest, and after starting it in realtime demo, it fails. The realtime results are much more better, if i finish the BT´s a few moths befor present day and let them run after end of BT.
So, can you pls stop optimizing of this algo as of 4/1/2021 and then backtest it from 5/1 to today?
09/03/2021 at 9:20 AM #176713If you do it like that you still don’t see how it works in realtime because BT conditions, whether in-sample or out-of-sample, are nothing like real trading (for reasons that have been discussed countless times). Better is to optimise on max data (esp if you’ve only got 17 months), then forward test in demo.
In my opinion, a backtest only tells you if something is worth putting on demo for a few months. Only then will you get an idea of how it works out of sample.
I did already say this in my original post.
09/03/2021 at 10:34 AM #176717So, can you pls stop optimizing of this algo as of 4/1/2021 and then backtest it from 5/1 to today?
If you do it like that you still don’t see how it works in realtime because BT conditions, whether in-sample or out-of-sample, are nothing like real trading
Trying to learn something …
When I read about the idea of VinzentVega, I actually thought it would be a good idea. Not that I would apply it for real, but I think it should work. Thus :
Backtest (literally) until a few months ago (e.g. April vs today’s September) and no bar further. 🙂
When done and optimized to your ideas, run a final backtest (not literally – it is just a final check) from the bar you stopped optimizing (April) until today (September). Let it further run in real time from there if you want. I personally see no difference in this final check done from April till today on one hand, and back in April starting a Paper run till today on the other. If there *is* a difference, then something is wrong with the approach in the backtest program vs what would be reality.
Of course one golden rule is in order : It is totally forbidden to optimize further after you saw the results of that final check (the run from April till today). And, if the final check tells you “FAIL” then just stop with that strategy. It would also be forbidden to optimize the first part (until April) so-called not looking at the final check, because inherently you will be doing this latter (optimize the first part so the last part looks better – DON’T).Is this wrong somewhere ?
Thanks !
Peter09/03/2021 at 10:52 AM #176721Is this wrong somewhere ?
Yes … we miss out on optimising for the market cycles / price action existing today, last week , last month etc.
Far better to leave an unoptimised period at the beginning of backtest (10k bars, 50k bars, whatever) and then run the optimised Algo over that OOS period. If Algo stays above zero / not go into deep loss (during the OOS period) then proceed to Forwrd Test / Paper Trade on Demo Account.
09/03/2021 at 11:11 AM #17672309/03/2021 at 11:25 AM #176725I personally see no difference in this final check done from April till today on one hand, and back in April starting a Paper run till today on the other. If there *is* a difference, then something is wrong with the approach in the backtest program vs what would be reality.
It’s easy to prove it. Take one algo, duplicate it, optimize it, based on the two backtest scenarios, and finally backtest it and compare the results. I ensure you, that there will be diffrences.
Far better to leave an unoptimised period at the beginning of backtest (10k bars, 50k bars, whatever) and then run the optimised Algo over that OOS period.
This is also a possibility. If you have enough backtest time (in higher timeframe) , then you can disregard one period BEFORE and one period AFTER in optimization. And than ckeck the results.
-
AuthorPosts
Find exclusive trading pro-tools on