Indicator to Optimizer
Forums › ProRealTime English forum › ProOrder support › Indicator to Optimizer
- This topic has 12 replies, 7 voices, and was last updated 2 months ago by pableitor.
-
-
09/21/2024 at 9:13 PM #237912
Hi.
This looks intressting
https://www.prorealcode.com/prorealtime-indicators/candlestick-pattern-indicator-2-0/
How do I use the optimizer to backtest and find the best entry with this indicator.
09/23/2024 at 12:50 PM #237937Hi!
You could create a new variable called “type” (for example) and introduce in conditions to take a long position:
Here you have an example with 4 variations. Your code has a lot of types…123456789101112131415161718192021//---Doji: type1DojiSize = 0.05data=(abs(open - close) <= (high - low) * DojiSize)if type=1 and data thenbuy 1 contract at marketendif//---MorningStar: type 2MorningStar=(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 type=2 and TrendDown[3] AND MorningStar thenbuy 1 contract at marketendif//---PiercingLine: type 3PiercingLine=(body[1]<0 and body>0 and longcandle[1] and longcandle and open<low[1] and close>Pmiddle[1] and close<open[1])if type=3 and TrendDown[2] AND PiercingLine thenbuy 1 contract at marketendif//---AbandonedBabyBottom: type 4AbandonedBabyBottom=(body[2]<0 and body>0 and longcandle[2] and ratio[1]<0.3 and high[1]<low[2] and high[1]<low)if type=4 and TrendDown[3] AND AbandonedBabyBottom thenbuy 1 contract at marketendif2 users thanked author for this post.
09/23/2024 at 2:42 PM #23794109/23/2024 at 3:29 PM #237944I added the variable Signal to tell which pattern is returned and the variable Opt to be used with the optimizer.
The optimizer will pliot the best performing patterns for LONG trades.
Then you will have to uncomment line 487 and comment out line 486 to repeat the optimization for the best performing patterns for SHORT trades.
Here is the code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490// Trend direction identification//(choose 0=No Trend check, 1=MACD, 2=SAR, 3=Directional Movement, 4=Moving Averages crossing [default], 5=Stochastic)TDS=4//text color// white = 255,255,255 ; black = 0,0,0r = 0g = 0b = 0atr = averagetruerange[10](close)*0.5body=close-openabody=abs(body)if range>0 thenratio=abody/rangeelseratio=0endifmyMiddle=(open+close)/2if body>0 thenbodytop=closebodybottom=openelsebodytop=openbodybottom=closeendif//bodytop=max(open, close)//bodybottom=min(open, close)shadowtop=high-bodytopshadowbottom=bodybottom-lowlongcandle= (ratio>0.6)DojiSize = 0.05data=(abs(open - close) <= (high - low) * DojiSize)if data then//DrawText("Doji", barindex, high+atr*0.75, Dialog, Standard, 12) COLOURED(R,G,B)endif//Trend Detectionif TDS=0 thenTrendUp=1TrendDown=1elseif TDS=1 thenTrendUp=(MACDline[12,26,9](close)>0 AND MACD[12,26,9](close)>0)TrendDown=(MACDline[12,26,9](close)<0 AND MACD[12,26,9](close)<0)elseif TDS=2 thenTrendUp=(SAR[0.02,0.02,0.2]<low)TrendDown=(SAR[0.02,0.02,0.2]>high)elseif TDS=3 thenTrendUp=(ADX[14]>23 AND DI[14](close)>0)TrendDown=(ADX[14]>23 AND DI[14](close)<0)elseif TDS=4 thenTrendUp=(ExponentialAverage[2](close)>ExponentialAverage[4](close))TrendDown=(ExponentialAverage[2](close)<ExponentialAverage[4](close))elseif TDS=5 thenTrendUp=(Stochastic[14,3](close)>Average[5](Stochastic[14,3](close)))TrendDown=(Stochastic[14,3](close)<Average[5](Stochastic[14,3](close)))endifendifendifendifendifendifSignal = 0//Bullish SignalMorningStar=(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 TrendDown[3] AND MorningStar thenSignal = 1//DrawText("Morning Star", barindex, low[1]-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex-1,low[1]) COLOURED(0,155,10)endifPiercingLine=(body[1]<0 and body>0 and longcandle[1] and longcandle and open<low[1] and close>myMiddle[1] and close<open[1])if TrendDown[2] AND PiercingLine thenSignal = 2//DrawText("Piercing Line", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifAbandonedBabyBottom=(body[2]<0 and body>0 and longcandle[2] and ratio[1]<0.3 and high[1]<low[2] and high[1]<low)if TrendDown[3] AND AbandonedBabyBottom thenSignal = 2//DrawText("Abandoned Baby Bottom", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifThreeInsideUp=(body[2]<0 and body[1]>0 and body>0 and BullishHarami[1] and close>close[1])if TrendDown[3] AND ThreeInsideUp thenSignal = 3//DrawText("Three Inside Up", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifThreeOutsideUp=(body[2]<0 and body[1]>0 and body>0 and BullishEngulfing[1] and close>close[1])if TrendDown[3] AND ThreeOutsideUp thenSignal = 4//DrawText("Three Outside Up", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifThreeWhiteSoldiers=(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 TrendDown[3] AND ThreeWhiteSoldiers thenSignal = 5//DrawText("Three White Soldiers", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifConcealingBabySwallow=(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 TrendDown[4] AND ConcealingBabySwallow thenSignal = 6//DrawText("Concealing Baby Swallow", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifBullishHarami=(body[1]<0 and body>0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])if TrendDown[2] AND BullishHarami thenSignal = 7//DrawText("Bullish Harami", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifHomingPigeon=(body[1]<0 and body<0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])if TrendDown[2] AND HomingPigeon thenSignal = 8//DrawText("Homing Pigeon", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifBullishEngulfing=(body[1]<0 and body>0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)if TrendDown[2] AND BullishEngulfing thenSignal = 9//DrawText("Bullish Engulfing", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifLastEngulfingBottom=(body[1]>0 and body<0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)if TrendDown[2] AND LastEngulfingBottom thenSignal = 10//DrawText("Last Engulfing Bottom", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifDragonflyDojiBottom=(body[1]<0 and longcandle[1] and low<low[1] and shadowbottom>3*abody and shadowtop<shadowbottom/3)if TrendDown[2] AND DragonflyDojiBottom thenSignal = 11//DrawText("Dragonfly Doji", barindex, low-atr, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifGravestoneDojiBottom=(body[1]<0 and longcandle[1] and low<low[1] and shadowtop>3*abody and shadowbottom<shadowtop/3)if TrendDown[2] AND GravestoneDojiBottom thenSignal = 12//DrawText("Gravestone Doji", barindex, low-atr, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifDojiStarBottom=(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 TrendDown[2] AND DojiStarBottom thenSignal = 13//DrawText("Doji", barindex, low-atr*0.75, Dialog, Standard, 12) COLOURED(R,G,B)endifBullishHaramiCross=(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 TrendDown[2] AND BullishHaramiCross thenSignal = 14//DrawText("Bullish Harami Cross", barindex, low-atr*1.20, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifThreeStarsInTheSouth=(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 TrendDown[3] AND ThreeStarsInTheSouth thenSignal = 15//DrawText("Three Stars In The South", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifBullishBreakaway=(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 TrendDown[5] AND BullishBreakaway thenSignal = 16//DrawText("Bullish Breakaway", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifHammer=(body[1]<0 and longcandle[1] and low<low[1] and shadowbottom>2*abody and shadowtop<0.3*abody)if TrendDown[2] AND Hammer thenSignal = 17//DrawText("Hammer", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifInvertedHammer=(body[1]<0 and longcandle[1] and low<low[1] and shadowtop>2*abody and shadowbottom<0.3*abody)if TrendDown[2] AND InvertedHammer thenSignal = 18//DrawText("Inverted Hammer", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifRisingThreeMethods=(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 TrendUp[5] AND RisingThreeMethods thenSignal = 19//DrawText("Rising Three Methods", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifBullishThreeLineStrike=(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 TrendUp[4] AND BullishThreeLineStrike thenSignal = 20//DrawText("Bullish Three Line Strike", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifBullishMatHold=(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 TrendUp[5] AND BullishMatHold thenSignal = 21//DrawText("Bullish Mat Hold", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endif//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 TrendUp[3] AND EveningStar thenSignal = 22//DrawText("Evening Star", barindex, high[1]+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex-1,high[1]) COLOURED(255,0,10)endifDarkCloudCover=(body[1]>0 and body<0 and longcandle[1] and longcandle and open>high[1] and close<myMiddle[1] and close>open[1])if TrendUp[2] AND DarkCloudCover thenSignal = 23//DrawText("Dark Cloud Cover", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifAbandonedBabyTop=(body[2]>0 and body<0 and longcandle[2] and ratio[1]<0.3 and low[1]>high[2] and low[1]>high)if TrendUp[3] AND AbandonedBabyTop thenSignal = 24//DrawText("Abandoned Baby Top", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifThreeInsideDown=(body[2]>0 and body[1]<0 and body<0 and bearishharami[1] and close<close[1])if TrendUp[3] AND ThreeInsideDown thenSignal = 25//DrawText("Three Inside Down", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifThreeOutsideDown=(body[2]>0 and body[1]<0 and body<0 and bearishengulfing[1] and close<close[1])if TrendUp[3] AND ThreeOutsideDown thenSignal = 26//DrawText("Three Outside Down", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifThreeBlackCrows=(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 TrendUp[3] AND ThreeBlackCrows thenSignal = 27//DrawText("Three Black Crows", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifUpsideGapTwoCrows=(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 TrendUp[3] AND UpsideGapTwoCrows thenSignal = 28//DrawText("Upside Gap Two Crows", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifBearishHarami=(body[1]>0 and body<0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])if TrendUp[2] AND BearishHarami thenSignal = 29//DrawText("Bearish Harami", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifDescendingHawk=(body[1]>0 and body>0 and longcandle[1] and bodybottom>bodybottom[1] and bodytop<bodytop[1])if TrendUp[2] AND DescendingHawk thenSignal = 30//DrawText("Descending Hawk", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifBearishEngulfing=(body[1]>0 and body<0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)if TrendUp[2] AND BearishEngulfing thenSignal = 31//DrawText("Bearish Engulfing", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,20)endifLastEngulfingTop=(body[1]<0 and body>0 and bodybottom<bodybottom[1] and bodytop>bodytop[1] and longcandle)if TrendUp[2] AND LastEngulfingTop thenSignal = 32//DrawText("Last Engulfing Top", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,20)endifDragonflyDojiTop=(body[1]>0 and longcandle[1] and high>high[1] and shadowbottom>3*abody and shadowtop<shadowbottom/3)if TrendUp[2] AND DragonflyDojiTop thenSignal = 33//DrawText("Dragonfly Doji", barindex, high+atr, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifGravestoneDojiTop=(body[1]>0 and longcandle[1] and high>high[1] and shadowtop>3*abody and shadowbottom<shadowtop/3)if TrendUp[2] AND GravestoneDojiTop thenSignal = 34//DrawText("Gravestone Doji", barindex, high+atr, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifDojiStarTop=(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 TrendUp[2] AND DojiStarTop thenSignal = 35//DrawText("Doji", barindex, high+atr*0.75, Dialog, Standard, 12) COLOURED(R,G,B)endifBearishHaramiCross=(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 TrendUp[2] AND BearishHaramiCross thenSignal = 36//DrawText("Bearish Harami Cross", barindex, high+atr*1.20, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifAdvanceBlock=(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 TrendUp[3] AND AdvanceBlock thenSignal = 37//DrawText("Advance Block", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifTwoCrows=(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 TrendUp[3] AND TwoCrows thenSignal = 38//DrawText("Two Crows", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifBearishBreakaway=(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 TrendUp[5] AND BearishBreakaway thenSignal = 39//DrawText("Bearish Breakaway", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifShootingStar=(body[1]>0 and longcandle[1] and high>high[1] and shadowtop>2*abody and shadowbottom<0.3*abody)if TrendUp[2] AND ShootingStar thenSignal = 40//DrawText("Shooting Star", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifHangingMan=(body[1]>0 and longcandle[1] and high>high[1] and shadowbottom>2*abody and shadowtop<0.3*abody)if TrendUp[2] AND HangingMan thenSignal = 41//DrawText("Hanging Man", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifFallingThreeMethods=(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 TrendDown[5] AND FallingThreeMethods thenSignal = 42//DrawText("Falling Three Methods", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifBearishThreeLineStrike=(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 TrendDown[4] AND BearishThreeLineStrike thenSignal = 43//DrawText("Bearish Three Line Strike", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifBearishMatHold=(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 TrendDown[5] AND BearishMatHold thenSignal = 44//DrawText("Bearish Mat Hold", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endif//GapsGapUp=(low>high[1])GapDown=(high<low[1])if GapUp thenSignal = 45//DrawText("w", barindex, (high[1]+low)/2, Dialog, Bold, 12) COLOURED(0,0,255)elseif GapDown thenSignal = 46//DrawText("w", barindex, (high+low[1])/2, Dialog, Bold, 12) COLOURED(255,0,255)endifendif//Steve Nison CandlesBullSash=(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 thenSignal = 47//DrawText("Bull Sash", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifBullSeparatingLine=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>=open[1] AND shadowtop<0.1*abody)if BullSeparatingLine thenSignal = 48//DrawText("Bull Separating Line", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifBullishCounterAttack=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND close<=close[1])if TrendDown[2] AND BullishCounterAttack thenSignal = 49//DrawText("Bullish Counter Attack", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifBearSash=(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 thenSignal = 50//DrawText("Bear Sash", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifBearSeparatingLine=(body[1]>0 AND longcandle[1] AND body<0 AND longcandle AND open<=open[1] AND shadowbottom<0.1*abody)if BearSeparatingLine thenSignal = 51//DrawText("Bear Separating Line", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifBearishCounterAttack=(body[1]>0 AND longcandle[1] AND body<0 AND longcandle AND close>=close[1])if TrendUp[2] AND BearishCounterAttack thenSignal = 52//DrawText("Bearish Counter Attack", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endif//Tweezers Top and BottomTweezersTop=(body[1]>0 AND longcandle[1] AND body<=0 AND high=high[1])if TrendUp[2] AND TweezersTop thenSignal = 53//DrawText("Tweezers Top", barindex, high+atr*1.20, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifTweezersBottom=(body[1]<0 AND longcandle[1] AND body>=0 AND low=low[1])if TrendDown[2] AND TweezersBottom thenSignal = 54//DrawText("Tweezers Bottom", barindex, low-atr*1.20, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endif//kicker candlestick patternsBullishKicking=(body[1]<0 AND longcandle[1] AND body>0 AND longcandle AND open>=open[1] AND shadowtop=0 AND shadowbottom=0)if BullishKicking thenSignal = 55//DrawText("Bullish Kicking", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,155,10)//DrawArrOWUP(barindex,low-atr) COLOURED(0,155,10)endifBearishKicking=(body[1]>0 AND longcandle[1] AND body<0 AND longcandle AND open<=open[1] AND shadowtop=0 AND shadowbottom=0)if BearishKicking thenSignal = 56//DrawText("Bearish Kicking", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)//DrawArrOWDOWN(barindex,high+atr) COLOURED(255,0,10)endifIF Signal = Opt THENBUY 1 CONTRACT AT MARKET//SELLSHORT 1 CONTRACT AT MARKETSET STOP %LOSS 1SET TARGET %PROFIT 2ENDIF09/23/2024 at 3:30 PM #23794609/23/2024 at 4:29 PM #23794909/23/2024 at 5:09 PM #237951The ITF file is working like a charm.
09/23/2024 at 5:11 PM #237952sorry, i just copied it without downloading the itf
1 user thanked author for this post.
09/24/2024 at 11:40 AM #237964Several of the ‘Signals’ show body < 0 (example below).
How can a body be less than 0?
Or is it that PRT uses one calc only for body – Close – Open (instead of abs(Close-Open) – and so with a red candle, Close – Open gives a negative number and so this is interpreted by PRT as < 0?
Or do I need more coffee!? 😉
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 Signal = 50EDIT / PS
Signal 50 does get selected by the optimser so PRT does interpret body < 0 somehow?09/24/2024 at 12:34 PM #237967Only had a quick glance at code…
On line 13, if body is bear, close-open will result in a negative value, as you noted, Therefore, is body<0, just a way of knowing its a bear candle by the fact, bear will be negative and bull will be positive.
The BearSash statement is a logic equation, if body<0 was negative, this part results to true ‘1’. If it was positive it results in false ‘0’.
All part of the statement need to be true for Bearish to be true, if body was bull, the statement would fail false.
In this case the value of body appears not needed here just if its + or -.
Maybe the variable names may be a bit misleading, body = candleDirection, abody = candleSize,
additionally line 15, abody = abs(body) is just the size of the body if that info is required in a condition.
1 user thanked author for this post.
09/24/2024 at 1:39 PM #237968I think there is a little bug: the AbandonedBabyBottom signal should be 3 , not 2. From there you have to add 1 to all the signal values. Otherwise, superjob from @lighthouse and @roberto !
1 user thanked author for this post.
09/24/2024 at 2:04 PM #23796909/24/2024 at 2:16 PM #237970Well spotted! Easier to renumber the first 4 as 0,1,2,3 and enter 0 – 56 -1 in the optimiser?
even easier, just renumber AbandonedBabyBottom signal from 2 to 57
11 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on