No output and I cannot see the problem. Please help!

To add comments, please log in or register
CobusSteyn0105
37
CobusSteyn0105  

Hi 

I just want to draw a channel line connecting the fractals. But nothing shows up on the chart.

Can someone perhaps point out the bug in my code?

I'm using MetaEditor Ver 5 Build 2143.


Many thanks

#property copyright "Copyright 2019 - Cobus Steyn auxanotrading@gmail.com"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot FCUp
#property indicator_label1  "FCUp"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrMediumSeaGreen
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot FCDown
#property indicator_label2  "FCDown"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrOrangeRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- indicator buffers
double         FCUpBuffer[];
double         FCDownBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,FCUpBuffer);
   SetIndexBuffer(1,FCDownBuffer);
   
  
//---
   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[])
  {
//---
      int begin;
      double fu,fd;
      
      begin = rates_total-1;
      for (int i=begin;i>=0;i--)
      {
         fu=iFractals(NULL,0,MODE_UPPER,i);
         if (fu > 0) FCUpBuffer[i]=High[i];
      }
         
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

I haven't started writing the channel line for the lower fractals yet, since not even the upper channel line is working.

Keith Watford
Moderator
20422
Keith Watford  
CobusSteyn0105:

Hi 

I just want to draw a channel line connecting the fractals. But nothing shows up on the chart.

Can someone perhaps point out the bug in my code?

#property indicator_label1  "FCUp"
#property indicator_type1   DRAW_LINE
#property indicator_label1  "FCUp"
#property indicator_type1   DRAW_SECTION
CobusSteyn0105
37
CobusSteyn0105  
Keith Watford:

Thank you Keith! Didn't expect such a quick reply especially on Sunday.

I didn't even know there was a DRAW_SECTION option...

William Roeder
20214
William Roeder  
CobusSteyn0105: I didn't even know there was a DRAW_SECTION option...
Perhaps you should read the manual. MQL4 Reference → Language Basics → Preprocessor → Drawing Styles - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
To add comments, please log in or register