指标: 改变烛形的颜色

 

改变烛形的颜色:

本指标允许改变烛形的颜色.

作者: Kourosh Davallou

 
您好kourosh1347 您的代码与论坛(https://www.mql5.com/en/forum/9142#comment_382841) 用户 TIMisthebest 的代码有 什么 相似之处?
 
phi.nuts:
您好kourosh1347 您的代码与用户 TIMisthebest 在论坛(https://www.mql5.com/en/forum/9142#comment_382841) 中的代码相似吗?

您好;

不;kourosh1347 写的是第一个版本;

当我问他关于 ;

 TIMisthebest 2012.12.04 13:37 #

thank you.

i correct it but ; still has a problem;

//+------------------------------------------------------------------+
//|Z4_ColorCandles_Daily_Hours.mq5
//| 2012 年 MetaQuotes 软件公司版权所有。|
//|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  GetColorChartLine() { return((color)ChartGetInteger(0,CHART_COLOR_CHART_LINE)); }
    void  SetColorChartLine(color Color_Chart_Line) { ChartSetInteger(0,CHART_COLOR_CHART_LINE,Color_Chart_Line); } 
//-------------------------------------------------------------------------------------- 公牛蜡烛的主体颜色 
    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); }
//-------------------------------------------------------------------------------------- 熊蜡烛的主体颜色 
    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); }   
//----------------------------------------------------------------------------------- 公牛蜡烛图的主体颜色 
    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); }     
//----------------------------------------------------------------------------------- 公牛蜡烛图的主体颜色 
    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); }      
//+------------------------------------------------------------------+
//| 自定义指示器初始化函数
//+------------------------------------------------------------------+
int OnInit()
  {
//--- 指示器缓冲区映射
   
//---
   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[])
  {
//---
   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);
//--- 为下一次调用返回 prev_calculated 的值
   return(rates_total);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| 自定义指标去初始化函数
//+------------------------------------------------------------------+ 
void OnDeinit(const int reason)
  {
   Comment("");
//----
//----
  }
//+----------------------------------

他写了这个:

//+------------------------------------------------------------------------------+
//|烛光颜色
//+------------------------------------------------------------------------------+              
#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); 
  }
//+------------------------------------------------------------------+

并发给了我;

这不是我所期望的;

因此,当我 通过电话 与 "kourosh1347 " 谈论此事时

之后,我分享了它,对它进行了修改:(如何帮助?)

它没有名字;

来自:( 你好;一个关于在 mql5 中定义时间的问题。

in this code:

but still has problem ; can you please check it

//+------------------------------------------------------------------------------+ 
#property indicator_chart_window              
#property  version "1.0"                                   

我告诉他(在信息中):

这有问题,当:(

Day_Start=6;  and  Day_End=6

(我的经纪人从 22:00 到 24:00 工作了 6 天)。


指标:改变蜡烛的颜色

是属于 "kourosh1347 " 的。

在写这篇文章之前,我给 "kourosh1347 " 发了信息

阅读 :

hi; a question about time define in mql5 .

&

指标:改变蜡烛的颜色

&

我还向他的手机发送了短信

 
Automated-Trading:

改变蜡烛的颜色

作者:Kourosh Davallou


怎样才能只让最后一根蜡烛改变颜色?而其他蜡烛的颜色保持不变?
附加的文件: