Help with data from custom indicator

 
int eurusd;
  int gbpjpy;
  int usdcad;
  int usdchf;
  int audusd;
  int audcad;
  int gold;
  int ger40;
  int us30;
int OnInit()
  {
  int eurusd=iCustom("EURUSD#",PERIOD_M1,"iSpy");
  int gbpjpy=iCustom("GBPJPY#",PERIOD_M1,"iSpy");
  int usdcad=iCustom("USDCAD#",PERIOD_M1,"iSpy");
  int usdchf=iCustom("USDCHF#",PERIOD_M1,"iSpy");
  int audusd=iCustom("AUDUSD#",PERIOD_M1,"iSpy");
  int audcad=iCustom("AUDCAD#",PERIOD_M1,"iSpy");
  int gold=iCustom("GOLD#",PERIOD_M1,"iSpy");
  int ger40=iCustom("GER40Cash",PERIOD_M1,"iSpy");
  int us30=iCustom("US30Cash",PERIOD_M1,"iSpy");
  
  if(eurusd == INVALID_HANDLE) 
  
      {
      Print("Error in setting of spy on EURUSD#"); return(true);
      }
      
   if(gbpjpy == INVALID_HANDLE) 
   
      { 
      Print("Error in setting of spy on GBPJPY#"); return(true);
      }
      
   if(usdcad == INVALID_HANDLE) 
      { Print("Error in setting of spy on USDCAD#"); return(true);}
      
   if(usdchf == INVALID_HANDLE) 
      { Print("Error in setting of spy on USDCHF#"); return(true);}
      
   if(audusd == INVALID_HANDLE) 
      { Print("Error in setting of spy on AUDUSD#"); return(true);}
      
   if(audcad == INVALID_HANDLE) 
      { Print("Error in setting of spy on AUDCAD#"); return(true);}
      
   if(gold == INVALID_HANDLE) 
      { Print("Error in setting of spy on GOLD#"); return(true);}
      
   if(ger40 == INVALID_HANDLE) 
      { Print("Error in setting of spy on GER40Cash"); return(true);}
      
   if(us30 == INVALID_HANDLE) 
      { Print("Error in setting of spy on US30Cash"); return(true);}
   Print("ok");   
  
   //---
   return(0);
  }
  
//+------------------------------------------------------------------+
//| The Standard event handler.                                      |
//| See MQL5 Reference for the details.                              |
//|                                                                  |
//| In this case it is used for decoding of spy messages, sent by    |
//| iSPY Control panel MCM indicator.                                |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,           // event identifier
                  const long&   lparam, // the event flag.
                                       // event flag is a bit mask of ENUM_CHART_EVENT_SYMBOL enumeration.
                  const double& dparam, // price
                  const string& sparam  // symbol 
                 )
  {
   if(true)      
     {
      Print("CHARTEVENT_CUSTOM: " ,CHARTEVENT_CUSTOM, "actuall event id : ", id,"symbol: ", sparam, " price : ",dparam);
     }


  
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   IndicatorRelease(eurusd);
   IndicatorRelease(gbpjpy);
   IndicatorRelease(usdcad);
   IndicatorRelease(usdchf);
   IndicatorRelease(audusd);
   IndicatorRelease(audcad);
   IndicatorRelease(gold);
   IndicatorRelease(ger40);
   IndicatorRelease(us30);
   
  }

there is code of ea , it retrieves tick data with custom indicator

 problem is when turn off ea with manually it continues retrives data  from custom indicator 

it is only stops  when manually remove ea from chart . how do i get the custom indicator to stop when i disable ea 

 i tried IndicatorRelease() func but it doesnt work 

Step on New Rails: Custom Indicators in MQL5
Step on New Rails: Custom Indicators in MQL5
  • www.mql5.com
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
 

Please change your topic subject to something meaningful.

I will not even read a topic just asking for "Help", and I am certainly not the only one.

 
Alain Verleyen #: Please change your topic subject to something meaningful. I will not even read a topic just asking for "Help", and I am certainly not the only one.
I absolutely agree!
 
Alain Verleyen #:

Please change your topic subject to something meaningful.

I will not even read a topic just asking for "Help", and I am certainly not the only one.

it is changed

 
rosen007 #:

it is changed

I changed it, but you should post topics with more meaningful titles to attrach interest from experienced users that may be able to help you.

 
Eleni Anna Branou #:

I changed it, but you should post topics with more meaningful titles to attrach interest from experienced users that may be able to help you.

ı am new at this forum 

 
rosen007 #: ı am new at this forum 
Not quite! Your three previous topics had meaningful subjects, so you were already doing it correctly.
 
Fernando Carreiro #:
Not quite! Your three previous topics had meaningful subjects, so you were already doing it correctly.

mr. are you going to keep pushing just because i did one wrong thing or will you share your opinion about the problem

 
rosen007: there is code of ea , it retrieves tick data with custom indicator problem is when turn off ea with manually it continues retrives data  from custom indicator it is only stops  when manually remove ea from chart . how do i get the custom indicator to stop when i disable ea i tried IndicatorRelease() func but it doesnt work 

You seem to already know the answer, but have not realised it yet.

In your OnDeinit event handler you are releasing the indicator handles. That is your answer.

When you wish to "stop" the indicator, release its handle, during the OnTick() event handling.

EDIT: To help clarify the answer, please explain how exactly you are "turning off" the EA without removing it from the chart.

 
Fernando Carreiro #:

You seem to already know the answer, but have not realised it yet.

In your OnDeinit event handler you are releasing the indicator handles. That is your answer.

When you wish to "stop" the indicator, release its handle.

only stops send events when ea remove from chart but if turn off auto trading it is not working ıcustom still send events 


 
rosen007 #: only stops send events when ea remove from chart but if turn off auto trading it is not working ıcustom still send events 

Then, during the processing of events (OnTick, OnChart, etc.), you should read the current state of the "Algo Trading", and when it is off, you release the indicator handle.

And when it is on again, you will need to reinitialise the indicator handle. The best way, is probably to create a class object for the indicator so that you can initialise and release it on demand via the object's methods.

Here is some sample code to get the state of when trading is allowed or not during various situations ...

bool  bAccountTradeAllowed       = AccountInfoInteger(  ACCOUNT_TRADE_ALLOWED  ),
      bAutomatedTradeAllowed     = AccountInfoInteger(  ACCOUNT_TRADE_EXPERT   ),
      bTerminalTradeAllowed      = TerminalInfoInteger( TERMINAL_TRADE_ALLOWED ),
      bProgramTradeAllowed       = MQLInfoInteger(      MQL_TRADE_ALLOWED      ),
      bAllTradeAllowed           = bAccountTradeAllowed   &&
                                   bAutomatedTradeAllowed &&
                                   bTerminalTradeAllowed  &&
                                   bProgramTradeAllowed;
Reason: