//+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- if(ObjectFind(Sto_Button)< 0) Toggle(); //--- return(INIT_SUCCEEDED); }
.
Hi GumRai,
Thank you for your reply. I test it but it still if i change timeframe the button change from "Sto Aleert ON" to "Sto Aleert ON""Sto Aleert OFF"?
if(Alert_On ==0 ) ObjectSetString(0,Button,OBJPROP_TEXT,"Sto Alert ON"); else ObjectSetString(0,Button,OBJPROP_TEXT,"Sto Alert OFF"); }
The problem that I face is when " I active the alert button and change timeframe the status of the alert button changed to false".
Try these changes
//+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- if(ObjectFind(Sto_Button)< 0) Toggle(); //--- return(INIT_SUCCEEDED); }
//+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- //if(sparam==Sto_Button) Toggle(); if(ObjectGetInteger(0,Sto_Button,OBJPROP_STATE)) { Alert_On = true; ObjectSetString(0,Sto_Button,OBJPROP_TEXT,"Sto Alert ON"); } else { Alert_On = false; ObjectSetString(0,Sto_Button,OBJPROP_TEXT,"Sto Alert OFF"); } //--- }
//+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { if(reason==REASON_REMOVE || reason==REASON_RECOMPILE) ObjectDelete("Button_toggle"); return; }
OnDeinit to replace
//+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int deinit() { ObjectDelete("Button_toggle"); return(0); }
thank you very much
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I'm new to mql4 programing I try my best to learn it.
I did some modification to an alerting to have it as a buttons in the chart window.
The problem that I face is when " I active the alert button and change timeframe the status of the alert button changed to false".