Functions or Variables to Return a value based on certain parameters - page 2

 

Knave Just doing some looking at the set index buffers i think i might have found it.

It is to do with the lang used.

 

Just tried this Amend the Int init () to this which is what im seeing as the "new" code style for the init commands and has popped up in my data window

void OnInit(void)
{
  
  SetIndexBuffer(0,f_1);
  SetIndexBuffer(1,f_2);
  SetIndexBuffer(2,f_3);
  SetIndexBuffer(3,f_4);
  SetIndexBuffer(4,f_5);
  SetIndexBuffer(5,f_6);
  SetIndexBuffer(6,f_7);
  SetIndexBuffer(7,f_8);
  SetIndexLabel(0,"Fibo_"+DoubleToStr(Fibo_Level_0,4));
  SetIndexLabel(1,"Fibo_"+DoubleToStr(Fibo_Level_1,4));
  SetIndexLabel(2,"Fibo_"+DoubleToStr(Fibo_Level_2,4));
  SetIndexLabel(3,"Fibo_"+DoubleToStr(Fibo_Level_3,4));
  SetIndexLabel(4,"Fibo_"+DoubleToStr(Fibo_Level_4,4));
  SetIndexLabel(5,"Fibo_"+DoubleToStr(Fibo_Level_5,4));
  SetIndexLabel(6,"Fibo_"+DoubleToStr(Fibo_Level_6,4));
  SetIndexLabel(7,"Fibo_"+DoubleToStr(Fibo_Level_7,4));
  
}


 

values
 

So have you got it working?

This is an indicator, so you'll want to be using:

OnInit() not init()

OnDeinit() not deinit()

OnCalculate() not start() 

#property strict
#property indicator_chart_window

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {

   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  
  }

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

   return(rates_total);
  }

This page may help - https://docs.mql4.com/basis/function/events

You should also specify the number of indicator buffers at the top:

#property indicator_buffers 8 
Event Handling Functions - Functions - Language Basics - MQL4 Reference
Event Handling Functions - Functions - Language Basics - MQL4 Reference
  • docs.mql4.com
Event Handling Functions - Functions - Language Basics - MQL4 Reference
 

Hi Knave,

 

thanks for the help mate, yea fixed it. Had to change some bits for example the original code never deleted the lines and now does must just be written in old code.

 

all working now so if anyone wants to use it here it is! 

 
Glad you got it sorted