#property copyright "Beerrun, 12.1.2018" #property link "https://www.forexfactory.com/showthread.php?t=166758" #property description "Indicates an Engulfing bar, then two same direction inside bars , followed by another engulfing bar of equal or greater size to initial bar. If any errors or requests please contact me at forexfactory.com" #property version "1.0" #property strict enum alerts{ alert=1,//Alert only notification=2,//Notification only both=3//Both alert and notification }; enum alertforming{ yes=1,//Yes no=2//No }; enum destroy{ yy=1,//Yes nn=2//No }; input alerts Alerts=both;//Alerts and/or notifications input alertforming AlertForming=yes;//Alert when pattern is forming? Yes/No input string possbull ="Possible BULL Pattern Forming";//Message for Bullish pattern forming input string bullbreak="!!!BULL Pattern Broken To Upside!!!";//Message for Bullish pattern break input string possbear ="Possible BEAR Pattern Forming";//Message for Bearish pattern forming input string bearbreak="!!!BEAR Pattern Broken To Downside!!!";//Message for Bearish pattern break input color bullboxcolour=clrSteelBlue;//Bull pattern box colour input color bearboxcolour=clrIndigo;//Bear pattern box colour input color failedboxcolour=C'82,82,82';//Failed set colour input destroy Delete=nn;//Delete old boxes? static datetime _lastBarTime=0; string name; int boxcnt=0,possbullsw=0,possbearsw=0,bypass=1; void init(){ destroybox(); _lastBarTime=iTime(Symbol(),Period(),0); comments(); return;} int start(){ comments(); if(IsNewBar()==True){ if(possbullsw==0){ possbullsw=(Close[1]>Open[1])?1:0; return(0);} if(possbullsw==1){ if(Close[1]Open[2]&& Close[1]Open[3]&& Close[1]Open[3]){ send(possbull); patternbox(bullboxcolour); possbullsw=3;return(0);} else {possbullsw=0;return(0);}} if(possbullsw==3){ if(Close[1]>Open[1]&& Open[1]<=Close[2]&& Open[1]>=Open[4]&& Close[1]>=Close[4]){ possbullsw=4; comments(); send(bullbreak);} else failedbox(); possbullsw=0; destroybox();return(0);} if(possbearsw==0){ possbearsw=(Close[1]Open[1]&& Open[1]>=Close[2]&& Close[1]Close[2]){ possbearsw=2;return(0);} else {possbearsw=0;return(0);}} if(possbearsw==2){ if(Close[1]>Open[1]&& Close[1]Close[2]&& Open[1]=Close[2]&& Open[1]<=Open[4]&& Close[1]<=Close[4]){ possbearsw=4; send(bearbreak);} else failedbox(); possbearsw=0; destroybox();return(0);}} return(0);} void deinit(){ bypass=1; destroybox(); comments(); return;} bool IsNewBar(){if(iTime(Symbol(),Period(),0)!=_lastBarTime){ _lastBarTime=iTime(Symbol(),Period(),0);return(True);}else return(False);} void send(string message){ string msg=_Symbol+" "+message; if(AlertForming==1){ if(Alerts==1)Alert(msg); if(Alerts==2)SendNotification(msg); if(Alerts==3){Alert(msg);SendNotification(msg);}} return;} void patternbox(color colour){ datetime firstcandle=iTime(Symbol(),Period(),3), lastcandle=iTime(Symbol(),Period(),0); double price1=Open[3],price2=Close[3]; name=_Symbol+StringFormat("BreakoutBox%G",boxcnt); if(ObjectCreate(name,OBJ_RECTANGLE,0,firstcandle,price2,lastcandle,price1)){ ObjectSet(name,OBJPROP_COLOR,colour); boxcnt+=1;} return;} void failedbox(){ ObjectSet(name,OBJPROP_COLOR,failedboxcolour); return;} void destroybox(){ if(Delete==1||bypass==1){ for(int i=boxcnt;i>=0;i--){ ObjectDelete(_Symbol+StringFormat("BreakoutBox%G",i));} boxcnt=0; bypass=0;} return;} void comments(){ if(possbullsw==0||possbearsw==0){ Comment("Rising-Falling_Two Indicator v1.0 \n ...waiting on Mr. Market... ");} if(possbullsw==1||possbearsw==1){ Comment("Rising-Falling_Two Indicator v1.0 \n ...noise noise noise... ");} if(possbullsw==2||possbearsw==2){ Comment("Rising-Falling_Two Indicator v1.0 \n ...waiting on Ms. Market... ");} if(possbullsw==3||possbearsw==3){ Comment("Rising-Falling_Two Indicator v1.0 \n ***Possible Pattern!*** ");} if(possbullsw==4||possbearsw==4){ Comment("Rising-Falling_Two Indicator v1.0 \n *!*Pattern Successfully Completed*!* ");} return;}