Using multi timeframe conditions/ Indicators New comment Mohamed Abdullah 2023.08.22 23:12 Hello all, I want to implement advisor which uses ema50 & ema200 of 30m time frame along with Stochastic oscillator of 1m time frame example: ema50 & ema200 above current price & Stochastic main and signal above 80 how could this be synced together ? here is my code currenty: double iMABuffer200[]; double iMABuffer50[]; double StoMainBuffer1[]; double StoSignalBuffer1[]; double ema50; double ema200; double Sto1; input int BARS_NUM = 50; MqlRates candles30[]; MqlRates candles1[]; bool time_passed = true; int OnInit() { ema50 = iMA(Symbol(), PERIOD_M30, emaPeriod50, 0, MODE_EMA, PRICE_CLOSE); ema200 = iMA(Symbol(), PERIOD_M30, emaPeriod200, 0, MODE_EMA, PRICE_CLOSE); Sto1 = iStochastic(Symbol(),PERIOD_M1,8,3,5,MODE_SMA,STO_LOWHIGH); return(INIT_SUCCEEDED); } bool sto_buy(){ if(StoMainBuffer1[0] > 80 && StoSignalBuffer1[0]> 80) return true; return false; } bool ma_buy() { if(iMABuffer200[0] > candles30[0].close && iMABuffer50[0] > candles30[0].close) return true; return false; } void OnTick() { CopyBuffer( ema200, 0, 1, BARS_NUM, iMABuffer200 ); CopyBuffer( ema50, 0, 1, BARS_NUM, iMABuffer50 ); CopyBuffer( Sto1, 0, 1, BARS_NUM, StoMainBuffer1 ); CopyBuffer( Sto1, 1, 1, BARS_NUM, StoSignalBuffer1 ); CopyRates(_Symbol, PERIOD_M30, 1, BARS_NUM, candles30); CopyRates(_Symbol, PERIOD_M1, 1, BARS_NUM, candles1); if (ma_buy() && sto_buy() && time_passed == true) { Alert("you can buy now"); Print("Candle Close:", candles30[0].close); Print("Candle time:", candles30[0].time); Print("Candle Close:", candles1[0].close); Print("Candle time:", candles1[0].time); Print("======================================"); time_passed = false; EventSetTimer(2); }else{ } } void OnTimer() { time_passed = true; } when I try to run it, it gives false buy alerts. for debugging I checked candles of 30 and 1 , and found that they don't sync in time at all Any help please? Stochastic Oscillator - Oscillators - Technical Indicators - Price Charts, Technical and Fundamental Analysis Stochastic Oscillator - Oscillators - Indicators - Charts - MetaTrader 5 for Android Stochastic Oscillator - Oscillators - Indicators - Chart - MetaTrader 5 for iPhone New comment
Hello all,
I want to implement advisor which uses ema50 & ema200 of 30m time frame
along with Stochastic oscillator of 1m time frame
example:
ema50 & ema200 above current price &
Stochastic main and signal above 80
how could this be synced together ?
here is my code currenty:
when I try to run it, it gives false buy alerts. for debugging I checked candles of 30 and 1 , and found that they don't sync in time at all
Any help please?