I am not sure what you are trying to do with your code.
Doesn't this do what you want?
bool PriceReversingDown(int i=0) { if(ClosePrice(i+1)<EMA(i+1) && ClosePrice(i+2)<EMA(i+2) && ClosePrice(i+3)<EMA(i+3)) return true; return false; }
and it is much simpler.
Keith Watford:
I am not sure what you are trying to do with your code.
Doesn't this do what you want?
and it is much simpler.
I just made it complicated, yes that's what I want to do. thanks for make it simpler
This will make it even simpler by using a loop.
bool PriceReversingDown(int i=0,int numberOfBars=3) { for(int x=1; x<=numberOfBars; x++) if(ClosePrice(i+x)>=EMA(i+x)) //look for condition NOT being satisfied return false; return true; }
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
Hi everyone I want to create a code to check if numbers of bars closing price is below ema line. And this is the code that I came up with.
so in this code I create a variables with name result1, result2 and result3. This variable will store the value from if statement of respective bars. The last thing to do is to check whether the result return the value of 1, if all of it is 1 then it return true, if one of it false then return false.
when I compile this code a warning result showed up with description:
1. expression is not bollean.
2. possible use of uninitialized variable 'result1', 'result2', and 'result3'.
and of course the result of this code is always true. Can anyone help me fix this code?