Questions from Beginners MQL4 MT4 MetaTrader 4 - page 114
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Good afternoon ! How can I create a trigger ? For example I need this condition if(iClose(NULL,HTF,4)<BlueLine) if it is executed DayDown = 1 ! Q: How can DayDown be left as 1 and not polled until the next day ?
I have other objects attached to 1 object, and when you delete this object, the rest just hang on the chart
I've got it like this:
if(DayNext!= Day()) // If a new day, you have to poll
{
// Polling
if(iClose(NULL,1440,2)<BlueLine)
if(iOpen(NULL,1440,1)<BlueLine && iClose(NULL,HTF,1)>BlueLine)
PROBOI1 = 1;Print("Closed above BlueLine = ",iClose(NULL,HTF,1));
if(iClose(NULL,1440,2)>RedLine)
if(iOpen(NULL,1440,1)>RedLine && iClose(NULL,HTF,1)<RedLine)
PROBOI1 = -1;Print("Closed below RedLine = ",iClose(NULL,HTF,1));
DayNext = Day(); // Remember the day
}
Correct if something is wrong! Further, if I want to track what's happening now on a lower TF do I need to write Day outside the Survey? Right -STARIJ:
if(iClose(NULL,60,1)>RedLine&&iClose(NULL,1440,2)>RedLine) ) Sell = 1
https://www.mql5.com/ru/forum/226620#comment_6481536
Set magic number +1 for condition 1, magic number +2 for condition 2 and so on. That way you can then see if this position has been opened with condition 1 or with condition 2...
Afternoon. I have only succeeded for one position BAY. The magik set for sell does not work for some reason. Everything is absolutely identical, except for the magik itself of course. What have I done wrong?
What have I done wrong?
I apologize for not finding the beginning of the correspondence, but I would like to immediately advise you to avoid complex conditions and calculations in them - this makes the code unreadable and therefore complicates the search for logical errors, I would write your code like this:
If you understand what I mean, you can modify the code I gave you a little more, I mean to put it in a separate conditionif(OrderType()==OP_BUY....
Then it will be much easier to find logical errors, imho
I apologize for not finding the beginning of the correspondence, but I would like to immediately advise to avoid complex conditions and calculations in them - this makes the code unreadable and as a consequence complicates the search for logical errors, I would write your code like this:
If you understand what I mean, you can modify the code I gave you a little more, I mean to put it in a separate conditionif(OrderType()==OP_BUY....
Then it will be much easier to find logical errors, imho
Understood, thanks, but as far as I understand there is no difference for understanding of the code by the platform, while for me, breaking one condition into several shorter ones seems to be more complicated in searching for errors because the number of occurrences of statements inside each other increases. But maybe you're right and I'll come over to your side soon. Regarding code logic - I haven't found any difference between mine and yours and still don't see the error.
Regarding code logic - I found no difference between mine and yours and I still don't see the error.
Exactly so - the logic of the code is the same, but if you split the conditions, it is faster to find where the logical error is, and in your case, if you take it out:
into a separate condition, we get code optimization - the condition will be checked once instead of 4 times like in your example.
Check the output in the Expert Advisor's journal using the
Print()
for logging to see which code fragment is executed and with what parameters
Guys,
How do I read the Morning Flat indicator in the Expert Advisor code?
I'm trying it this way and it doesn't work.
The indicator itself