Indicators: Change the color of the candles
Hi kourosh1347 , how did your code is similar with the one in forum (https://www.mql5.com/en/forum/9142#comment_382841) that belong to user TIMisthebest ?
hi;
no; kourosh1347 write the first version of it ;
when i asked him about ;
TIMisthebest 2012.12.04 13:37 # thank you. i correct it but ; still has a problem; //+------------------------------------------------------------------+ //| Z4_ColorCandles_Daily_Hours.mq5 | //| Copyright 2012, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" #property indicator_chart_window int Day_End=4; int Hour_Start=6; int Minute_Start=0; int Hour_End=23; int Minute_End=59; input color Color_Chart_Line_0=Magenta; input color Color_Candle_Bull_0=SkyBlue; input color Color_Candle_Bear_0=LightPink; input color Color_Bar_Up_0=PowderBlue; input color Color_Bar_Down_0=Bisque; //--- input color Color_Chart_Line_1=Red; input color Color_Candle_Bull_1=Red; input color Color_Candle_Bear_1=Red; input color Color_Bar_Up_1=Red; input color Color_Bar_Down_1=Red; //------------------------------------------------------------------------------ color for line chart and Doji candles color GetColorChartLine() { return((color)ChartGetInteger(0,CHART_COLOR_CHART_LINE)); } void SetColorChartLine(color Color_Chart_Line) { ChartSetInteger(0,CHART_COLOR_CHART_LINE,Color_Chart_Line); } //-------------------------------------------------------------------------------------- body color of the bull candle color GetColorCandleBull() { return((color)ChartGetInteger(0,CHART_COLOR_CHART_UP)); } void SetColorCandleBull(color Color_Candle_Bull) { ChartSetInteger(0,CHART_COLOR_CHART_UP,Color_Candle_Bull); } //-------------------------------------------------------------------------------------- body color of the bear candle color GetColorCandleBear() { return((color)ChartGetInteger(0,CHART_COLOR_CHART_DOWN)); } void SetColorCandleBear(color Color_Candle_Bear) { ChartSetInteger(0,CHART_COLOR_CHART_DOWN,Color_Candle_Bear); } //----------------------------------------------------------------------------------- Body color of a bull candlestick color GetColorBarUp() { return((color)ChartGetInteger(0,CHART_COLOR_CANDLE_BULL)); } void SetColorBarUp(color Color_Bar_Up) { ChartSetInteger(0,CHART_COLOR_CANDLE_BULL,Color_Bar_Up); } //----------------------------------------------------------------------------------- Body color of a bull candlestick color GetColorBarDown() { return((color)ChartGetInteger(0,CHART_COLOR_CANDLE_BEAR)); } void SetColorBarDown(color Color_Bar_Down) { ChartSetInteger(0,CHART_COLOR_CANDLE_BEAR,Color_Bar_Down); } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping //--- 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[]) { //--- ChartSetInteger(0,CHART_COLOR_CHART_LINE,Color_Chart_Line_0); ChartSetInteger(0,CHART_COLOR_CHART_UP,Color_Candle_Bull_0); ChartSetInteger(0,CHART_COLOR_CHART_DOWN,Color_Candle_Bear_0); ChartSetInteger(0,CHART_COLOR_CANDLE_BULL,Color_Bar_Up_0); ChartSetInteger(0,CHART_COLOR_CANDLE_BEAR,Color_Bar_Down_0); MqlDateTime time_now; datetime candle_time=TimeTradeServer(time_now); if( time_now.day_of_week==Day_End && time_now.hour>=Hour_End && time_now.min>=Minute_End ) { ChartSetInteger(0,CHART_COLOR_CHART_LINE,Color_Chart_Line_1); ChartSetInteger(0,CHART_COLOR_CHART_UP,Color_Candle_Bull_1); ChartSetInteger(0,CHART_COLOR_CHART_DOWN,Color_Candle_Bear_1); ChartSetInteger(0,CHART_COLOR_CANDLE_BULL,Color_Bar_Up_1); ChartSetInteger(0,CHART_COLOR_CANDLE_BEAR,Color_Bar_Down_1); } //+------------------------------------------------------------------+ Comment( "\ntime_now=",candle_time ,"\ntime_now_year=",time_now.year," time_now_mon=",time_now.mon ,"\ntime_now_day=",time_now.day," time_now_hour=",time_now.hour," time_now_min=",time_now.min ," time_now_sec=",time_now.sec); //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { Comment(""); //---- //---- } //+----------------------------------
he write this:
//+------------------------------------------------------------------------------+ //| candel color | //+------------------------------------------------------------------------------+ #property indicator_chart_window #property version "1.0" #property indicator_buffers 6 #property indicator_label1 "Open;High;Low;Close" #property indicator_plots 1 #property indicator_type1 DRAW_COLOR_CANDLES #property indicator_width1 3 input int Day_Start=1; input int Hour_Start=22; input int Minute_Start=30; input int Day_End=1; input int Hour_End=23; input int Minute_End=30; input color Color_Bar_Up_1=Magenta; input color Color_Bar_Down_1=Blue; input color Color_Bar_Up_0=Green; input color Color_Bar_Down_0=Red; double buffer_open[],buffer_high[],buffer_low[],buffer_close[]; double buffer_color_line[]; double buffer_tmp[1]; int OnInit() { SetIndexBuffer(0,buffer_open,INDICATOR_DATA); SetIndexBuffer(1,buffer_high,INDICATOR_DATA); SetIndexBuffer(2,buffer_low,INDICATOR_DATA); SetIndexBuffer(3,buffer_close,INDICATOR_DATA); SetIndexBuffer(4,buffer_color_line,INDICATOR_COLOR_INDEX); PlotIndexSetInteger(0,PLOT_COLOR_INDEXES,4); PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,Color_Bar_Up_0); PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,Color_Bar_Down_0); PlotIndexSetInteger(0,PLOT_LINE_COLOR,2,Color_Bar_Up_1); PlotIndexSetInteger(0,PLOT_LINE_COLOR,3,Color_Bar_Down_1); return(0); } 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[]) { MqlDateTime time_now; for(int i=prev_calculated;i<=rates_total-1;i++) { buffer_open[i]=open[i]; buffer_high[i]=high[i]; buffer_low[i]=low[i]; buffer_close[i]=close[i]; datetime candle_time=time[i]; TimeToStruct(time[i],time_now); if( (time_now.day_of_week==Day_Start && time_now.hour>=Hour_Start && time_now.min>=Minute_Start) &&( time_now.day_of_week==Day_End && time_now.hour<=Hour_End && time_now.min<=Minute_End ) ) { if ( open[i]>= close[i]) buffer_color_line[i]=3; else buffer_color_line[i]=2; } else { if ( open[i]>= close[i]) buffer_color_line[i]=1; else buffer_color_line[i]=0; } } return(rates_total-1); } //+------------------------------------------------------------------+
and send it to me;
and it was not that thing i expected ;
so when i talk about this with " kourosh1347 " by phone ;
after that i share it , to modified it:( how can help? )
and it has no name;
from : ( hi; a question about time define in mql5 .
in this code: but still has problem ; can you please check it //+------------------------------------------------------------------------------+ #property indicator_chart_window #property version "1.0"
and i told him ( in messsage):
this have problem when : (
Day_Start=6; and Day_End=6
( my broker worked in day=6 from 22:00 to 24:00 )
and
Indicators: Change the color of the candles
is belong to " kourosh1347 "
before i wrote this i send message to " kourosh1347 " :
read :
hi; a question about time define in mql5 .
&
Indicators: Change the color of the candles
&
also i send sms to his mobile phone
How can I make only the last candle change its colour? And the rest of the candles remain the same colour?
Change the color of the candles:
The indicator that allows modifying color of the candles.
Author: Kourosh Davallou