Yes but imo only for current data. Meaning when you start the indicator you'll get empty chart and then it''ll draw bars for you in real time. These wont be real bars though and the TimeSeries commands will not apply to them.
i tried coding like this but it did not work properly.
what's wrong with it?
can someone help.
//+------------------------------------------------------------------+ //| 10TicksCandle.mq4 | //| yijomza | //| yijomza@gmail.com | //+------------------------------------------------------------------+ #property copyright "yijomza" #property link "yijomza@gmail.com" #property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 Crimson #property indicator_color2 SteelBlue #property indicator_color3 Crimson #property indicator_color4 SteelBlue extern int Tick2Count=10; extern int MaxCandle =200; //---- buffers double UpTail[]; double UpBody[]; double DNTail[]; double DNBody[]; double open[]; double high[]; double low[]; double close[]; double tick[]; int BarCounter,curtick,ct; double price,pre; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_HISTOGRAM, STYLE_SOLID, 1); SetIndexBuffer(0,UpTail); SetIndexStyle(1,DRAW_HISTOGRAM, STYLE_SOLID, 1); SetIndexBuffer(1,DNTail); SetIndexStyle(2,DRAW_HISTOGRAM, STYLE_SOLID, 3); SetIndexBuffer(2,UpBody); SetIndexStyle(3,DRAW_HISTOGRAM, STYLE_SOLID, 3); SetIndexBuffer(3,DNBody); SetIndexDrawBegin(0, 10); SetIndexDrawBegin(1, 10); SetIndexDrawBegin(2, 10); SetIndexDrawBegin(3, 10); for (int i=Bars-1;i>=0;i--) { //UpTail[i]=0.0; //UpBody[i]=0.0; //DNTail[i]=0.0; //DNBody[i]=0.0; } ArrayResize(open,MaxCandle); ArrayResize(close,MaxCandle); ArrayResize(high,MaxCandle); ArrayResize(low,MaxCandle); ArrayResize(tick,20); open[0]=Bid; close[0]=Bid; low[0]=Bid; high[0]=Bid; price=Bid; //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- Comment(""); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- if(BarCounter==0 && curtick==0) { open[0]=Bid; close[0]=Bid; low[0]=Bid; high[0]=Bid; price=Bid; } if (curtick>Tick2Count) { curtick=1; BarCounter++; pre=price; price=Bid; open[0]=Bid; ShiftArray(); } else { curtick++; pre=price; price=Bid; close[0]=Bid; if(Bid<pre)low[0]=Bid; if(Bid>pre)high[0]=Bid; } for(int i=MaxCandle;i>=0;i--) { if(close[i]>=open[i]) { UpBody[i]=close[i]; DNBody[i]=open[i]; UpTail[i]=high[i]; DNTail[i]=low[i]; } else//(close[i]<open[i]) { DNBody[i]=close[i]; UpBody[i]=open[i]; DNTail[i]=high[i]; UpTail[i]=low[i]; } } Comment("Close : ",close[0] ,"\nOpen : ",open[0] ,"\nHigh : ",high[0] ,"\nLow : ",low[0] ,"\nBar : ",BarCounter ,"\nTick : ",curtick ); //---- return(0); } //+------------------------------------------------------------------+ void ShiftArray() { //---- if(BarCounter>MaxCandle)BarCounter=MaxCandle; for(int cnt=BarCounter;cnt>0;cnt--) { open[cnt]=open[cnt-1]; high[cnt]=high[cnt-1]; low[cnt]=low[cnt-1]; close[cnt]=close[cnt-1]; UpTail[cnt]=UpTail[cnt-1]; UpBody[cnt]=UpBody[cnt-1]; DNTail[cnt]=UpTail[cnt-1]; DNBody[cnt]=UpBody[cnt-1]; } //---- return(0); }
and it looks like this
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
as above
please help ^_^