#property description "Indicator alerts when candle size is larger than CandlePoint value for specified period" #property strict #property indicator_chart_window #property indicator_buffers 0 #property indicator_plots 0 //+------------------------------------------------------------------+ //| Declaring Constants | //+------------------------------------------------------------------+ #define RESET 0 //+------------------------------------------------------------------+ //| Enumeration for the indication of operation | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Input parameters of the indicator | //+------------------------------------------------------------------+ //--- Candle point size input uint CandlePointM1 = 5; // Minimum candle points for Period M1 input uint CandlePointM5 = 5; // Minimum candle points for Period M5 int timeFrame[] = {PERIOD_M1, PERIOD_M5, PERIOD_H1}; string currencyPairs[] = {"AUDCAD", "AUDNZD", "AUDJPY", "AUDUSD"} //+------------------------------------------------------------------+ //| Custom indicator initialisation function | //+------------------------------------------------------------------+ int OnInit() { return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Deinitialisation | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ //| Custom iteration function | //+------------------------------------------------------------------+ 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[]) //+------------------------------------------------------------------+ //| Candle size indicator | //+------------------------------------------------------------------+ { int range; static datetime alertBar[] = {0, 0, 0}; // used for one alert/bar datetime candleTime[3]; for(int i=0; i<3; i++) { for (int j=0 ;j<3 ;j++) { double candleLow, candleHigh; candleLow = iLow(currencyPairs[i],timeFrame[j],0); candleHigh = iHigh(currencyPairs[i],timeFrame[j],0); range = int((candleHigh-candleLow)/_Point); candleTime[j] = iTime(currencyPairs[i],timeFrame[j],0); if (alertBar[j] != candleTime[j]) { if (timeFrame[j] == PERIOD_M1 && range>int(CandlePointM1)) { Alert(currencyPairs[i], "PERIOD_M1", "candle >", CandlePointM1, "points"); alertBar[j] = candleTime[j]; } if (timeFrame[j] == PERIOD_M5 && range>int(CandlePointM5)) { Alert(currencyPairs[i], "PERIOD_M5", "candle >", CandlePointM5, "points"); alertBar[j] = candleTime[j]; } } } }