Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 135
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 day, if it's not too difficult, please advise a newbie:
1) How to declare an array of size equal to the value of some variable? (If i=7 declare array double Muss[7] and so on);
...
1) ArrayResize()
such a thing:
if you call MarketInfo(Symbol(),MODE_TRADEALLOWED), it returns - 1=trade allowed.
But if you hover over symbol in market overview, tooltip with text - Trade: Close will pop up.
what's the trick here?
it really does not let me trade, but why does MODE_TRADEALLOWED return wrong value?
How many times did you run the indicator? It looks like several times (cyclicality is noticeable in your results).
Add one more print to deinit with some "separator", set input condition or redo it in the script so that it is run no more than once, then it will be clearer.
Great idea))
I made it simpler, like this:
The beginning in the logbook is like this:
There's not even any cycles at all. There is no order. The output is not consistent at all.
Great idea))
I made it simpler, like this:
The beginning in the logbook is like this:
There's not even any cycles at all. There is no order. The output is not consistent at all.
You have made things a bit more complicated, at the test stage everything can be done in 1-2 lines, depending on the variant. It is possible to do everything in the Inite. The order of output has not been stipulated.
You made things a bit more complicated, at the check stage everything can be done in 1-2 lines, depending on variant. It is possible to do everything in the Inite. The order of output was not stipulated.
Do you mean to introduce a flag so that the loops are executed once and that's it? I don't stop executing... That's the way it works:
In essence, though, the code should work as in INITA, once and for all. Then the Boolean variable Status_run will immediately set to false and the if condition won't execute again... But my log doesn't run out of output for some reason.
Do you mean to introduce a flag so that the loops execute once and that's it? I don't stop running... That's the way it works:
Although in essence, the code should work as in INITE, once and that's it. Then the Boolean variable Status_run will immediately set to false and the if condition won't execute again... But I don't run out of output in the log for some reason.
You asserted that the loops gave wrong results and I offered you a way to test it. If it works as you need then you should follow your algorithm, and if not, you should change it during check.
PS "Status_run" must be created before start(), it is a global variable.
Gurus, a word of advice. I set bool variable Flag=true; to start,
I open a deal
if ( condition)
{
Opn_S = true;
Flag=false;
}
There is a question about the flag, if the flag returnsfalse when opened and there is this flag in the open condition. How long is the truth or false passed to the flag kept, is it reset to zero the next day?
Gurus, a word of advice. I set variable bool=true; to start,
I open a deal
if ( condition)
{
Opn_S = true;
Flag=false;
}
There is a question about the flag, if the flag returnsfalse when opened and there is this flag in the open condition. How long is the truth or false passed to the flag kept, will it be reset to zero the next day?
No it won't, with every new tick the value of Flag will be true . https://book.mql4.com/ru/variables/types
Either declare the variable globally - for example at the beginning of a program, outside all functions.
Or make the variable static - static bool flag=true; .
No it won't, with every new tick the value of Flag will be true . https://book.mql4.com/ru/variables/types
Either declare the variable globally - at the beginning of the program, outside all functions.
Or make the variable static - static bool flag=true; .
Perhaps what I understood from your question is different from what you meant. My example compares the opening prices between 3 and 2 bars, and 2 and 1. Bars 3 and 1 are not compared. In case the compared values are equal - nothing happens, just passes to the next comparison.
Why x>1 (not >=). The first iteration compares Open[3]==Open[3-1], i.e. Open[3]==Open[2]. OK. At the second (x=2), Open[2]==Open[1]. OK. There is no third iteration. At x>=1 there will be comparison Open[1]==Open[0], it is not OK, because there will be comparison with 0 bar.
Thank you very much! And if we compare the open and close prices of each of the three bars, would that change the code?