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
Hi all,
I'm trying to get alert once 20SMA and 50SMA meet or crossover each other
and I modified existing code and applied it. I can get a "BUY" alert correctly, but "SELL" alert is not working.
I attached current my code here. Could you anyone help me why "SELL" alert is not triggered?
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit=Bars-counted_bars;
if (limit<0) limit=0;
// define MAs values
for (int i=limit; i>=0; i--)
{
Fast[i]=iMA(NULL, 0, Fast_MA_Period, Fast_MA_Shift, Fast_MA_Method, Fast_MA_Apply, i);
Slow[i]=iMA(NULL, 0, Slow_MA_Period, Slow_MA_Shift, Slow_MA_Method, Slow_MA_Apply, i);
}
// Alert
{
// buy alert
if ((New_Candle() && Fast[0] > Slow[0] && Fast[1] <= Slow[1]))
{
if (ScreenAlert) Alert("BUY - "+Symbol()," | ",TimeToStr(CurTime(),TIME_DATE)," | ",TimeHour(CurTime()),":",TimeMinute(CurTime())," | Period=",Period());
if (PushAlert) SendNotification("BUY -"+Symbol());
}
// sell alert
if ((New_Candle() && Fast[0] < Slow[0] && Fast[1] >= Slow[1]))
{
if (ScreenAlert) Alert("SELL - "+Symbol()," | ",TimeToStr(CurTime(),TIME_DATE)," | ",TimeHour(CurTime()),":",TimeMinute(CurTime())," | Period=",Period());
if (PushAlert) SendNotification("SELL - "+Symbol());
}
}
return(0);
}