Use something like
if(iRSI(Symbol(),PERIOD_MN1,RSI_period,RSI_applied_price,0)>50 && iRSI(Symbol(),PERIOD_W1,RSI_period,RSI_applied_price,0)>50 && iRSI(Symbol(),PERIOD_D1,RSI_period,RSI_applied_price,0)>50 && iRSI(Symbol(),PERIOD_H4,RSI_period,RSI_applied_price,0)>50 //etc )
Is that really so simple?
It is part of the whole ea. I think you need to ask someone to code it for you.
https://www.mql5.com/en/job
I tried... the outcome is this, but i have a problem
// External variables extern double LotSize = 0.01; extern double StopLoss = 100; extern double TakeProfit = 100; extern double TrailingStopLimit = 0; extern double TrailingStopStop = 0; extern int MagicNumber = 23310; double var1=iRSI(Symbol(), PERIOD_M15, 10, PRICE_CLOSE,0 ); double var2=iRSI(Symbol(), PERIOD_M30, 10, PRICE_CLOSE,0 ); double var3=iRSI(Symbol(), PERIOD_H1, 10, PRICE_CLOSE,0 ); double var4=iRSI(Symbol(), PERIOD_H4, 10, PRICE_CLOSE,0 ); double var5=iRSI(Symbol(), PERIOD_D1, 10, PRICE_CLOSE,0 ); double var6=iRSI(Symbol(), PERIOD_W1, 10, PRICE_CLOSE,0 ); double var7=iRSI(Symbol(), PERIOD_MN1, 10, PRICE_CLOSE,0 ); // Global variables int LongTicket; int ShortTicket; double RealPoint; // Init function int init() { RealPoint = RealPipPoint(Symbol()); } // Start function int start() { //Variables // Long OrderSelect(LongTicket,SELECT_BY_TICKET); if(OrderCloseTime() != 0 || LongTicket == 0) { bool buy_condition_1 = iRSI(Symbol(), PERIOD_M15, 10, PRICE_CLOSE,0 ) > 50 ; bool buy_condition_2 = iRSI(Symbol(), PERIOD_M30, 10, PRICE_CLOSE,0 ) > 50 ; bool buy_condition_3 = iRSI(Symbol(), PERIOD_H1, 10, PRICE_CLOSE,0 ) > 50 ; bool buy_condition_4 = iRSI(Symbol(), PERIOD_H4, 10, PRICE_CLOSE, 0) > 50 ; bool buy_condition_5 = iRSI(Symbol(), PERIOD_D1, 10, PRICE_CLOSE, 0) > 50 ; bool buy_condition_6 = iRSI(Symbol(), PERIOD_W1, 10, PRICE_CLOSE, 0) > 50 ; bool buy_condition_7 = iRSI(Symbol(), PERIOD_MN1, 10, PRICE_CLOSE, 0) > 50 ; if( buy_condition_1 && buy_condition_2 && buy_condition_3 && buy_condition_4 && buy_condition_5 && buy_condition_6 && buy_condition_7 ) { OrderSelect(ShortTicket,SELECT_BY_TICKET); if(OrderCloseTime() == 0 && ShortTicket > 0) { bool Closed = OrderClose(ShortTicket,OrderLots(),Ask,0,Red); } LongTicket = OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,"Buy Order",MagicNumber,0,Green); Print(var1," ",var2," ",var3," ",var4," ",var5," ",var6," ",var7); OrderSelect(LongTicket,SELECT_BY_TICKET); double OpenPrice = OrderOpenPrice(); if(StopLoss > 0) double LongStopLoss = OpenPrice - (StopLoss * RealPoint); if(TakeProfit > 0) double LongTakeProfit = OpenPrice + (TakeProfit * RealPoint); if(LongStopLoss > 0 || LongTakeProfit > 0) { bool LongMod = OrderModify(LongTicket,OpenPrice,LongStopLoss, LongTakeProfit,0); } ShortTicket = 0; } } return(0); } // Pip Point Function double RealPipPoint(string Currency) { int CalcDigits = MarketInfo(Currency,MODE_DIGITS); if(CalcDigits == 2 || CalcDigits == 3) double CalcPoint = 0.01; else if(CalcDigits == 4 || CalcDigits == 5) CalcPoint = 0.0001; return(CalcPoint); }
Basically it doens't refresh rsi data in the backtest. How do i do to make it work? Anybody willing to help?
Many thanks
2015.01.27 18:27:34.439 2014.05.06 12:47 prova EURUSD,H1: modify #15 buy 0.01 EURUSD at 1.39339 sl: 1.38339 tp: 1.40339 ok 2015.01.27 18:27:34.439 2014.05.06 12:47 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:34.439 2014.05.06 12:47 prova EURUSD,H1: open #15 buy 0.01 EURUSD at 1.39339 ok 2015.01.27 18:27:34.439 2014.05.06 12:47 Tester: take profit #14 at 1.39318 (1.39319 / 1.39339) 2015.01.27 18:27:33.423 2014.04.30 11:20 prova EURUSD,H1: modify #14 buy 0.01 EURUSD at 1.38318 sl: 1.37318 tp: 1.39318 ok 2015.01.27 18:27:33.423 2014.04.30 11:20 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:33.423 2014.04.30 11:20 prova EURUSD,H1: open #14 buy 0.01 EURUSD at 1.38318 ok 2015.01.27 18:27:33.392 2014.04.30 11:00 Tester: stop loss #13 at 1.37792 (1.37788 / 1.37808) 2015.01.27 18:27:29.923 2014.04.10 16:45 prova EURUSD,H1: modify #13 buy 0.01 EURUSD at 1.38792 sl: 1.37792 tp: 1.39792 ok 2015.01.27 18:27:29.923 2014.04.10 16:45 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:29.923 2014.04.10 16:45 prova EURUSD,H1: open #13 buy 0.01 EURUSD at 1.38792 ok 2015.01.27 18:27:29.923 2014.04.10 16:45 Tester: take profit #12 at 1.38772 (1.38772 / 1.38792) 2015.01.27 18:27:28.626 2014.04.08 13:26 prova EURUSD,H1: modify #12 buy 0.01 EURUSD at 1.37772 sl: 1.36772 tp: 1.38772 ok 2015.01.27 18:27:28.626 2014.04.08 13:26 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:28.626 2014.04.08 13:26 prova EURUSD,H1: open #12 buy 0.01 EURUSD at 1.37772 ok 2015.01.27 18:27:26.486 2014.04.03 16:10 Tester: stop loss #11 at 1.37041 (1.37041 / 1.37061) 2015.01.27 18:27:24.798 2014.03.31 13:16 prova EURUSD,H1: modify #11 buy 0.01 EURUSD at 1.38041 sl: 1.37041 tp: 1.39041 ok 2015.01.27 18:27:24.798 2014.03.31 13:16 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:24.798 2014.03.31 13:16 prova EURUSD,H1: open #11 buy 0.01 EURUSD at 1.38041 ok 2015.01.27 18:27:23.705 2014.03.28 09:01 Tester: stop loss #10 at 1.37189 (1.37189 / 1.37209) 2015.01.27 18:27:21.390 2014.03.24 09:00 prova EURUSD,H1: modify #10 buy 0.01 EURUSD at 1.38189 sl: 1.37189 tp: 1.39189 ok 2015.01.27 18:27:21.390 2014.03.24 09:00 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:21.390 2014.03.24 09:00 prova EURUSD,H1: open #10 buy 0.01 EURUSD at 1.38189 ok 2015.01.27 18:27:19.859 2014.03.20 10:25 Tester: stop loss #9 at 1.38002 (1.38002 / 1.38022) 2015.01.27 18:27:15.234 2014.03.07 12:25 prova EURUSD,H1: modify #9 buy 0.01 EURUSD at 1.39002 sl: 1.38002 tp: 1.40002 ok 2015.01.27 18:27:15.234 2014.03.07 12:25 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:15.234 2014.03.07 12:25 prova EURUSD,H1: open #9 buy 0.01 EURUSD at 1.39002 ok 2015.01.27 18:27:15.234 2014.03.07 12:25 Tester: take profit #8 at 1.38979 (1.38982 / 1.39002) 2015.01.27 18:27:13.703 2014.02.28 11:11 prova EURUSD,H1: modify #8 buy 0.01 EURUSD at 1.37979 sl: 1.36979 tp: 1.38979 ok 2015.01.27 18:27:13.703 2014.02.28 11:11 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:13.703 2014.02.28 11:11 prova EURUSD,H1: open #8 buy 0.01 EURUSD at 1.37979 ok 2015.01.27 18:27:13.703 2014.02.28 11:11 Tester: take profit #7 at 1.37959 (1.37959 / 1.37979) 2015.01.27 18:27:10.937 2014.02.14 08:00 prova EURUSD,H1: modify #7 buy 0.01 EURUSD at 1.36959 sl: 1.35959 tp: 1.37959 ok 2015.01.27 18:27:10.937 2014.02.14 08:00 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:10.937 2014.02.14 08:00 prova EURUSD,H1: open #7 buy 0.01 EURUSD at 1.36959 ok 2015.01.27 18:27:10.921 2014.02.14 08:00 Tester: take profit #6 at 1.36936 (1.36939 / 1.36959) 2015.01.27 18:27:09.085 2014.02.06 14:49 prova EURUSD,H1: modify #6 buy 0.01 EURUSD at 1.35936 sl: 1.34936 tp: 1.36936 ok 2015.01.27 18:27:09.085 2014.02.06 14:49 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:09.085 2014.02.06 14:49 prova EURUSD,H1: open #6 buy 0.01 EURUSD at 1.35936 ok 2015.01.27 18:27:04.722 2014.01.30 16:51 Tester: stop loss #5 at 1.35620 (1.35620 / 1.35640) 2015.01.27 18:27:04.316 2014.01.29 15:14 prova EURUSD,H1: modify #5 buy 0.01 EURUSD at 1.36620 sl: 1.35620 tp: 1.37620 ok 2015.01.27 18:27:04.316 2014.01.29 15:14 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:04.316 2014.01.29 15:14 prova EURUSD,H1: open #5 buy 0.01 EURUSD at 1.36620 ok 2015.01.27 18:27:04.253 2014.01.29 14:06 Tester: stop loss #4 at 1.36230 (1.36220 / 1.36240) 2015.01.27 18:27:03.128 2014.01.24 12:27 prova EURUSD,H1: modify #4 buy 0.01 EURUSD at 1.37230 sl: 1.36230 tp: 1.38230 ok 2015.01.27 18:27:03.128 2014.01.24 12:27 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:03.128 2014.01.24 12:27 prova EURUSD,H1: open #4 buy 0.01 EURUSD at 1.37230 ok 2015.01.27 18:27:03.128 2014.01.24 12:27 Tester: take profit #3 at 1.37203 (1.37210 / 1.37230) 2015.01.27 18:27:02.628 2014.01.23 09:28 prova EURUSD,H1: modify #3 buy 0.01 EURUSD at 1.36203 sl: 1.35203 tp: 1.37203 ok 2015.01.27 18:27:02.628 2014.01.23 09:28 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:27:02.628 2014.01.23 09:28 prova EURUSD,H1: open #3 buy 0.01 EURUSD at 1.36203 ok 2015.01.27 18:27:01.112 2014.01.17 16:46 Tester: stop loss #2 at 1.35633 (1.35630 / 1.35650) 2015.01.27 18:26:59.831 2014.01.10 14:34 prova EURUSD,H1: modify #2 buy 0.01 EURUSD at 1.36633 sl: 1.35633 tp: 1.37633 ok 2015.01.27 18:26:59.831 2014.01.10 14:34 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:26:59.831 2014.01.10 14:34 prova EURUSD,H1: open #2 buy 0.01 EURUSD at 1.36633 ok 2015.01.27 18:26:57.310 2014.01.02 13:06 Tester: stop loss #1 at 1.36744 (1.36743 / 1.36763) 2015.01.27 18:26:57.123 2014.01.02 04:12 prova EURUSD,H1: modify #1 buy 0.01 EURUSD at 1.37744 sl: 1.36744 tp: 1.38744 ok 2015.01.27 18:26:57.123 2014.01.02 04:12 prova EURUSD,H1: 31.6712 33.3289 31.3563 48.1589 58.926 62.9229 61.5904 2015.01.27 18:26:57.123 2014.01.02 04:12 prova EURUSD,H1: open #1 buy 0.01 EURUSD at 1.37744 ok
It doesn't refresh because you don't write the code for it to refresh, you print var1, var2 etc, but these are not given new values in the main code.
double var1=iRSI(Symbol(), PERIOD_M15, 10, PRICE_CLOSE,0 ); double var2=iRSI(Symbol(), PERIOD_M30, 10, PRICE_CLOSE,0 ); double var3=iRSI(Symbol(), PERIOD_H1, 10, PRICE_CLOSE,0 ); double var4=iRSI(Symbol(), PERIOD_H4, 10, PRICE_CLOSE,0 ); double var5=iRSI(Symbol(), PERIOD_D1, 10, PRICE_CLOSE,0 ); double var6=iRSI(Symbol(), PERIOD_W1, 10, PRICE_CLOSE,0 ); double var7=iRSI(Symbol(), PERIOD_MN1, 10, PRICE_CLOSE,0 );
from after the Externs and replace
bool buy_condition_1 = iRSI(Symbol(), PERIOD_M15, 10, PRICE_CLOSE,0 ) > 50 ; bool buy_condition_2 = iRSI(Symbol(), PERIOD_M30, 10, PRICE_CLOSE,0 ) > 50 ; bool buy_condition_3 = iRSI(Symbol(), PERIOD_H1, 10, PRICE_CLOSE,0 ) > 50 ; bool buy_condition_4 = iRSI(Symbol(), PERIOD_H4, 10, PRICE_CLOSE, 0) > 50 ; bool buy_condition_5 = iRSI(Symbol(), PERIOD_D1, 10, PRICE_CLOSE, 0) > 50 ; bool buy_condition_6 = iRSI(Symbol(), PERIOD_W1, 10, PRICE_CLOSE, 0) > 50 ; bool buy_condition_7 = iRSI(Symbol(), PERIOD_MN1, 10, PRICE_CLOSE, 0) > 50 ; if( buy_condition_1 && buy_condition_2 && buy_condition_3 && buy_condition_4 && buy_condition_5 && buy_condition_6 && buy_condition_7 ) {
with
double var1=iRSI(Symbol(), PERIOD_M15, 10, PRICE_CLOSE,0 ); double var2=iRSI(Symbol(), PERIOD_M30, 10, PRICE_CLOSE,0 ); double var3=iRSI(Symbol(), PERIOD_H1, 10, PRICE_CLOSE,0 ); double var4=iRSI(Symbol(), PERIOD_H4, 10, PRICE_CLOSE,0 ); double var5=iRSI(Symbol(), PERIOD_D1, 10, PRICE_CLOSE,0 ); double var6=iRSI(Symbol(), PERIOD_W1, 10, PRICE_CLOSE,0 ); double var7=iRSI(Symbol(), PERIOD_MN1, 10, PRICE_CLOSE,0 ); if(var1>50 && var2>50 && var3>50 && var4>50 && var5>50 && var6>50 && var7>50) {
Incidently the indents and gaps in your code do not make it reader-friendly and you will find that many will not be bothered to read it.
Hint: You can often tidy up your code significantly by pressing Ctrl and "," in the Editor.
hello there i,m very new at coding in mql4, please i have written some code but it has failedto comply i,m kindly rquesting for your help and advise please, on what i should do to comply it, please reply kindly if you have an idea thanks once again.
void OnTick() { void Check Forsignal(){ static datetime candletime = 0; if(candletime [0]) { //Did it make an up arrow on candle 1? double upSolid = iCustom(NULL,0,"zigzag-fibo-v2beta",0,ExtDepth,ExtDeviation,ExtBackstep,); if(upSolid !=EMPTY_VALUE) EnterTrade(OP_BUY); //Did it make a down arrow on candle 1? double downSolid = iCustom(NULL,0,"zigzag-fibo-v2beta",0,ExtDepth,ExtDeviation,ExtBackstep,); if(downSolid != EMPTY_VALUE) EnterTrade(OP_SELL); candletime=Time[0]; } }
hello there i,m very new at coding in mql4, please i have writtensome code but it has failedto comply i,m kindly rquesting for your helpand advise please, on what i should do to comply it, please reply kindlyif you have an idea thanks once again.
Please stop double and triple post.
And use the SRC button when you post code. Thank you.
This time, I edited it for you.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone.
I have a problem: i don't know how to code this expert advisor.
It has to open a position when all rsi's timeframes are aligned. I'll explain better. Open buy when 15m to Monthly RSIs are >50 and sell the way around.
Somebody can help me? I'm freaking out on how to code the multi timeframe rsi thing..
Thanks