How do I get a single notification for this indicator? so he sends a notification every second. because?
- indicator with notification
- problem with mql4 indicator and with sendnotification
- '{' - function definition unexpected
Try this:
//+------------------------------------------------------------------+ //+ isNewBar MACD Notification + //+------------------------------------------------------------------+ #property copyright "Copyright 2018, МегаКурец Software Corp." #property indicator_chart_window datetime timeBar; bool isNewBar; 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[]) { if(Time[0]!=timeBar) isNewBar=true; else isNewBar=false; double mc1=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1); double mc2=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1); double mc01=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); double mc02=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0); if(isNewBar) { if(mc1<mc2&&mc01>mc02) SendNotification(Symbol()+" TF:"+IntegerToString(Period())+" "+" buy: "); if(mc1>mc2&&mc01<mc02) SendNotification(Symbol()+" TF:"+IntegerToString(Period())+" "+"short: "); timeBar = Time[0]; } return(rates_total); } //+------------------------------------------------------------------+
kypa:
Try this:
if(Time[0]!=timeBar) isNewBar;
on this line he tells me: expression has no effect. in the same way this code sends me notifications every second
int start(){ isNewBar = (Time[0]!=timeBar); timeBar = Time[0]; return(INIT_SUCCEEDED); } int OnCalculate(const int rates_total,
Use the old init/start or the new OnInit/OnCalculate. You can not use both.
Event Handling Functions - Functions - Language Basics - MQL4 Reference- What do you think if(condition) true; possibly does? Nothing (expression has no effect.)
if(Time[0]!=timeBar) isNewBar=true; else isNewBar=false;
Simplified: isNewBar = Time[0]!=timeBar;
Increase Order after stoploss - MQL4 and MetaTrader 4 - MQL4 programming forum № 3
yes I understand, thank you so much to you two
kypa:
mt5
Try this:
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