Hi, thanks for your input, I did consider this problem however at this early stage I am only testing the code on the UK100 & NASDAQ both are trading around the 7500 mark.
So if Close[i+1] was 7483.8 and Close[i] was 7481.2
if(Close[i+1]-Close[i]>=2)
Would result in (2.6) or integer 2 which confirms the direction the market is moving and by how much?
Your revision would allow the code to run on any index, which would eventually be needed.
The problem I am trying to resolve is so simple everyone assumes 'it goes without saying...'
If the above IF statement is correct I need to move on to another IF statement and then to another etc. What I dont need is all IF statements completing every tick regardless of any logic path!
For multiple if statements either nest them or use && instead of ||. To only check for a condition on a new bar and not on every tick, add a flag before the loop.(I'm not sure if that is what you meant with the last sentence.)
//---if(rates_total!=prev_calculated)
{
//---int begin=rates_total-prev_calculated+1;
if(prev_calculated==0)
begin=rates_total-3;
for(int i=begin;i>0 && !_StopFlag;i--)
{
if(close[i+1]-close[i+2]>=2*pipToDouble)
if(close[i]-close[i+1]>=4*pipToDouble)
BuyBuffer[i]=low[i];
else
BuyBuffer[i]=0.0;
//---if(close[i+2]-close[i+1]>=2*pipToDouble &&
close[i+1]-close[i] >=4*pipToDouble)
SellBuffer[i]=high[i];
else
SellBuffer[i]=0.0;
}
}
//--- return value of prev_calculated for next callreturn(rates_total);
}
I think nesting is what I was looking for, I need to ask a series of questions and only have an action if all are true. Will need to find out more but cannot find anything useful about flag.
Bostock58: I think nesting is what I was looking for, I need to ask a series of questions and only have an action if all are true. Will need to find out more but cannot find anything useful about flag.
What do you mean by flag? Are you referring to a boolean "bool"?
Fernando Carreiro: What do you mean by flag? Are you referring to a boolean "bool"?
"add a flag before the loop." was a suggestion from Ernst.
I have been trying to find a full explanation for the function of { } type brackets as there is literally nothing in MQL4 Resource about them. I dont know if the have a specific name but its difficult to Google "{ }"
"add a flag before the loop." was a suggestion from Ernst.
I have been trying to find a full explanation for the function of { } type brackets as there is literally nothing in MQL4 Resource about them. I dont know if the have a specific name but its difficult to Google "{ }"
It's called the compound operator. https://www.mql5.com/en/docs/basis/operators/compound
The flag (bool) is this part:
if(rates_total!=prev_calculated)
It will only look for signals on the second and third bars once a new bar is formed, and not on every tick.
Unfortunately the 'compound operator' description only tells me that an 'if' statement is followed by a function in brackets, which I already knew.
I can see how the (rates_total!=prev_calculated) would work I will look to incorporate it, if I ever find a way to add a (true, false) logic path beyond one question.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
This will never be true. The pip value has to be converted to a double.
Only have to alter four lines of the second example I provided.
Hi, thanks for your input, I did consider this problem however at this early stage I am only testing the code on the UK100 & NASDAQ both are trading around the 7500 mark.
So if Close[i+1] was 7483.8 and Close[i] was 7481.2
Would result in (2.6) or integer 2 which confirms the direction the market is moving and by how much?
Your revision would allow the code to run on any index, which would eventually be needed.
The problem I am trying to resolve is so simple everyone assumes 'it goes without saying...'
If the above IF statement is correct I need to move on to another IF statement and then to another etc. What I dont need is all IF statements completing every tick regardless of any logic path!
For multiple if statements either nest them or use && instead of ||. To only check for a condition on a new bar and not on every tick, add a flag before the loop.(I'm not sure if that is what you meant with the last sentence.)
What do you mean by flag? Are you referring to a boolean "bool"?
"add a flag before the loop." was a suggestion from Ernst.
I have been trying to find a full explanation for the function of { } type brackets as there is literally nothing in MQL4 Resource about them. I dont know if the have a specific name but its difficult to Google "{ }"
"add a flag before the loop." was a suggestion from Ernst.
I have been trying to find a full explanation for the function of { } type brackets as there is literally nothing in MQL4 Resource about them. I dont know if the have a specific name but its difficult to Google "{ }"
It's called the compound operator. https://www.mql5.com/en/docs/basis/operators/compound
The flag (bool) is this part:
if(rates_total!=prev_calculated)It will only look for signals on the second and third bars once a new bar is formed, and not on every tick.
Unfortunately the 'compound operator' description only tells me that an 'if' statement is followed by a function in brackets, which I already knew.
I can see how the (rates_total!=prev_calculated) would work I will look to incorporate it, if I ever find a way to add a (true, false) logic path beyond one question.