My indicators just alert every 15m because i trade on 15m tf. Could anyone code for me that after the a signal is open, the next one will be open after 1hour.
My indicators just alert every 15m because i trade on 15m tf. Could anyone code for me that after the a signal is open, the next one will be open
after 1hour.
Pls help meeeee
//+------------------------------------------------------------------+//| Indicator: rsi vhunter.mq4 |//+------------------------------------------------------------------+#property version"1.00"#property description""#include <stdlib.mqh>
#include <stderror.mqh>
//--- indicator settings#property indicator_chart_window#property indicator_buffers2#property indicator_type1DRAW_ARROW#property indicator_width11#property indicator_color10xFFAA00#property indicator_label1"Buy"#property indicator_type2DRAW_ARROW#property indicator_width21#property indicator_color20x0000FF#property indicator_label2"Sell"//--- indicator buffersdouble Buffer1[];
double Buffer2[];
datetime time_alert; //used when sending alertexternbool Audible_Alerts = true;
externbool Push_Notifications = true;
double myPoint; //initialized in OnInitvoid myAlert(string type, string message)
{
if(type == "print")
Print(message);
elseif(type == "error")
{
Print(type+" | rsi vhunter @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
}
elseif(type == "order")
{
}
elseif(type == "modify")
{
}
elseif(type == "Vietnguyenduc")
{
Print(type+" | rsi vhunter @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
if(Audible_Alerts) Alert(type+" | rsi vhunter @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
if(Push_Notifications) SendNotification(type+" | rsi vhunter @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
}
}
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit()
{
IndicatorBuffers(2);
SetIndexBuffer(0, Buffer1);
SetIndexEmptyValue(0, EMPTY_VALUE);
SetIndexArrow(0, 241);
SetIndexBuffer(1, Buffer2);
SetIndexEmptyValue(1, EMPTY_VALUE);
SetIndexArrow(1, 242);
//initialize myPoint
myPoint = Point();
if(Digits() == 5 || Digits() == 3)
{
myPoint *= 10;
}
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime& time[],
constdouble& open[],
constdouble& high[],
constdouble& low[],
constdouble& close[],
constlong& tick_volume[],
constlong& volume[],
constint& spread[])
{
int limit = rates_total - prev_calculated;
//--- counting from 0 to rates_totalArraySetAsSeries(Buffer1, true);
ArraySetAsSeries(Buffer2, true);
//--- initial zeroif(prev_calculated < 1)
{
ArrayInitialize(Buffer1, 0);
ArrayInitialize(Buffer2, 0);
}
else
limit++;
//--- main loopfor(int i = limit-1; i >= 0; i--)
{
if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation //Indicator Buffer 1if(iRSI(NULL, PERIOD_M1, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_M1, Time[i])) > 52//Relative Strength Index > fixed value
&& iRSI(NULL, PERIOD_M5, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_M5, Time[i])) > 52//Relative Strength Index > fixed value
&& iRSI(NULL, PERIOD_M15, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_M15, Time[i])) > 52//Relative Strength Index > fixed value
&& iRSI(NULL, PERIOD_M30, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_M30, Time[i])) > 52//Relative Strength Index > fixed value
&& iRSI(NULL, PERIOD_H1, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_H1, Time[i])) > 52//Relative Strength Index > fixed value
&& iRSI(NULL, PERIOD_H4, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_H4, Time[i])) > 52//Relative Strength Index > fixed value
&& iRSI(NULL, PERIOD_D1, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_D1, Time[i])) > 52//Relative Strength Index > fixed value
)
{
Buffer1[i] = Low[i] - iATR(NULL, PERIOD_CURRENT, 14, i); //Set indicator value at Candlestick Low - Average True Rangeif(i == 1 && Time[1] != time_alert) myAlert("indicator", "Buy"); //Alert on next bar open
time_alert = Time[1];
}
else
{
Buffer1[i] = EMPTY_VALUE;
}
//Indicator Buffer 2if(iRSI(NULL, PERIOD_M1, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_M1, Time[i])) < 48//Relative Strength Index < fixed value
&& iRSI(NULL, PERIOD_M5, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_M5, Time[i])) < 48//Relative Strength Index < fixed value
&& iRSI(NULL, PERIOD_M15, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_M15, Time[i])) < 48//Relative Strength Index < fixed value
&& iRSI(NULL, PERIOD_M30, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_M30, Time[i])) < 48//Relative Strength Index < fixed value
&& iRSI(NULL, PERIOD_H1, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_H1, Time[i])) < 48//Relative Strength Index < fixed value
&& iRSI(NULL, PERIOD_H4, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_H4, Time[i])) < 48//Relative Strength Index < fixed value
&& iRSI(NULL, PERIOD_D1, 3, PRICE_CLOSE, iBarShift(Symbol(), PERIOD_D1, Time[i])) < 48//Relative Strength Index < fixed value
)
{
Buffer2[i] = High[i] + iATR(NULL, PERIOD_CURRENT, 14, i); //Set indicator value at Candlestick High + Average True Rangeif(i == 1 && Time[1] != time_alert) myAlert("indicator", "Sell"); //Alert on next bar open
time_alert = Time[1];
}
else
{
Buffer2[i] = EMPTY_VALUE;
}
}
return(rates_total);
}
//+------------------------------------------------------------------+
My indicators just alert every 15m because i trade on 15m tf. Could anyone code for me that after the a signal is open, the next one will be open after 1hour.
Pls help meeeee