Download MetaTrader 5
To add comments, please log in or register
Do you know that MQL5 is an object-oriented language?
MikeT
232
MikeT 2016.09.06 18:15 

Hi Guys

I'm trying to create a Histogram based on the previous High/Low values of a :ZigZag" type of indicator called Swing_ZZ.mq4... But I'm just not getting it right.... If someone could point me in the right direction here I'd appreciate it... 

Thanx 

This is the jist of the Swing_ZZ indi: 

//+------------------------------------------------------------------+
//|                                                     Swing_ZZ.mq4 |
//+------------------------------------------------------------------+
#property copyright "onix"
#property link      "http://onix-trade.net/forum/index.php?s=&showtopic=118&view=findpost&p=131476"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_color3 Blue

//---- indicator parameters
extern int    minBars = 3; 

//---- indicator buffers
double zzL[];
double zzH[];
double zz[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
 //  IndicatorBuffers(3);
//---- drawing settings
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexStyle(0,DRAW_SECTION);
   SetIndexArrow(2,159);
   SetIndexArrow(1,159);
//---- indicator buffers mapping
   SetIndexBuffer(0,zz);
   SetIndexBuffer(1,zzH);
   SetIndexBuffer(2,zzL);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);

 

And this is my attempt to read the High/lows...

#property indicator_buffers 3
#property indicator_color1 DarkGreen
#property indicator_color1 Maroon
//
extern   int History = 100;

string    indName="Rhythm_Swing_ZZ_Histogram";
string mycomment;
//---- buffers
double Swing[];
double Bottoms[];
double Tops[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators setup
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexBuffer(0,Tops);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexBuffer(1,Bottoms);
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
SetIndexLabel(0,NULL);
SetIndexLabel(1,NULL);

   return(0);
  } 
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
  Comment("");
  return(0);
  }

  //--------------------------------------------------------------------
int start()                         
  {
  for(int i=History-1;i>=0;i--)
  {
    Swing[i]=iCustom(Symbol(),0,"Swing_ZZ",3,0,i);

    if(Swing[i]>0.1 && Low[i]==Swing[i]) Bottoms[i]=Swing[i];
    if(Swing[i]>0.1 && High[i]==Swing[i]) Tops[i]=Swing[i];
  }
  
// I'm just putting comments in for now to read the last Swing High
// and Low... I'd be happy to just have this result but I'm getting Nada...
// Where am I going wrong here...?
mycomment=StringConcatenate("\n"
      ,"\nTops = ",Tops[0]
      ,"\nBottoms = ",Bottoms[0]
      ,"\n");
Comment(mycomment);

//--------------------------------------------------------------------
   return(0);                          
  }
//--------------------------------------------------------------------

 Any idea's.....?

/
To add comments, please log in or register