Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 42

 

Artyom Trishkin:

...Got it right, but from the wrong bar. This has to be known and taken into account.

I.e., in multitime data acquisition, you need to rely on the time, and recalculate it to the bar number at the right timeframe.

Thank you for your clarification.

So, if we call the indicator in the EA like this

ozy_verh=NormalizeDouble(iCustom(NULL, 240, "Ozy", Amplitude, 3, 1), Digits);

and run the EA on H1, the indicator will not read from H4 of the first bar.

What will be the indicator readings then, and how to do it correctly to get the correct readings from the H4?

int TimeFrame = 240;

ozy_verh=NormalizeDouble(iCustom(NULL, TimeFrame, "Ozy", Amplitude,3,iBarShift(Symbol(),TimeFrame,iTime(Symbol(),TimeFrame,1)) ), Digits);


So, will the values of the indicator be correct from H4?



 
mila.com:

Thank you for the clarification.

It turns out that if I call the indicator in the EA like this

ozy_verh=NormalizeDouble(iCustom(NULL, 240, "Ozy", Amplitude, 3, 1), Digits);

and run the EA on H1, the indicator will not read from H4 of the first bar.

What indicator readings do I get then, and how should I do it correctly to get correct readings from the senior t.f.?

int TimeFrame = 240;

ozy_verh=NormalizeDouble(iCustom(NULL, TimeFrame, "Ozy", Amplitude,3,iBarShift(Symbol(),TimeFrame,iTime(Symbol(),TimeFrame,1)) ), Digits);


So, will the values of the indicator be correct from H4?



If you call the indicator the way you wrote:

ozy_verh=NormalizeDouble(iCustom(NULL, 240, "Ozy", Amplitude, 3, 1), Digits);

then the indicator data will be obtained from the current symbol, from PERIOD_H4, from the fourth buffer, and from the first bar on the H4 timeframe.

You must have misunderstood what I was telling you.

Here's what I mean: if the EA is running on M5 and you get data from bar 1 on M5, then if you want to see what is happening on the higher prices, like on H1, then if you get the value from the higher foref H1 also from bar 1, you will not get the current value, which is now on the H1, but the value that was at the last hour. Because bar 1 on M5 is inside bar 0 on H1.

This is what you have to take into account and this is what I was just talking about.

 
Vitaly Muzichenko:

I mean the log in the tester

Added: Assemble the code to its normal state, revise it, then run it in the tester and read the errors in the log. You're giving bits and pieces of code here.

Here. I understand about the checks but don't understand where it's coming from.

Files:
count.mq4  17 kb
 
Artyom Trishkin:

This is what you have to take into account and this is what I was talking about.

If I put the EA on M 5 and want to get the indicator value from H1, from the first bar, then the following entry is correct?

ozy_verh=NormalizeDouble(iCustom(NULL, 60, "Ozy", Amplitude, 3, 1), Digits);
 
mila.com:

If I place the Expert Advisor on M 5 and want to get the indicator value from H1, from the first bar, then the following entry is correct?

ozy_verh=NormalizeDouble(iCustom(NULL, 60, "Ozy", Amplitude, 3, 1), Digits);

No. Instead of 1:

datetime _time1 = iTime(Symbol(), PERIOD_H1, 1);
int      _n     = iBarShift(Symbol(), PERIOD_CURRENT, _time1);
// ваша формула
ozy_verh=NormalizeDouble(iCustom(NULL, 60, "Ozy", Amplitude, 3, _n), Digits);
Only if you use the EA on the server or on your own, but you do not have H1 chart open as well, then you have to do extra checking.
 

Oksana Berenko:

... but you won't have an H1 chart open either, then you have to do extra checking.

Thank you.

I have one M5 chart open, and I have an EA on it that calls the H1 indicator, just like you wrote.

What other checks do I need?

 
mila.com:

If I put the Expert Advisor on M 5 and want to get the indicator value from H1, from the first bar, then the following entry is correct?

ozy_verh=NormalizeDouble(iCustom(NULL, 60, "Ozy", Amplitude, 3, 1), Digits);

Right. It depends on the first bar of what timeframe you need data from...

Looks like you still don't understand what I was saying...

 
Hello, could you please tell me what are the main differences between mt4 and mt5? ?I don't see any major differences.
 

Afternoon ...

if (OrderType()==OP_SELL) CloseOpBuySell("BUY");

if (OrderType()==OP_BUY) CloseOpBuySell("SELL");

here's the condition I need to close a Sell position when I open a Buy position and vice versa, will it trigger?

I am just interested in the left part OrderType()==OP_SELL

the right hand side works when any signal is pushed there

Question: "Will this close work?

 
elektrik777:
Hello, could you please tell me what are the main differences between mt4 and mt5? I don't see any major differences.
The differences are in the programming language for EAs, scripts and indicators, everything else is the same, except MT5 can trade on the stock exchanges, MT4 cannot.