ProRealCode - Trading & Coding with ProRealTime™
If the prescribed method for WF is to trade Demo / Live using optimised values from the most recent backtested period (provided WF % is > 50%) then why do we bother backtesting for 100k bars or 200k bars?? 🙂
I run the dax version today (with tp8 sl50) and that is stopped twice for error division by zero.
It took 3 trades in real ( win 🙂 ) and it stopped again.
I do not see where the problem comes from 🙁
Think I know where the potential ‘divide by zero’ problem could lie:
dojibull2 = open[2]<close[2] and abs(open[2]-close[2])/(high[2]-low[2])<0.6
dojibull1 = open[1]<close[1] and abs(open[1]-close[1])/(high[1]-low[1])<0.6
dojibear2 = open[2]>close[2] and abs(open[2]-close[2])/(high[2]-low[2])<0.6
dojibear1 = open[1]>close[1] and abs(open[1]-close[1])/(high[1]-low[1])<0.6
Can fix by replacing the above block of code with this:
If high[2]-low[2] = 0 Then
HiLo2 = 1
Else
HiLo2 = high[2]-low[2]
EndIf
If high[1]-low[1] = 0 Then
HiLo1 = 1
Else
HiLo1 = high[1]-low[1]
EndIf
dojibull2 = open[2]<close[2] and abs(open[2]-close[2])/HiLo2<0.6
dojibull1 = open[1]<close[1] and abs(open[1]-close[1])/HiLo1<0.6
dojibear2 = open[2]>close[2] and abs(open[2]-close[2])/HiLo2<0.6
dojibear1 = open[1]>close[1] and abs(open[1]-close[1])/HiLo1<0.6
Here’s two possibilities on the link below … let us know which works please as I had this on another Strat a few days ago.
https://www.prorealcode.com/topic/trading-system-was-stopped-due-to-a-division-by-zero/
Thanks to Wing …
Usually, this problem is because you have a variable that you initiate as zero, or simply do not give a set value to at first. When you try to divide a number or another variable with this zero variable, an error is returned. So my first suggestion, look at all points in the system where you divide something, then make sure nothing is ever divided by zero.
But – thanks to Bin – solution was in fact …
Thanks for your advise, I fixed the problem, it caused by preloadbars issue, my previous setting is 150, its ok when change to 1000.
why do we bother backtesting for 100k bars or 200k bars??
If we have more history, we can do a lot more IS/OOS tests and be more confident on the robustness of the strategy and its ability to benefit from optimization.
Think I know where the potential ‘divide by zero’ problem could lie:
1234 dojibull2 = 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.6Can fix by replacing the above block of code with this:
123456789101112131415 If high[2]–low[2] = 0 ThenHiLo2 = 1ElseHiLo2 = high[2]–low[2]EndIfIf high[1]–low[1] = 0 ThenHiLo1 = 1ElseHiLo1 = high[1]–low[1]EndIfdojibull2 = open[2]<close[2] and abs(open[2]–close[2])/HiLo2<0.6dojibull1 = open[1]<close[1] and abs(open[1]–close[1])/HiLo1<0.6dojibear2 = open[2]>close[2] and abs(open[2]–close[2])/HiLo2<0.6dojibear1 = open[1]>close[1] and abs(open[1]–close[1])/HiLo1<0.6
thank you. But for the dax I use your version 1 of the code and there are not these parts of code.
Here is the code I use :
//Stategy: Scalping Candles
//Market: DAX
//Timeframe: 1min
//Spread: 1
//Author: Juan Jacobs (Jd3gjacobs@gmail.com)
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
noEntryBeforeTime = 090000
timeEnterBefore = time >= noEntryBeforeTime
noEntryAfterTime = 220000
timeEnterAfter = time < noEntryAfterTime
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
If longonmarket and close < positionprice and (barindex-tradeindex) > 650 Then
Sell at market
ElsIf shortonmarket and close > positionprice and (barindex-tradeindex) > 60 then
Exitshort at market
EndIf
body=close-open
abody=abs(body)
if range>0 then
ratio=abody/range
else
ratio=0
endif
middle=(open+close)/2
bodytop=max(open, close)
bodybottom=min(open, close)
shadowtop=high-bodytop
shadowbottom=bodybottom-low
longcandle= (ratio>0.6)
Bull = 0
Bear = 0
//Bullish Signals
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 then
Bull = 1 //Positive
endif
PiercingLine=(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 then
Bull = 1 //None
endif
AbandonedBabyBottom=(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 then
Bull = 1 //None
endif
ThreeInsideUp=(body[2]<0 and body[1]>0 and body>0 and BullishHarami[1] and close>close[1])
if ThreeInsideUp then
Bull = 1 //Positive
endif
ThreeOutsideUp=(body[2]<0 and body[1]>0 and body>0 and BullishEngulfing[1] and close>close[1])
if ThreeOutsideUp then
Bull = 1 //Positive
endif
ThreeWhiteSoldiers=(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 Drawdown
endif
ConcealingBabySwallow=(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 then
Bull = 1 //None
endif
BullishHarami=(body[1]<0 and body>0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])
if BullishHarami then
//Bull = 1 //Negative Impact
endif
HomingPigeon=(body[1]<0 and body<0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])
if HomingPigeon then
Bull = 1 //None
endif
BullishEngulfing=(body[1]<0 and body>0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)
if BullishEngulfing then
Bull = 1 //Positive
endif
LastEngulfingBottom=(body[1]>0 and body<0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)
if LastEngulfingBottom then
Bull = 1 //None
endif
DragonflyDojiBottom=(body[1]<0 and longcandle[1] and low<low[1] and shadowbottom>3*abody and shadowtop<shadowbottom/3)
if DragonflyDojiBottom then
Bull = 1 //None
endif
GravestoneDojiBottom=(body[1]<0 and longcandle[1] and low<low[1] and shadowtop>3*abody and shadowbottom<shadowtop/3)
if GravestoneDojiBottom then
Bull = 1 //None
endif
DojiStarBottom=(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 then
Bull = 1 //None
endif
BullishHaramiCross=(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 then
Bull = 1 //None
endif
ThreeStarsInTheSouth=(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 then
Bull = 1 //None
endif
BullishBreakaway=(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 then
Bull = 1 //None
endif
Hammer=(body[1]<0 and longcandle[1] and low<low[1] and shadowbottom>2*abody and shadowtop<0.3*abody)
if Hammer then
Bull = 1 //None
endif
InvertedHammer=(body[1]<0 and longcandle[1] and low<low[1] and shadowtop>2*abody and shadowbottom<0.3*abody)
if InvertedHammer then
Bull = 1 //None
endif
RisingThreeMethods=(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 then
Bull = 1 //None
endif
BullishThreeLineStrike=(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 then
Bull = 1 //None
endif
BullishMatHold=(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 then
Bull = 1 //None
endif
BullSash=(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 then
Bull = 1 //Positive
endif
BullSeparatingLine=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>=open[1] AND shadowtop<0.1*abody)
if BullSeparatingLine then
Bull = 1 //None
endif
BullishCounterAttack=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND close<=close[1])
if BullishCounterAttack then
Bull = 1 //None
endif
BullishKicking=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>=open[1] AND shadowtop=0 AND shadowbottom=0)
if BullishKicking then
Bull = 1 //None
endif
//Bearish Signal
EveningStar=(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 then
Bear = 1
endif
DarkCloudCover=(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 then
Bear = 1
endif
AbandonedBabyTop=(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 then
Bear = 1
endif
ThreeInsideDown=(body[2]>0 and body[1]<0 and body<0 and bearishharami[1] and close<close[1])
if ThreeInsideDown then
Bear = 1
endif
ThreeOutsideDown=(body[2]>0 and body[1]<0 and body<0 and bearishengulfing[1] and close<close[1])
if ThreeOutsideDown then
Bear = 1
endif
ThreeBlackCrows=(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 then
Bear = 1
endif
UpsideGapTwoCrows=(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 then
Bear = 1
endif
BearishHarami=(body[1]>0 and body<0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])
if BearishHarami then
Bear = 1
endif
DescendingHawk=(body[1]>0 and body>0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])
if DescendingHawk then
Bear = 1
endif
BearishEngulfing=(body[1]>0 and body<0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)
if BearishEngulfing then
Bear = 1
endif
LastEngulfingTop=(body[1]<0 and body>0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)
if LastEngulfingTop then
Bear = 1
endif
DragonflyDojiTop=(body[1]>0 and longcandle[1] and high>high[1] and shadowbottom>3*abody and shadowtop<shadowbottom/3)
if DragonflyDojiTop then
Bear = 1
endif
GravestoneDojiTop=(body[1]>0 and longcandle[1] and high>high[1] and shadowtop>3*abody and shadowbottom<shadowtop/3)
if GravestoneDojiTop then
Bear = 1
endif
DojiStarTop=(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 then
Bear = 1
endif
BearishHaramiCross=(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 then
Bear = 1
endif
AdvanceBlock=(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 then
Bear = 1
endif
TwoCrows=(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 then
Bear = 1
endif
BearishBreakaway=(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 then
Bear = 1
endif
ShootingStar=(body[1]>0 and longcandle[1] and high>high[1] and shadowtop>2*abody and shadowbottom<0.3*abody)
if ShootingStar then
Bear = 1
endif
HangingMan=(body[1]>0 and longcandle[1] and high>high[1] and shadowbottom>2*abody and shadowtop<0.3*abody)
if HangingMan then
Bear = 1
endif
FallingThreeMethods=(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 then
Bear = 1
endif
BearishThreeLineStrike=(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 then
Bear = 1
endif
BearishMatHold=(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 then
Bear = 1
endif
BearSash=(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 then
Bear = 1
endif
BearSeparatingLine=(body[1]>0 AND longcandle[1] AND body<0 AND longcandle AND open<=open[1] AND shadowbottom<0.1*abody)
if BearSeparatingLine then
Bear = 1
endif
BearishCounterAttack=(body[1]>0 AND longcandle[1] AND body<0 AND longcandle AND close>=close[1])
if BearishCounterAttack then
Bear = 1
endif
BearishKicking=(body[1]>0 AND longcandle[1] AND body<0 AND longcandle AND open<=open[1] AND shadowtop=0 AND shadowbottom=0)
if BearishKicking then
Bear = 1
endif
//Entry/Exit Criteria
possize = 1
NearMA = Average[7,2](close)
If countofposition = 0 and Bull = 1 and NearMA[1] > NearMA[3] and RSI[2](close) > 60 and NearMA > Average[150,2](close) and timeEnterBefore and timeEnterAfter and not daysForbiddenEntry Then
//If shortonmarket Then
//Exitshort at market
//EndIf
Buy possize contract at market
EndIf
If countofposition = 0 and Bear = 1 and NearMA[1] < NearMA[3] and RSI[2](close) < 25 and NearMA < Average[150,2](close)and timeEnterBefore and timeEnterAfter and not daysForbiddenEntry Then
//If longonmarket Then
//Sell at market
//EndIf
//Sellshort possize contract at market
EndIf
Set Target pProfit 8
Set Stop pLoss 50
body=close-open
abody=abs(body)
if (range+0.0000001)>0 then
ratio=abody/(range+0.0000001)
else
ratio=0
endif
Line 23-31, I´ve tried this on a strategy with candlesticks and it worked for me, same as Francesco78 did in his oil strategy.
Juanji.
THANK YOU for this strategy.! WORKS GREAT.!
I run in on EUR/USD, AUD/USD and EUR/CHF. Some run with your original code and some on the modified code. All with different SL and TP levels.
It will be great if the same strategy will run on Bear market as well.
I tried to tweak it for Bear market but I have no programming skills and gave up after some hours. I have tried coding but is just not good at it like you guys but I try.
I am considering giving it to friend of mine who recently lost his job and will need some income on the side.
I have been looking for strategy like this that does not require big amount of capital with him in mind.
Thank you
Andre Vorster
DAX not bad too with a added “MFE trailing stop” set up to 10…
I almost forgot about this strategy! Glad to see it still works.
@Inertia, maybe you can add the DAX version with the MFE Trailing Stop for easier future reference.
//Stategy: Scalping Candles
//Market: DAX
//Timeframe: 1min
//Spread: 1
//Author: Juan Jacobs (Jd3gjacobs@gmail.com)
// Définition des paramètres du code
DEFPARAM CumulateOrders = False
DEFPARAM FLATBEFORE = 090000
DEFPARAM FLATAFTER = 220000
noEntryBeforeTime = 090000
timeEnterBefore = time >= noEntryBeforeTime
noEntryAfterTime = 220000
timeEnterAfter = time < noEntryAfterTime
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
SL = 50 // 50
TP = 55 // 55
TS = 10 // 10
If longonmarket and close < positionprice and (barindex-tradeindex) > 650 Then
Sell at market
ElsIf shortonmarket and close > positionprice and (barindex-tradeindex) > 60 then
Exitshort at market
EndIf
body=close-open
abody=abs(body)
if (range+0.0000001)>0 then
ratio=abody/(range+0.0000001)
else
ratio=0
endif
middle=(open+close)/2
bodytop=max(open, close)
bodybottom=min(open, close)
shadowtop=high-bodytop
shadowbottom=bodybottom-low
longcandle= (ratio>0.6)
Bull = 0
//Bullish Signals
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 then
Bull = 1 //Positive
endif
PiercingLine=(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 then
Bull = 1 //None
endif
AbandonedBabyBottom=(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 then
Bull = 1 //None
endif
ThreeInsideUp=(body[2]<0 and body[1]>0 and body>0 and BullishHarami[1] and close>close[1])
if ThreeInsideUp then
Bull = 1 //Positive
endif
ThreeOutsideUp=(body[2]<0 and body[1]>0 and body>0 and BullishEngulfing[1] and close>close[1])
if ThreeOutsideUp then
Bull = 1 //Positive
endif
ThreeWhiteSoldiers=(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 Drawdown
endif
ConcealingBabySwallow=(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 then
Bull = 1 //None
endif
BullishHarami=(body[1]<0 and body>0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])
if BullishHarami then
//Bull = 1 //Negative Impact
endif
HomingPigeon=(body[1]<0 and body<0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])
if HomingPigeon then
Bull = 1 //None
endif
BullishEngulfing=(body[1]<0 and body>0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)
if BullishEngulfing then
Bull = 1 //Positive
endif
LastEngulfingBottom=(body[1]>0 and body<0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)
if LastEngulfingBottom then
Bull = 1 //None
endif
DragonflyDojiBottom=(body[1]<0 and longcandle[1] and low<low[1] and shadowbottom>3*abody and shadowtop<shadowbottom/3)
if DragonflyDojiBottom then
Bull = 1 //None
endif
GravestoneDojiBottom=(body[1]<0 and longcandle[1] and low<low[1] and shadowtop>3*abody and shadowbottom<shadowtop/3)
if GravestoneDojiBottom then
Bull = 1 //None
endif
DojiStarBottom=(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 then
Bull = 1 //None
endif
BullishHaramiCross=(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 then
Bull = 1 //None
endif
ThreeStarsInTheSouth=(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 then
Bull = 1 //None
endif
BullishBreakaway=(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 then
Bull = 1 //None
endif
Hammer=(body[1]<0 and longcandle[1] and low<low[1] and shadowbottom>2*abody and shadowtop<0.3*abody)
if Hammer then
Bull = 1 //None
endif
InvertedHammer=(body[1]<0 and longcandle[1] and low<low[1] and shadowtop>2*abody and shadowbottom<0.3*abody)
if InvertedHammer then
Bull = 1 //None
endif
RisingThreeMethods=(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 then
Bull = 1 //None
endif
BullishThreeLineStrike=(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 then
Bull = 1 //None
endif
BullishMatHold=(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 then
Bull = 1 //None
endif
BullSash=(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 then
Bull = 1 //Positive
endif
BullSeparatingLine=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>=open[1] AND shadowtop<0.1*abody)
if BullSeparatingLine then
Bull = 1 //None
endif
BullishCounterAttack=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND close<=close[1])
if BullishCounterAttack then
Bull = 1 //None
endif
BullishKicking=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>=open[1] AND shadowtop=0 AND shadowbottom=0)
if BullishKicking then
Bull = 1 //None
endif
//Entry/Exit Criteria
possize = 1
NearMA = Average[7,2](close)
If countofposition = 0 and Bull = 1 and NearMA[1] > NearMA[3] and RSI[2](close) > 60 and NearMA > Average[150,2](close) and timeEnterBefore and timeEnterAfter and not daysForbiddenEntry Then
//If shortonmarket Then
//Exitshort at market
//EndIf
Buy possize contract at market
EndIf
If countofposition = 0 and NearMA[1] < NearMA[3] and RSI[2](close) < 25 and NearMA < Average[150,2](close)and timeEnterBefore and timeEnterAfter and not daysForbiddenEntry Then
//If longonmarket Then
//Sell at market
//EndIf
//Sellshort possize contract at market
EndIf
//trailing stop
trailingstop = TS
if not onmarket then
MAXPRICE = 0
priceexit = 0
endif
//LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
endif
endif
//exit on trailing stop price levels
if onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endif
Set Target pProfit TP
Set Stop pLoss SL
There you go.
I also tried to make this strategy looking for short trades but was not successful enough to go live.
Thank you JuanJ !
I tried the eur/usd code on page nr 3 and it looks like this. Ins´t that strange?
I also want to remind you that when you test the dax code you can´t backtest it with 1p spread since it´s 2p spread after 17:30.
For those who are interested, I have played around adapting the strategy to ETH/USD and managed to get some good results.
1 Min Trading Strategy
This topic contains 219 replies,
has 29 voices, and was last updated by Leo
8 years, 2 months ago.
| Forum: | ProOrder: Automated Strategies & Backtesting |
| Language: | English |
| Started: | 07/13/2017 |
| Status: | Active |
| Attachments: | 65 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.