Why Indicator giving alert after every time candle close? Its should give alert only one time after cross MA

To add comments, please log in or register
mssheik89
50
mssheik89  
//+------------------------------------------------------------------+
//|                                            Price Close Alert.mq4 |
//|                                        Copyright © 2007, SMJones |
//|                                            sjcoinc2000@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, SMJones"
#property link      "sjcoinc2000@yahoo.com"

#property indicator_chart_window

extern int       TimeFrame = 15;
extern int       InputMAval=10;
extern int       InputMAtype=1; // 0 for Simple (SMA), 1 for Exponential (EMA), 2 for Smoothed (SMMA), 3 for LWMA
extern int       InputMAshift=0;
extern int       InputMAprice=6; // 0=close, 1=open, 2=high, 3=low, 4=Median, 5=Typical, 6=Weighted

//extern double  PriceTest = 0.0;

extern bool    AlertAbove  = false,
               AlertBelow  = false,
               EmailAlertAbove,
               EmailAlertBelow;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
      static int AlertPrevTime = 0;
      if (Time[0] <= AlertPrevTime) { 
      return;
      }
      double testclose = iClose(NULL,TimeFrame,1);
      
      // PriceTest adalah nilai dari iMA
      if (InputMAval > 0) double PriceTest = iMA(NULL, 0, InputMAval, InputMAshift, InputMAtype, InputMAprice, 0);
      
      if(testclose>PriceTest && PriceTest!=0)
       {
        if(AlertAbove)Alert(Symbol() + " Price Has Closed Above MA On ", TimeFrame, " Minute Bar");
        if(EmailAlertAbove)SendMail(Symbol() + " Price Close Alert!",Symbol() + " Price Has Closed Above MA On "+TimeFrame+" Minute Bar");
        AlertPrevTime  = Time[0];
       }
         
      if(testclose<PriceTest)
       {
        if(AlertBelow)Alert(Symbol() + " Price Has Close Below MA On ", TimeFrame, " Minute Bar"); 
        if(EmailAlertBelow)SendMail(Symbol() + " Price Close Alert!",Symbol() + " Price Has Closed Below MA On "+TimeFrame+" Minute Bar"); 
        AlertPrevTime  = Time[0];
       }
//----
   return(0);
  }
//+------------------------------------------------------------------+
William Roeder
20233
William Roeder  
mssheik89: Why Indicator giving alert after every time candle close
  1. Move your AlertPrevTime assignment to just below the test/return. New candle has nothing to do with your alert tests succeeding.

  2. You are looking at a signal. Act on a change of signal.
              MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum
mssheik89
50
mssheik89  
whroeder1:
  1. Move your AlertPrevTime assignment to just below the test/return. New candle has nothing to do with your alert tests succeeding.

  2. You are looking at a signal. Act on a change of signal.
              MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum

Can you please do that for me? I know nothing about coding. Please please......

Abi Manyu
293
Abi Manyu  
mssheik89:

Can you please do that for me? I know nothing about coding. Please please......

Cek This bro
its just send alert one time for change signal

Files:
mssheik89
50
mssheik89  
Abi Manyu:

Cek This bro
its just send alert one time for change signal

Thanks bro. You are so nice.....

William Roeder
20233
William Roeder  
mssheik89: Can you please do that for me? I know nothing about coding. Please please......
You have only four choices:
  1. Search for it,
  2. Beg at
    Coding help - MQL4 and MetaTrader 4 - MQL4 programming forum Requests & Ideas (MQL5 only!) - Trade FX - Expert Advisors and Automated Trading - MQL5 programming forum
    Free coding for your trading system.. - Easy Trading Strategy - General - MQL5 programming forum I will code & automate your strategy for free - Options Trading Strategies - General - MQL5 programming forum

  3. learn to code it. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
  4. or pay (Freelance) someone to code it.
We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help
          urgent help.
To add comments, please log in or register