Why not . . .
int g=1; while(g <= 48) { if(High[g] < iMA(NULL,0,20,0,0,0,g)) ObjectCreate(StringConcatenate("SMA_Line_", g),OBJ_HLINE, 0, Time[0], High[g]); g++; }
. . . or similar ?
RaptorUK:
Why not . . .
. . . or similar ?
Of course this it is! Simply solution of include the increment to condition for array to loop! You are clever many time! Thank you!
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,
I have thinking mistake: I wanted to make code to check if within last 48 bars has been there a high price that is above its corresponding moving average. Because I beliefed that within this period time highest price automatically meaned also above moving average of that bar. But some time highest price was not above moving average and some time has been high price above moving average but it is not highest of the most total within 48 bars. So I have been thinked about a way to remember every high price within last 48 bars and make condition to get only that bars who make above moving average. So all this look like this:
You saw that I have reducing code above to only 4 variables because 48 time variable is too big. My questions to you are two: First number: Is this good code? Second number: There is more intelligent alternative for this so not so many variables to write? I just thinked to you to forget question number first. Code I know is bad. But is better way exist to code this problem?