PROBLEM with candlesticks plot - page 2

claudio.zeccolella
182
claudio.zeccolella  

Same code different results

Hey Vladimir , I tweaked your code just to explore and learn. Now it's exactly like my previous code but yours work and mine don't. It's the exact copy now. What am I missing ? 

Vladimir Karputov
Moderator
224647
Vladimir Karputov  
claudio.zeccolella :

Hey Vladimir , I tweaked your code just to explore and learn. Now it's exactly like my previous code but yours work and mine don't. It's the exact copy now. What am I missing ? 

I can't read minds. Insert your code using the button Code

claudio.zeccolella
182
claudio.zeccolella  
Vladimir Karputov:

I can't read minds. Insert your code using the button

//+------------------------------------------------------------------+
//|                                                Chart_Candles.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_plots   1
//--- plot Candlesticks
#property indicator_label1  "Candle"
#property indicator_type1   DRAW_COLOR_CANDLES
#property indicator_color1  clrCrimson,clrMediumSeaGreen
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- indicator buffers
double         Candle_Open[];
double         Candle_Close[];
double         Candle_High[];
double         Candle_Low[];
double         Candle_Color[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0, Candle_Open, INDICATOR_DATA);
   SetIndexBuffer(1, Candle_Close, INDICATOR_DATA);
   SetIndexBuffer(2, Candle_High, INDICATOR_DATA);
   SetIndexBuffer(3, Candle_Low, INDICATOR_DATA);
   SetIndexBuffer(4, Candle_Color, INDICATOR_COLOR_INDEX);
 
//---
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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[])
  {
//---

   for(int i=0 ; i < rates_total ; i++)
     {
      Candle_Open[i]  = open[i];
      Candle_High[i]  = high[i];
      Candle_Low[i]   = low[i];
      Candle_Close[i] = close[i];
      if(open[i] > close[i])
        {
         Candle_Color[i] = 1.0;
        }
      else
        {
         Candle_Color[i] = 0.0;
        }
     }

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+ MY CODE 

//+------------------------------------------------------------------+
//|                                           DRAW_COLOR_CANDLES.mq5 |
//|                        Copyright 2011, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property description "An indicator to demonstrate DRAW_COLOR_CANDLES."
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_plots   1
//--- plot ColorCandles
#property indicator_label1  "ColorCandles"
#property indicator_type1   DRAW_COLOR_CANDLES
//--- Define 8 colors for coloring candlesticks (they are stored in the special array)
#property indicator_color1  clrRed,clrBlue,clrGreen
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- input parameters
//---
//--- Indicator buffers
double   BufferOpen[];
double   BufferHigh[];
double   BufferLow[];
double   BufferClose[];
double   BufferColors[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,BufferOpen,INDICATOR_DATA);
   SetIndexBuffer(1,BufferHigh,INDICATOR_DATA);
   SetIndexBuffer(2,BufferLow,INDICATOR_DATA);
   SetIndexBuffer(3,BufferClose,INDICATOR_DATA);
   SetIndexBuffer(4,BufferColors,INDICATOR_COLOR_INDEX);

   
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
 
   for(int i=0; i<rates_total; i++)
     {
      BufferOpen[i]=open[i];
      BufferHigh[i]=high[i];
      BufferLow[i]=low[i];
      BufferClose[i]=close[i];
      if(open[i]>close[i])
         {
         BufferColors[i]=1.0;
         }
      else
         {
         BufferColors[i]=0.0;
         }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+ Vladimir code tweaked

Your tweaked one works like a charm. Mine which is the copy it's not working at all... Tks

Vladimir Karputov
Moderator
224647
Vladimir Karputov  
claudio.zeccolella :

Your tweaked one works like a charm. Mine which is the copy it's not working at all... Tks

Why did you insert TWO SAME CODES?

claudio.zeccolella
182
claudio.zeccolella  
Vladimir Karputov:

Why did you insert TWO SAME CODES?

It's what I'm trying to say...


My code ( the first posted ) and your code now are the same. You previously told me that my code was wrong.

I just opened your code and tweaked it a little bit in order to understand my errors. But there were no errors since the beginning with my original code.

Your tweaked one DRAW_COLOR_CANDLES is fully working while my code(Chart_Candles) which is exactly the same copy it's not working at all as you can see from the picture. 


Did you get it ? :)

Vladimir Karputov
Moderator
224647
Vladimir Karputov  
claudio.zeccolella :

It's what I'm trying to say...


My code ( the first posted ) and your code now are the same. You previously told me that my code was wrong.

I just opened your code and tweaked it a little bit in order to understand my errors. But there were no errors since the beginning with my original code.

Your tweaked one DRAW_COLOR_CANDLES is fully working while my code(Chart_Candles) which is exactly the same copy it's not working at all as you can see from the picture. 


Did you get it ? :)

No, I do not understand you, especially since I do not read the code in the pictures (screenshots). Want to ask a question: ask your question in one post at once. I showed you the working code. Study it and use it.

William Roeder
23727
William Roeder  
Buffers default to as-series. The OnCalculate arrays have no defaults. Set your direction.
claudio.zeccolella
182
claudio.zeccolella  
William Roeder:
Buffers default to as-series. The OnCalculate arrays have no defaults. Set your direction.

Sorry William. It's not a problem of direction. I have LITERALLY hand typed every single letter of the code given by Vladimir. I recorded a video about this. As soon as I run the Vladimir code everything works but as soon as I run my code which is the exact hand typed copy i get the error that you see in the picture. But if I copy and paste ( CTRL + C , CTRL + V ) from the Vlad code everything worked fine. This was happening on the 2690. 

I have uninstalled everything and re-installed the newest 2692 and everything seams to be working fine. I don't know...***