iCustom give a wrong output - page 3

 
angevoyageur:
I can't reproduce this issue. Can you tell us how to reproduce it ?
               I am mentioning that that error is not repeated after a signal is occurred. It only happens at the first tick. After a signal it is not happening.
 
angevoyageur:
I can't reproduce this issue. Can you tell us how to reproduce it ?
I got this error if I don't have the Indicator in the correct folder,  it might help to check that the CopyBuffer() is working . . .
 

Try this version then :

double Buy_Signal[];
double preBuy=0;
double preSell=0;
double Sell_Signal[];
int Stoc_Handler=INVALID_HANDLE;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   Stoc_Handler=iCustom(_Symbol,PERIOD_H1,"Forum\\Stochastic_Cross_Alert_SigOverlayM_cw");
   if(Stoc_Handler==INVALID_HANDLE)
     {
      Print("Invalid handle ",GetLastError());
      return(INIT_FAILED);
     }

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   int iBuy=CopyBuffer(Stoc_Handler,1,1,1,Buy_Signal);
   int iSell=CopyBuffer(Stoc_Handler,0,1,1,Sell_Signal);
   if(iBuy==1 && iSell==1 && Buy_Signal[0]!=Sell_Signal[0] && (Buy_Signal[0]!=preBuy || Sell_Signal[0]!=preSell))
     {
      Print("Buy = ",Buy_Signal[0]);
      preBuy=Buy_Signal[0];
      Print("Sell = ",Sell_Signal[0]);
      preSell=Sell_Signal[0];
     }
  }
//+------------------------------------------------------------------+
  • iCustom must by used in OnInit() and not in OnTick()
  • You have to check returned value of function.
 
angevoyageur:

Try this version then :

  • iCustom must by used in OnInit() and not in OnTick()
  • You have to check returned value of function.
Thank you friend. It works.
 
krishna_gopal_2:
Thank you friend. It works.
Finally
Reason: