calculate DT oscillator - page 2

 
Nitin Raj:
Call the indicator handle in OnInit() not in OnTick()

thanks Raj.

can you look to my code and find what's missing?

because it is end up with no value calculated:

double dtosc[];
double dtoss[];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int handle,handleM15;
int OnInit()
  {
   SetIndexBuffer( 0,dtosc ,INDICATOR_DATA);
   SetIndexBuffer( 1,dtoss ,INDICATOR_DATA);
   
   int handle    = iCustom(_Symbol,PERIOD_H1 ,"DTOS",13,8,5,5,true);
   int handleM15 = iCustom(_Symbol,PERIOD_M15,"DTOS",13,8,5,3,true);
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+

double rsibuf[];
double stobuf[];


void OnTick()
  {
   double H1main,H1sign;
   
   
      bool
   BB=false,
   BS=false,
   SB=false,
   SS=false;
   
   double mainM15[]; 
   ArraySetAsSeries(mainM15,true);
   CopyBuffer(handleM15,0,0,3,mainM15);
   double M15main0=mainM15[0];
   Comment(M15main0);
   
  }
 
babigaf:

thanks Raj.

can you look to my code and find what's missing?

because it is end up with no value calculated:

 Don't declare the indicator's handle variable at two places. Use the below code and make sure you are using the correct name of the indicator in iCustom. 

double dtosc[];
double dtoss[];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int handle,handleM15;
int OnInit()
  {
   SetIndexBuffer( 0,dtosc ,INDICATOR_DATA);
   SetIndexBuffer( 1,dtoss ,INDICATOR_DATA);
   
   handle    = iCustom(_Symbol,PERIOD_H1 ,"DTOS",13,8,5,5,true);
   handleM15 = iCustom(_Symbol,PERIOD_M15,"DTOS",13,8,5,3,true);
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+

double rsibuf[];
double stobuf[];


void OnTick()
  {
   double H1main,H1sign;
   
   
      bool
   BB=false,
   BS=false,
   SB=false,
   SS=false;
   
   double mainM15[]; 
   ArraySetAsSeries(mainM15,true);
   CopyBuffer(handleM15,0,0,3,mainM15);
   double M15main0=mainM15[0];
   Comment(M15main0);
   
  }
 
Nitin Raj:

 Don't declare the indicator's handle variable at two places. Use the below code and make sure you are using the correct name of the indicator in iCustom. 

you are awesome Raj ^__^

thanks for your patience and manner.

you helped a lot. you were a great help brotha 

 
int OnInit()
  {
   SetIndexBuffer( 0,dtosc ,INDICATOR_DATA);
   SetIndexBuffer( 1,dtoss ,INDICATOR_DATA);
   
   int handle    = iCustom(_Symbol,PERIOD_H1 ,"DTOS",13,8,5,5,true);
   int handleM15 = iCustom(_Symbol,PERIOD_M15,"DTOS",13,8,5,3,true);
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+

double rsibuf[];
double stobuf[];


void OnTick()

Indicators have buffer, and is called by OnCalculate. EAs/scripts don't have buffers, and are called by OnTick()/OnStart().

You can't mix them. Either you have an indicator, EA or script. Your code is bogus.
          Event Handling Functions - Functions - Language Basics - MQL4 Reference

 
William Roeder:

Indicators have buffer, and is called by OnCalculate. EAs/scripts don't have buffers, and are called by OnTick()/OnStart().

You can't mix them. Either you have an indicator, EA or script. Your code is bogus.
          Event Handling Functions - Functions - Language Basics - MQL4 Reference

yeah. you are right. I am new in writing this stuff and full of questions myself. I would appreciate if you could give me a link that helps me as a starter. thanks

Reason: