#property copyright "Ajchi" #property link "No Link" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Green #property indicator_color2 Red #property indicator_color3 MediumVioletRed #property indicator_color4 DodgerBlue #property indicator_color5 Bisque #property indicator_color6 DeepPink //extern int takenBars,difference,matching; //----vyrovnávací paměti double buyPB[]; double sellPB[]; static int prevTime; double dayRange = 0.0; int outsideBarsCount=0; string period=""; //stats variables //+------------------------------------------------------------------+ //| Custom indicator – inicializační funkce | //+------------------------------------------------------------------+ int init() { //----indikátory SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,233); //242 for down arrow SetIndexBuffer(0,buyPB); SetIndexLabel(0,"PB UP"); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,234); //244 for up&down arrow SetIndexBuffer(1,sellPB); SetIndexLabel(1,"PB DOWN"); switch (Period()) { case 60: period="H1"; break; case 240: period="H4"; break; case 1440: period="D1"; break; case 30: period="30m"; break; case 15: period="15m"; break; case 5: period="5m"; break; } return(0); } //+------------------------------------------------------------------+ //| Custom indicator – deinicializační funkce | //+------------------------------------------------------------------+ int deinit() { //----- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator – funkce opakování | //+------------------------------------------------------------------+ int start() { string info=""; string time=""; bool addInfo=false; int outsideBarDirection; int hours, min, sec; double gapSize; bool alertOn; int smallSRcount=0; if(prevTime==Time[0]) return(0); // Always start at the new bar prevTime=Time[0]; int counted_bars=IndicatorCounted(); if (counted_bars<0) return(-1); if (counted_bars>0) counted_bars--; int pos=Bars-counted_bars; if(pos>20000) pos=20000; alertOn=true; //Comment("counted_bars="+counted_bars+", pos="+pos); //pos=0; int counter=0; //double poslGap=0.0; while(pos>=0 ) { double Boll_High= iBands (Symbol(), 0, 20, 2.0, 0, 0, MODE_UPPER, pos+1); double Boll_Low= iBands (Symbol(), 0, 20, 2.0, 0, 0, MODE_LOWER, pos+1); //addInfo=false; if (IsBuyPinbar(dayRange,pos)) { buyPB[pos+1]=Low[pos+1]-dayRange/4.0; if(alertOn&&pos<1&&Low[pos+1]Boll_High) { Alert ("Symbol: ",Symbol()," TimeFrame: ",period," Operace: PinBar SELL Rozsah: ",(High[1]-Low[1])/Point," Cas:",TimeToStr(Time[pos],TIME_DATE|TIME_MINUTES)); PlaySound("alert2.wav"); addInfo=true; } } pos--; } return(0); } //+------------------------------------------------------------------+ //| User function AveRange4 | //+------------------------------------------------------------------+ double AveRange4(int pos) { double sum; double rangeSerie[4]; int i=0; int ind=1; int startYear=1995; int den; if(pos<=0)den=1; else den = pos; if (TimeYear(Time[den-1])>=startYear) { while (i<4) { //datetime pok=Time[pos+ind]; if(TimeDayOfWeek(Time[pos+ind])!=0) { sum+=High[pos+ind]-Low[pos+ind];//make summation i++; } ind++; //i++; } //Comment(sum/4.0); return (sum/4.0);//make average, don't count min and max, this is why I divide by 4 and not by 6 } return (50*Point); }//------------END FUNCTION------------- //+------------------------------------------------------------------+ //| User function IsPinbar | //+------------------------------------------------------------------+ bool IsBuyPinbar(double& dayRange, int pos) { //start of declarations double actOp,actCl,actHi,actLo,preHi,preLo,preCl,preOp,actRange,preRange,actHigherPart,actHigherPart1; actOp=Open[pos+1]; actCl=Close[pos+1]; actHi=High[pos+1]; actLo=Low[pos+1]; preOp=Open[pos+2]; preCl=Close[pos+2]; preHi=High[pos+2]; preLo=Low[pos+2]; //SetProxy(preHi,preLo,preOp,preCl);//Check proxy actRange=actHi-actLo; preRange=preHi-preLo; actHigherPart=actHi-actRange*0.4;//helping variable to not have too much counting in IF part actHigherPart1=actHi-actRange*0.4;//helping variable to not have too much counting in IF part //end of declaratins //start function body dayRange=AveRange4(pos); if((actCl>actHigherPart1&&actOp>actHigherPart)&& //Close&Open of PB is in higher 1/3 of PB (actRange>dayRange*0.5)&& //PB is not too small //(actHi<(preHi-preRange*0.3))&& //High of PB is NOT higher than 1/2 of previous Bar (actLo+actRange*0.25Low[pos+1]) return (true); } return(false); }//------------END FUNCTION------------- bool IsSellPinbar(double& dayRange, int pos) { //start of declarations double actOp,actCl,actHi,actLo,preHi,preLo,preCl,preOp,actRange,preRange,actLowerPart, actLowerPart1; actOp=Open[pos+1]; actCl=Close[pos+1]; actHi=High[pos+1]; actLo=Low[pos+1]; preOp=Open[pos+2]; preCl=Close[pos+2]; preHi=High[pos+2]; preLo=Low[pos+2]; //SetProxy(preHi,preLo,preOp,preCl);//Check proxy actRange=actHi-actLo; preRange=preHi-preLo; actLowerPart=actLo+actRange*0.4;//helping variable to not have too much counting in IF part actLowerPart1=actLo+actRange*0.4;//helping variable to not have too much counting in IF part //end of declaratins //start function body dayRange=AveRange4(pos); if((actCldayRange*0.5)&& //PB is not too small //(actLo>(preLo+preRange/3.0))&& //Low of PB is NOT lower than 1/2 of previous Bar (actHi-actRange*0.25>preHi)) //Nose of the PB is at least 1/3 lower than previous bar { if(High[ArrayMaximum(High,3,pos+3)]