//+------------------------------------------------------------------+ //| HAshi_sub.mq4 | //| Maxim A.Kuznetsov | //| nektomk.wordpress.com | //+------------------------------------------------------------------+ #property copyright "Maxim A.Kuznetsov" #property link "nektomk.wordpress.com" #property version "1.00" #property description "Heiken Ashi Candles in subwindow" #property strict #property indicator_separate_window #property indicator_buffers 8 #property indicator_plots 8 //--- plot GREEN_CLOSE #property indicator_label1 "GREEN_CLOSE" #property indicator_type1 DRAW_HISTOGRAM #property indicator_color1 clrGreen #property indicator_style1 STYLE_SOLID #property indicator_width1 5 //--- plot GREEN_OPEN #property indicator_label2 "GREEN_OPEN" #property indicator_type2 DRAW_HISTOGRAM #property indicator_color2 clrWhite #property indicator_style2 STYLE_SOLID #property indicator_width2 5 //--- plot GREEN_HIGH #property indicator_label3 "GREEN_HIGH" #property indicator_type3 DRAW_HISTOGRAM #property indicator_color3 clrGreen #property indicator_style3 STYLE_SOLID #property indicator_width3 1 //--- plot GREEN_LOW #property indicator_label4 "GREEN_LOW" #property indicator_type4 DRAW_HISTOGRAM #property indicator_color4 clrWhite #property indicator_style4 STYLE_SOLID #property indicator_width4 1 //--- plot RED_OPEN #property indicator_label5 "RED_OPEN" #property indicator_type5 DRAW_HISTOGRAM #property indicator_color5 clrRed #property indicator_style5 STYLE_SOLID #property indicator_width5 5 //--- plot RED_CLOSE #property indicator_label6 "RED_CLOSE" #property indicator_type6 DRAW_HISTOGRAM #property indicator_style6 STYLE_SOLID #property indicator_color6 clrWhite #property indicator_width6 5 //--- plot RED_HIGH #property indicator_label7 "RED_HIGH" #property indicator_type7 DRAW_HISTOGRAM #property indicator_color7 clrRed #property indicator_style7 STYLE_SOLID #property indicator_width7 1 //--- plot RED_LOW #property indicator_label8 "RED_LOW" #property indicator_type8 DRAW_HISTOGRAM #property indicator_style8 STYLE_SOLID #property indicator_color8 clrWhite #property indicator_width8 1 //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ enum ENUM_CANDLE_WIDTH { CANDLE_2=2, // 2 CANDLE_THIN=3, // 3 CANDLE_MID=4, // 4 CANDLE_THIK=5 // 5 }; sinput color GREEN_CANDLE=clrGreen; // color for "green" candle: sinput color RED_CANDLE=clrRed; // color for "red" candle: sinput ENUM_CANDLE_WIDTH CANDLE_WIDTH=CANDLE_THIK; // width for candles: sinput bool SHOW_BID=true; // show "Bid" line sinput bool SHOW_ASK=true; // show "Ask" line color bg; //--- indicator buffers double GREEN_HIGH[]; double GREEN_OPEN[]; double GREEN_CLOSE[]; double GREEN_LOW[]; double RED_HIGH[]; double RED_OPEN[]; double RED_CLOSE[]; double RED_LOW[]; // Bid && Ask lines string shortName; // shortname long chart; // chart int subwin; // subwindow int indId; // indicator id in subwin string prefix; // common object prefix string hlineBid; color colorBid; string hlineAsk; color colorAsk; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { string obj; IndicatorDigits(_Digits); chart=ChartID(); MathSrand((int)GetMicrosecondCount()); // determine main subwin shortName=StringFormat("HAshi_sub %d",MathRand()); IndicatorShortName(shortName); int total,totalWin; totalWin=(int)ChartGetInteger(chart,CHART_WINDOWS_TOTAL); for(subwin=1;subwin=hashi_close) { RED_OPEN[bar]=hashi_open; RED_HIGH[bar]=hashi_high-_Point; RED_LOW[bar]=hashi_low; RED_CLOSE[bar]=hashi_close-_Point; } else { GREEN_OPEN[bar]=hashi_open; GREEN_HIGH[bar]=hashi_high-_Point; GREEN_LOW[bar]=hashi_low; GREEN_CLOSE[bar]=hashi_close-_Point; } } if(hlineBid!="") ObjectSetDouble(chart,hlineBid,OBJPROP_PRICE,Bid); if(hlineAsk!="") ObjectSetDouble(chart,hlineAsk,OBJPROP_PRICE,Ask); return(rates_total-2); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void AllArraysAsNormal(const double &open[],const double &high[],const double &low[],const double &close[]) { ArraySetAsSeries(GREEN_HIGH,false); ArraySetAsSeries(GREEN_OPEN,false); ArraySetAsSeries(GREEN_CLOSE,false); ArraySetAsSeries(GREEN_LOW,false); ArraySetAsSeries(RED_HIGH,false); ArraySetAsSeries(RED_OPEN,false); ArraySetAsSeries(RED_CLOSE,false); ArraySetAsSeries(RED_LOW,false); ArraySetAsSeries(open,false); ArraySetAsSeries(high,false); ArraySetAsSeries(low,false); ArraySetAsSeries(close,false); } //+------------------------------------------------------------------+