is there a way to change this filter to moving average cross ?

 

Hi, how to change this code to moving average setup? want to add 2-3 EMA with changeable value..


extern string SignalSetting = "---------- Signal Setting ----------";

extern ENUM_APPLIED_PRICE ApplyTo = PRICE_CLOSE;
extern string Setting_ = "----------- Stochastic -----------";
extern int Kperiod = 25;
extern int Dperiod = 3;
extern int Slowing = 5;
extern ENUM_MA_METHOD MA_Stoc = MODE_SMA;
extern ENUM_STO_PRICE Price_Field = STO_CLOSECLOSE;
extern string Stoc_Level = "--- Stoch Level ---";
extern int Upper_level = 80;
extern int Lower_level = 20;
void SetupTrade()
{

double StocFast = iStochastic(Symbol(), Period(), Kperiod, Dperiod, Slowing, MA_Stoc, Price_Field, 0, 1);
double StocSlow = iStochastic(Symbol(), Period(), Kperiod, Dperiod, Slowing, MA_Stoc, Price_Field, 1, 1);

bool buy = StocFast < Lower_level && StocSlow < Lower_level;
bool sell = StocFast > Upper_level && StocSlow > Upper_level;


datetime candleTime = iTime(Symbol(),Period(),0); static datetime timeTrade;
bool trade = Hour() >= StartHour && Hour() <= EndHour;
bool trade2 = true;
int candlebaru = iClose(Symbol(),Period(),0);
{
if(trade && trade2 && candleTime)
{
if(buy && TradeBuy && TotalOrder(OP_BUY)==0)
{
Order(OP_BUY,Commentt);
trail_mode = 0;
timeTrade = candleTime;
}
if(sell && TradeSell && TotalOrder(OP_SELL)==0)
{
Order(OP_SELL,Commentt);
trail_mode = 0;
timeTrade = candleTime;
}

}
}
}
Moving Average - Trend Indicators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
Moving Average - Trend Indicators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
The Moving Average Technical Indicator shows the mean instrument price value for a certain period of time. When one calculates the moving average...