// Ticker Candles.mq4 // Èíäèêàòîð #property copyright "mandorr@gmail.com" #property indicator_separate_window #property indicator_buffers 2 extern int CandleVolume=100; // Òèêîâûé îáúåì ñâå÷è extern int CandleWidth=5; // Øèðèíà ëèíèè ñâå÷è extern int CandlesCount=1000; // Êîëè÷åñòâî îòîáðàæàåìûõ ñâå÷ double buffer0[]; double buffer1[]; int candle_open []; int candle_high []; int candle_low []; int candle_close[]; int candle_volume; int candle_tick; int candle_size; int price_prev; int win_index; string obj_name; string win_name; void init() { SetIndexBuffer(0,buffer0); SetIndexBuffer(1,buffer1); SetIndexStyle (0,DRAW_NONE); SetIndexStyle (1,DRAW_NONE); SetIndexEmptyValue(0,0.0); SetIndexEmptyValue(1,0.0); SetIndexLabel (0,"High"); SetIndexLabel (1,"Low"); SetIndexDrawBegin(0,0); SetIndexDrawBegin(1,0); IndicatorDigits(Digits); price_prev=0; candle_tick=0; candle_size=0; candle_volume=MathMax(1,CandleVolume); win_name="Ticker Candles ("+candle_volume+")"; } void deinit() { ObjectsDeleteAll(win_index); } void start() { int i, price; double open, high, low, close; datetime time; price=MathRound(Bid/Point); if (price==0) {return;} if (price==price_prev) {return;} price_prev=price; if (candle_size==0) { Clean(); Setup(); } candle_tick++; if (candle_tick>candle_volume) { candle_tick=1; candle_size++; if (candle_size>CandlesCount) {candle_size=CandlesCount;} else { ArrayResize(candle_open ,candle_size); ArrayResize(candle_high ,candle_size); ArrayResize(candle_low ,candle_size); ArrayResize(candle_close,candle_size); } for (i=candle_size-1; i>0; i--) { candle_open [i]=candle_open [i-1]; candle_high [i]=candle_high [i-1]; candle_low [i]=candle_low [i-1]; candle_close[i]=candle_close[i-1]; } candle_open [0]=price; candle_high [0]=price; candle_low [0]=price; candle_close[0]=price; } if (candle_high[0]<price) {candle_high[0]=price;} if (candle_low [0]>price) {candle_low [0]=price;} candle_close[0]=price; IndicatorShortName(win_name); win_index=WindowFind(win_name); for (i=0; i<candle_size; i++) { open =candle_open [i]*Point; high =candle_high [i]*Point; low =candle_low [i]*Point; close=candle_close[i]*Point; time =Time[i]; color candle_color; if (close<open) {candle_color=Red;} else {candle_color=Blue;} obj_name="Win"+win_index+"_Candle"+i+"_HL"; if (ObjectFind(obj_name)!=win_index) { ObjectCreate(obj_name,OBJ_TREND,win_index,time,high,time,low); } ObjectSet(obj_name,OBJPROP_TIME1,time); ObjectSet(obj_name,OBJPROP_TIME2,time); ObjectSet(obj_name,OBJPROP_PRICE1,high); ObjectSet(obj_name,OBJPROP_PRICE2,low); ObjectSet(obj_name,OBJPROP_STYLE,DRAW_LINE); ObjectSet(obj_name,OBJPROP_WIDTH,1); ObjectSet(obj_name,OBJPROP_RAY,false); ObjectSet(obj_name,OBJPROP_COLOR,candle_color); obj_name="Win"+win_index+"_Candle"+i+"_OC"; if (ObjectFind(obj_name)!=win_index) { ObjectCreate(obj_name,OBJ_TREND,win_index,time,open,time,close); } ObjectSet(obj_name,OBJPROP_TIME1,time); ObjectSet(obj_name,OBJPROP_TIME2,time); ObjectSet(obj_name,OBJPROP_PRICE1,open); ObjectSet(obj_name,OBJPROP_PRICE2,close); ObjectSet(obj_name,OBJPROP_STYLE,DRAW_LINE); ObjectSet(obj_name,OBJPROP_WIDTH,CandleWidth); ObjectSet(obj_name,OBJPROP_RAY,false); ObjectSet(obj_name,OBJPROP_COLOR,candle_color); buffer0[i]=high; buffer1[i]=low ; } buffer0[candle_size]=0.0; buffer1[candle_size]=0.0; obj_name="Win"+win_index+"_Bid"; if (ObjectFind(obj_name)!=win_index) { ObjectCreate(obj_name,OBJ_HLINE,win_index,Time[0],Bid); } ObjectSet(obj_name,OBJPROP_PRICE1,Bid); ObjectSet(obj_name,OBJPROP_STYLE,DRAW_LINE); ObjectSet(obj_name,OBJPROP_WIDTH,1); ObjectSet(obj_name,OBJPROP_COLOR,Silver); } void Clean() { for (int i=0; i<=CandlesCount; i++) { buffer0[i]=0.0; buffer1[i]=0.0; } IndicatorShortName(win_name); win_index=WindowFind(win_name); ObjectsDeleteAll(win_index); } void Setup() { candle_size=1; ArrayResize(candle_open ,1); ArrayResize(candle_high ,1); ArrayResize(candle_low ,1); ArrayResize(candle_close,1); int price=MathRound(Bid/Point); candle_open [0]=price; candle_high [0]=price; candle_low [0]=price; candle_close[0]=price; } // End
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Indicator Curves created:
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features: