#property strict // ----- INPUTS ----- input int RSI_Period = 14; input int RSI_Buy_Level = 30; input int RSI_Sell_Level = 70; input int Stoch_K = 5; input int Stoch_D = 3; input int Stoch_Slowing = 3; input int Stoch_Buy_Level = 20; input int Stoch_Sell_Level = 80; input int MA_Period = 50; input int MA_Shift = 0; input int MA_Method = MODE_SMA; // SMA=0, EMA=1, SMMA=2, LWMA=3 int OnInit() { return(INIT_SUCCEEDED); } void OnTick() { // --- GET INDICATOR VALUES --- // RSI Calculation double rsi = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, 0); // Stochastic Calculation double k_value = iStochastic(NULL, 0, Stoch_K, Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_MAIN, 0); double d_value = iStochastic(NULL, 0, Stoch_K, Stoch_D, Stoch_Slowing, MODE_SMA, 0, MODE_SIGNAL, 0); // Moving Average Calculation double ma = iMA(NULL, 0, MA_Period, MA_Shift, MA_Method, PRICE_CLOSE, 0); // --- BUY CONDITION --- if(Close[0] > ma && k_value < Stoch_Buy_Level && k_value > d_value && rsi < RSI_Buy_Level) { Print("BUY Signal Detected at ", TimeToString(TimeCurrent(), TIME_DATE|TIME_MINUTES)); } // --- SELL CONDITION --- if(Close[0] < ma && k_value > Stoch_Sell_Level && k_value < d_value && rsi > RSI_Sell_Level) { Print("SELL Signal Detected at ", TimeToString(TimeCurrent(), TIME_DATE|TIME_MINUTES)); } }