1 Min Trading Strategy
Forums › ProRealTime English forum › ProOrder support › 1 Min Trading Strategy
- This topic has 219 replies, 29 voices, and was last updated 7 years ago by Leo.
-
-
07/13/2017 at 12:29 PM #40559
Good Day,
I have seen many people asking for a 1 min trading strategy so I decided to make one.
I personally don’t like HFT type strategies as the spread can really eat away at profits compared to a nice trend following strategy.
The strategy is based on candle formations, along with a Long/Near Moving Average Trend Check and a RSI[2] check.
The trigger is made by a Bullish (or Bearish) candle formation and if the MA and RSI checks are valid a position is opened in the direction of the trend.
Some candle patterns are counter intuitive and hence some should be commented out (this would require some testing).
It is currently configured for long only trades (although the code is included for short trades).
I don’t think it is exceptionally effective, but maybe someone here can make something worthwhile out of it.
Results on 1min for thr EUR/USD with spread set to 0.8:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324Defparam cumulateorders = falseIf longonmarket and close < positionprice and (barindex-tradeindex) > 650 ThenSell at marketElsIf shortonmarket and close > positionprice and (barindex-tradeindex) > 60 thenExitshort at marketEndIfbody=close-openabody=abs(body)if range>0 thenratio=abody/rangeelseratio=0endifmiddle=(open+close)/2bodytop=max(open, close)bodybottom=min(open, close)shadowtop=high-bodytopshadowbottom=bodybottom-lowlongcandle= (ratio>0.6)Bull = 0Bear = 0//Bullish SignalsMorningStar=(body[2]<0 and body>0 and longcandle[2] and open[1]<close[2] and open>close[1] and ratio[1]<0.3 and abody[1]<abody[2] and abody[1]<abody and low[1]<low and low[1]<low[2] and high[1]<open[2] and high[1]<close)if MorningStar thenBull = 1 //PositiveendifPiercingLine=(body[1]<0 and body>0 and longcandle[1] and longcandle and open<low[1] and close>middle[1] and close<open[1])if PiercingLine thenBull = 1 //NoneendifAbandonedBabyBottom=(body[2]<0 and body>0 and longcandle[2] and ratio[1]<0.3 and high[1]<low[2] and high[1]<low)if AbandonedBabyBottom thenBull = 1 //NoneendifThreeInsideUp=(body[2]<0 and body[1]>0 and body>0 and BullishHarami[1] and close>close[1])if ThreeInsideUp thenBull = 1 //PositiveendifThreeOutsideUp=(body[2]<0 and body[1]>0 and body>0 and BullishEngulfing[1] and close>close[1])if ThreeOutsideUp thenBull = 1 //PositiveendifThreeWhiteSoldiers=(body[2]>0 and body[1]>0 and body>0 and high[1]>high[2] and high>high[1] and close[1]>close[2] and close>close[1] and open[1]>open[2] and open[1]<close[2] and open>open[1] and open<close[1])if ThreeWhiteSoldiers then//Bull = 1 //Increase DrawdownendifConcealingBabySwallow=(body[3]<0 and body[2]<0 and body[1]<0 and body<0 and ratio[3]>0.8 and ratio[2]>0.8 and ratio>0.8 and open[1]<close[2] and high[1]>close[2] and shadowtop[1]>0.6*(abody[1]+shadowbottom[1]) and bodybottom<bodybottom[1] and bodytop>high[1])if ConcealingBabySwallow thenBull = 1 //NoneendifBullishHarami=(body[1]<0 and body>0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])if BullishHarami then//Bull = 1 //Negative ImpactendifHomingPigeon=(body[1]<0 and body<0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])if HomingPigeon thenBull = 1 //NoneendifBullishEngulfing=(body[1]<0 and body>0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)if BullishEngulfing thenBull = 1 //PositiveendifLastEngulfingBottom=(body[1]>0 and body<0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)if LastEngulfingBottom thenBull = 1 //NoneendifDragonflyDojiBottom=(body[1]<0 and longcandle[1] and low<low[1] and shadowbottom>3*abody and shadowtop<shadowbottom/3)if DragonflyDojiBottom thenBull = 1 //NoneendifGravestoneDojiBottom=(body[1]<0 and longcandle[1] and low<low[1] and shadowtop>3*abody and shadowbottom<shadowtop/3)if GravestoneDojiBottom thenBull = 1 //NoneendifDojiStarBottom=(body[1]<0 AND longcandle[1] AND low<low[1] AND open<close[1] AND ratio<0.3 AND range<0.3*range[1])if DojiStarBottom thenBull = 1 //NoneendifBullishHaramiCross=(body[1]<0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1] and ratio<0.3 and range<0.3*range[1])if BullishHaramiCross thenBull = 1 //NoneendifThreeStarsInTheSouth=(body[2]<0 and body[1]<0 and body<0 and shadowtop[2]<range[2]/4 and shadowbottom[2]>abody[2]/2 and low[1]>low[2] and high[1]<high[2] and abody[1]<abody[2] and shadowtop[1]<range[1]/4 and shadowbottom[1]>abody[1]/2 and low>low[1] and high<high[1] and abody<abody[1] and shadowtop<range/4 and shadowbottom<range/4)if ThreeStarsInTheSouth thenBull = 1 //NoneendifBullishBreakaway=(body[4]<0 and body[3]<0 and body>0 and open[3]<close[4] and close[2]<close[3] and close[1]<close[2] and longcandle and close<close[4] and close>open[3])if BullishBreakaway thenBull = 1 //NoneendifHammer=(body[1]<0 and longcandle[1] and low<low[1] and shadowbottom>2*abody and shadowtop<0.3*abody)if Hammer thenBull = 1 //NoneendifInvertedHammer=(body[1]<0 and longcandle[1] and low<low[1] and shadowtop>2*abody and shadowbottom<0.3*abody)if InvertedHammer thenBull = 1 //NoneendifRisingThreeMethods=(body[4]>0 and body[3]<0 and body[1]<0 and body>0 and longcandle[4] and longcandle and close[2]<close[3] and close[1]<close[2] and high[2]<high[3] and high[1]<high[2] and low[1]>low[4] and open>close[1] and close>high[4] and close>high[3] and close>high[2] and close>high[1])if RisingThreeMethods thenBull = 1 //NoneendifBullishThreeLineStrike=(body[3]>0 and body[2]>0 and body[1]>0 and body<0 and longcandle[3] and longcandle[2] and longcandle[1] and close[2]>close[3] and close[1]>close[2] and open>close[1] and close<open[3])if BullishThreeLineStrike thenBull = 1 //NoneendifBullishMatHold=(body[4]>0 and body[3]<0 and body[1]<0 and body>0 and longcandle[4] and close[3]>close[4] and close[2]<close[3] and close[1]<close[2] and high[2]<high[3] and high[1]<high[2] and low[1]>low[4] and open>close[1] and close>high[4] and close>high[3] and close>high[2] and close>high[1])if BullishMatHold thenBull = 1 //NoneendifBullSash=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>close[1] AND open<open[1] AND close>open[1] AND shadowtop<0.1*abody)if BullSash thenBull = 1 //PositiveendifBullSeparatingLine=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>=open[1] AND shadowtop<0.1*abody)if BullSeparatingLine thenBull = 1 //NoneendifBullishCounterAttack=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND close<=close[1])if BullishCounterAttack thenBull = 1 //NoneendifBullishKicking=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>=open[1] AND shadowtop=0 AND shadowbottom=0)if BullishKicking thenBull = 1 //Noneendif//Bearish SignalEveningStar=(body[2]>0 AND body<0 and longcandle[2] and open[1]>close[2] and open<close[1] and ratio[1]<0.3 and abody[1]<abody[2] and abody[1]<abody and high[1]>high and high[1]>high[2] and low[1]>open[2] and low[1]>close)if EveningStar thenBear = 1endifDarkCloudCover=(body[1]>0 and body<0 and longcandle[1] and longcandle and open>high[1] and close<middle[1] and close>open[1])if DarkCloudCover thenBear = 1endifAbandonedBabyTop=(body[2]>0 and body<0 and longcandle[2] and ratio[1]<0.3 and low[1]>high[2] and low[1]>high)if AbandonedBabyTop thenBear = 1endifThreeInsideDown=(body[2]>0 and body[1]<0 and body<0 and bearishharami[1] and close<close[1])if ThreeInsideDown thenBear = 1endifThreeOutsideDown=(body[2]>0 and body[1]<0 and body<0 and bearishengulfing[1] and close<close[1])if ThreeOutsideDown thenBear = 1endifThreeBlackCrows=(body[2]<0 and body[1]<0 and body<0 and longcandle[2] and longcandle[1] and longcandle and low[1]<low[2] and low<low[1] and close[1]<close[2] and close<close[1] and open[1]<open[2] and open[1]>close[2] and open<open[1] and open>close[1])if ThreeBlackCrows thenBear = 1endifUpsideGapTwoCrows=(body[2]>0 and body[1]<0 and body<0 and longcandle[2] and open[1]>close[2] and bodytop>bodytop[1] and bodybottom<bodybottom[1] and close>close[2])if UpsideGapTwoCrows thenBear = 1endifBearishHarami=(body[1]>0 and body<0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])if BearishHarami thenBear = 1endifDescendingHawk=(body[1]>0 and body>0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])if DescendingHawk thenBear = 1endifBearishEngulfing=(body[1]>0 and body<0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)if BearishEngulfing thenBear = 1endifLastEngulfingTop=(body[1]<0 and body>0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)if LastEngulfingTop thenBear = 1endifDragonflyDojiTop=(body[1]>0 and longcandle[1] and high>high[1] and shadowbottom>3*abody and shadowtop<shadowbottom/3)if DragonflyDojiTop thenBear = 1endifGravestoneDojiTop=(body[1]>0 and longcandle[1] and high>high[1] and shadowtop>3*abody and shadowbottom<shadowtop/3)if GravestoneDojiTop thenBear = 1endifDojiStarTop=(body[1]>0 AND longcandle[1] AND high>high[1] AND open>close[1] AND ratio<0.3 AND range<0.3*range[1])if DojiStarTop thenBear = 1endifBearishHaramiCross=(body[1]>0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1] and ratio<0.3 and range<0.3*range[1])if BearishHaramiCross thenBear = 1endifAdvanceBlock=(body[2]>0 and body[1]>0 and body>0 and high[2]<high[1] and high[1]<high and open[1]>bodybottom[2] and open[1]<bodytop[2] and open>bodybottom[1] and open<bodytop[1] and abody[1]<abody[2] and abody<abody[1])if AdvanceBlock thenBear = 1endifTwoCrows=(body[2]>0 and body[1]<0 and body<0 and longcandle[2] and open[1]>close[2] and close[1]>close[2] and open<bodytop[1] and open>bodybottom[1] and close<bodytop[2] and close>bodybottom[2])if TwoCrows thenBear = 1endifBearishBreakaway=(body[4]>0 and body[3]>0 and body<0 and open[3]>close[4] and close[2]>close[3] and close[1]>close[2] and longcandle and close>close[4] and close<open[3])if BearishBreakaway thenBear = 1endifShootingStar=(body[1]>0 and longcandle[1] and high>high[1] and shadowtop>2*abody and shadowbottom<0.3*abody)if ShootingStar thenBear = 1endifHangingMan=(body[1]>0 and longcandle[1] and high>high[1] and shadowbottom>2*abody and shadowtop<0.3*abody)if HangingMan thenBear = 1endifFallingThreeMethods=(body[4]<0 and body[3]>0 and body[1]>0 and body<0 and longcandle[4] and longcandle and close[2]>close[3] and close[1]>close[2] and low[2]>low[3] and low[1]>low[2] and high[1]<high[4] and open<close[1] and close<low[4] and close<low[3] and close<low[2] and close<low[1])if FallingThreeMethods thenBear = 1endifBearishThreeLineStrike=(body[3]<0 and body[2]<0 and body[1]<0 and body>0 and longcandle[3] and longcandle[2] and longcandle[1] and close[2]<close[3] and close[1]<close[2] and open<close[1] and close>open[3])if BearishThreeLineStrike thenBear = 1endifBearishMatHold=(body[4]<0 and body[3]>0 and body[1]>0 and body<0 and longcandle[4] and close[3]<close[4] and close[2]>close[3] and close[1]>close[2] and low[2]>low[3] and low[1]>low[2] and high[1]<high[4] and open<close[1] and close<low[4] and close<low[3] and close<low[2] and close<low[1])if BearishMatHold thenBear = 1endifBearSash=(body[1]>0 AND longcandle[1] AND body<0 AND longcandle AND open>open[1] AND open<close[1] AND close<open[1] AND shadowbottom<0.1*abody)if BearSash thenBear = 1endifBearSeparatingLine=(body[1]>0 AND longcandle[1] AND body<0 AND longcandle AND open<=open[1] AND shadowbottom<0.1*abody)if BearSeparatingLine thenBear = 1endifBearishCounterAttack=(body[1]>0 AND longcandle[1] AND body<0 AND longcandle AND close>=close[1])if BearishCounterAttack thenBear = 1endifBearishKicking=(body[1]>0 AND longcandle[1] AND body<0 AND longcandle AND open<=open[1] AND shadowtop=0 AND shadowbottom=0)if BearishKicking thenBear = 1endif//Entry/Exit Criteriapossize = 1NearMA = Average[7,2](close)If countofposition = 0 and Bull = 1 and NearMA[1] > NearMA[3] and RSI[2](close) > 75 and NearMA > Average[150,2](close) Then//If shortonmarket Then//Exitshort at market//EndIfBuy possize contract at marketEndIfIf countofposition = 0 and Bear = 1 and NearMA[1] < NearMA[3] and RSI[2](close) < 25 and NearMA < Average[150,2](close) Then//If longonmarket Then//Sell at market//EndIf//Sellshort possize contract at marketEndIfSet Target pProfit 8Set Stop pLoss 10007/14/2017 at 8:24 AM #40607hello !
Thank you for sharing !
Have you tested with WF ? Why not activate the sell ?
thanks !
07/14/2017 at 8:44 AM #40608I try to test it but I have the division by zero problem on this strategy 🙂
07/14/2017 at 9:41 AM #40614I checked the optimisation (good) and tried the SellShort (not great, but maybe we can improve?) and I’ve set it going Live … it’s okay I’ll watch it as soon as it triggers.
It would be useful and interesting if (somehow easily?) we could GRAPH which of the candle patterns has formed at Trade entry. I guess you’d need Bull 1, Bull2, Bull 3 … etc and then use DRAWTEXT? And then GRAPH Bull 1 OR Bull 2 … etc (if even allowed?). Naah not worth the effort, just a few thoughts anyway?
Many Thanks for your inspiration, time and effort and sharing with us all juanj
Regards
GraHalPS I’ll let you know if I get the divide by zero error TheAccountant.
1 user thanked author for this post.
07/14/2017 at 10:06 AM #40621this is the backtest with 200k :
07/14/2017 at 12:32 PM #40633As promised TheAccountant … above Bot (with no changes) triggered a Live Trade with NO divide by zero error.
1 user thanked author for this post.
07/14/2017 at 12:45 PM #40635I have been thinking about the whole idea of a 1 min (scalping type strategy) and the important factors to consider should be as follow:
- In Direction of Primary Trend i.e. Long above and Short below 100-250MA (Long MA)
- In Direction of Near Trend i.e Near MA pointing in direction of Trade
- Strong Momentum i.e. RSI and or Stachastic in Overbough/Oversold area
- Good Trigger i.e. Reliable Candle Stick Pattern
- Small Target (i.e. <= ATR)
Also worth pointing out would be to use a market with a small spread <= 0.8
I believe my strategy over complicates the above.
Instead of using a whole library of candle patterns lets identify 1 to 3 ‘reliable’ ones such as the recent Hammer-Negated pattern posted by Francesco.
Also lets use confluence of Momentum Indicators such as Stochastic and RSI to identify strong Momentum
And finally using ATR to identify a likely Target
I don’t have the time right now to try this but will look into it sometime this weekend.
07/14/2017 at 1:02 PM #40640Good and logical ideas juanj!
it would seem sensible to use those candle patterns that are statistically proven to be the most reliable in predicting market direction after the pattern formed.
I’ll find some links for above and post on here.
Cheers
GraHal07/14/2017 at 3:12 PM #40653Okay so I got distracted by the idea and ended up coding something in line with the above logic.
Code is for Long only but pretty sure we can adapt it to be bi-directional.
I really like the results and think we are onto something here! EUR/USD (spread 0.8):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109//Stategy: Scalping Candles//Market: EUR/USD//Timeframe: 1min//Spread: 0.8//Author: Juan Jacobs (Jd3gjacobs@gmail.com)Defparam cumulateorders = falseIf longonmarket and close < positionprice and (barindex-tradeindex) > 720 Then //Time Stop set to 12 hoursSell at marketEndIf//Candle Paramatersbody=close-openabody=abs(body)if range>0 thenratio=abody/rangeelseratio=0endifbodytop=max(open, close)bodybottom=min(open, close)shadowtop=high-bodytoplongcandle= (ratio>0.6)Bull = 0//Bullish SignalsBullishHarami=(body[1]<0 and body>0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])MorningStar=(body[2]<0 and body>0 and longcandle[2] and open[1]<close[2] and open>close[1] and ratio[1]<0.3 and abody[1]<abody[2] and abody[1]<abody and low[1]<low and low[1]<low[2] and high[1]<open[2] and high[1]<close)if MorningStar thenBull = 1 //PositiveendifThreeInsideUp=(body[2]<0 and body[1]>0 and body>0 and BullishHarami[1] and close>close[1])if ThreeInsideUp thenBull = 1 //PositiveendifThreeOutsideUp=(body[2]<0 and body[1]>0 and body>0 and BullishEngulfing[1] and close>close[1])if ThreeOutsideUp thenBull = 1 //PositiveendifBullishEngulfing=(body[1]<0 and body>0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)if BullishEngulfing thenBull = 1 //PositiveendifBullSash=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>close[1] AND open<open[1] AND close>open[1] AND shadowtop<0.1*abody)if BullSash thenBull = 1 //PositiveendifIf (high - low) = 0 Then //Prevents potential division by zeroHiLo = 1ElseHiLo = (high - low)EndIfHammerUp = min(open[1],close[1])>high[1]-(high[1]-low[1])/3HammerUpNeg= max(open,close)<min(open[1],close[1]) and abs(open-close)/HiLo>0.5 //Bullish Hammer Negated = Bearish (used for exit signal)HammerDown = max(open[1],close[1])<low[1]+(high[1]-low[1])/3HammerDownNeg = min(open,close)>max(open[1],close[1]) and abs(open-close)/HiLo>0.5 //Bearish Hammer Negated = Bullish (used for exit signal)If HammerUp and HammerUpNeg Then//Bull = 0ElsIf HammerDown and HammerDownNeg ThenBull = 1EndIfdojibull2 = open[2]<close[2] and abs(open[2]-close[2])/(high[2]-low[2])<0.6dojibull1 = open[1]<close[1] and abs(open[1]-close[1])/(high[1]-low[1])<0.6dojibear2 = open[2]>close[2] and abs(open[2]-close[2])/(high[2]-low[2])<0.6dojibear1 = open[1]>close[1] and abs(open[1]-close[1])/(high[1]-low[1])<0.6hammerup2 = min(open,close)>high-(high-low)/2 //and max(open,close) < min(open[1],close[1])hammerdown2 = max(open,close)<low+(high-low)/2 //and max(open,close)<min(open[1],close[1])//and timeokIf (dojibull2 and dojibull1) and hammerdown2 ThenBull = 1ElsIf (dojibear2 and dojibear1) and hammerup2 Then//Bull = 0EndIf//Entry/Exit Criteriapossize = 1ATR = AverageTrueRange[4](close)LongMA = Average[50,2](close)NearMA = Average[6,2](close)RSIChk = RSI[4](close) >= 80StoChk = Stochastic[14,3](close) >= 75If countofposition = 0 and Bull = 1 and close > LongMA and NearMA > LongMA and LongMA[1] > LongMA[20] and NearMA[1] > NearMA[3] and ATR[1] > ATR[2] and RSIChk and StoChk ThenBuy possize contract at marketEndIfSet Target $profit 125Set Stop $Loss 2501 user thanked author for this post.
07/14/2017 at 8:13 PM #40666It’s weird I do not have the same results at all ! It’s not bad but it’s different ! 🙂
I can test on 200k but it will be necessary that we have the same results on 100k first lol
07/14/2017 at 8:38 PM #40671Have you got 0.8 spread set (same as juanj) on the backtest engine?
Also I don’t think juanj has stated exactly what instrument he is testing on … CFD or spreadbet etc??
I couldn’t get same results as juanj either.
Let’s keep at it now we are gaining momentum? So many of these collaborative / improvement projects seem to fall over?
Thanks
GraHal07/14/2017 at 8:58 PM #40675Hi, I suspect it could have something to do with the stop/target being specified in $profit and $loss instead of Pprofit and Ploss. Perhaps we should standardize to points x*pipsize.
TP = x*pipsize
SL = TP*2
Set Target pProfit TP
Set Stop pLoss SL
For the record it is standard CFD.
07/14/2017 at 9:20 PM #40678“Have you got 0.8 spread set (same as juanj) on the backtest engine?”
yep 🙂 and Im on CFD too.
07/14/2017 at 10:32 PM #4068007/15/2017 at 5:55 AM #40692 -
AuthorPosts
Find exclusive trading pro-tools on