help please!
Nguyen Dai Phuc:
help please!
update is done in OnCalculate..do your code in OnCalculate ..
help please!
if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; if (counted_bars == 0) limit = Bars - 3;
Nguyen Dai Phuc:
Hi everybody. I have this indicator. I dont know why it does not update after every bar finished. Please help me.
#property copyright "Candle Pattern" #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 8 //--- indicator buffers input string n1="------------Engulfing pattern----------------------"; input bool Engulfing=false; //Turn On/Off input color EnColor1 = clrRed;// Down Candle Color input color EnColor2 = clrLightSeaGreen; //Up Candle Color input color EnColor3 = clrWhite; //Shadow Color input int EnWidth1=2;// Width Shadow input int EnWidth2=10;//Width Body input string n2="------------Hammer pattern----------------------"; input bool Hammer=false; input color DoColor1 = clrYellow;// Down Candle Color input color DoColor2 = clrBlue; //Up Candle Color input color DoColor3 = clrWhite; //Shadow Color input int DoWidth1=2;// Width Shadow input int DoWidth2=10;//Width Body input string n3="------------Bullish Hammer----------------------"; input double WickwBody=2;//Wick/Body input double TipwBody=0.5;//Tip/Body input string n4="------------Bearish Hammer----------------------"; input double WickwBody1=0.5;//Wick/Body input double TipwBody1=2;//Tip/Body double NewLowBuffer[]; double NewHighBuffer[]; double NewOpenBuffer[]; double NewCloseBuffer[]; double DoNewLowBuffer[]; double DoNewHighBuffer[]; double DoNewOpenBuffer[]; double DoNewCloseBuffer[]; double wick,tip,body; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexStyle(0,DRAW_HISTOGRAM,0,EnWidth1,EnColor3); SetIndexBuffer(0,NewLowBuffer); SetIndexStyle(1,DRAW_HISTOGRAM,0,EnWidth1,EnColor3); SetIndexBuffer(1,NewHighBuffer); SetIndexStyle(2,DRAW_HISTOGRAM,0,EnWidth2,EnColor1); SetIndexBuffer(2,NewOpenBuffer); SetIndexStyle(3,DRAW_HISTOGRAM,0,EnWidth2,EnColor2); SetIndexBuffer(3,NewCloseBuffer); SetIndexStyle(4,DRAW_HISTOGRAM,0,DoWidth1,DoColor3); SetIndexBuffer(4,DoNewLowBuffer); SetIndexStyle(5,DRAW_HISTOGRAM,0,DoWidth1,DoColor3); SetIndexBuffer(5,DoNewHighBuffer); SetIndexStyle(6,DRAW_HISTOGRAM,0,DoWidth2,DoColor1); SetIndexBuffer(6,DoNewOpenBuffer); SetIndexStyle(7,DRAW_HISTOGRAM,0,DoWidth2,DoColor2); SetIndexBuffer(7,DoNewCloseBuffer); //--- return(INIT_SUCCEEDED); } int deinit() { //---- TODO: add your code here //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- double O, O1, O2, C, C1, C2, L, L1, L2, H, H1, H2; int shift1=0; int shift2; int shift3; int shift; int counted_bars = prev_calculated; if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; int limit=fmin(rates_total-counted_bars,rates_total-1); for(shift=limit;shift>=0;shift--) { shift1 = shift + 1; shift2 = shift + 2; shift3 = shift + 3; O = Open[shift1]; O1 = Open[shift2]; O2 = Open[shift3]; H = High[shift1]; H1 = High[shift2]; H2 = High[shift3]; L = Low[shift1]; L1 = Low[shift2]; L2 = Low[shift3]; C = Close[shift1]; C1 = Close[shift2]; C2 = Close[shift3]; if(Hammer) { if(C>O) { wick=O-L; body=C-O; tip=H-C; } if(C<O) { wick=C-L; body=O-C; tip=H-O; } if((tip/body<=TipwBody&&wick/body>=WickwBody)||(tip/body>=TipwBody1&&wick/body<=WickwBody1)) { DoNewCloseBuffer[shift1]=Close[shift1]; DoNewHighBuffer[shift1]=High[shift1]; DoNewLowBuffer[shift1]=Low[shift1]; DoNewOpenBuffer[shift1]=Open[shift1]; } } if (((C1>O1)&&(O>C)&&(C<L1)&&((O-C)>(C1-O1))&&H1>=H2)||((O1>C1)&&(C>O)&&(C>=H1)&&((C-O)>(O1-C1))&&L1<=L2)) { if(Engulfing) { NewCloseBuffer[shift1]=Close[shift1]; NewHighBuffer[shift1]=High[shift1]; NewLowBuffer[shift1]=Low[shift1]; NewOpenBuffer[shift1]=Open[shift1]; NewCloseBuffer[shift2]=Close[shift2]; NewHighBuffer[shift2]=High[shift2]; NewLowBuffer[shift2]=Low[shift2]; NewOpenBuffer[shift2]=Open[shift2]; } } } return(0); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi everybody. I have this indicator. I dont know why it does not update after every bar finished. Please help me.