インディケータ: ローソク足の色の変化

 

ローソク足の色の変化:

ローソク足の色を変更することができる指標。

作者: Kourosh Davallou

 
kourosh1347さん あなたのコードは、TIMisthebestさんのフォーラム(https://www.mql5.com/en/forum/9142#comment_382841) のコードと似ていますか?
 
phi.nuts:
kourosh1347さん あなたのコードは、TIMisthebestさんのフォーラム(https://www.mql5.com/en/forum/9142#comment_382841) のコードと似ていますか?

こんにちは;

いいえ、kourosh 1347が最初のバージョンを書きました;

について彼に尋ねたとき、彼はこう書いた;

 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://mql5.commql5.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

(私のブローカーはday=6で22:00から24:00まで働いています。)

そして

インジケータ:ローソク足の色を変える

は "kourosh1347 " さんのものです。

これを書く前に、"kourosh1347 " にメッセージを送りました

を読んでください:

mql5 の時間定義についての質問です。

&

インジケータ:ローソク足の色の変更

&

また、私は彼の携帯電話にSMSを送信する

 

どうすれば最後のロウソクだけ色を変えることができますか?残りのキャンドルは同じ色のままですか?