Posted By: tomaslolo
How to code this for() condition? - 08/28/19 10:52
Hi all, I´m bad coding, I try many things and fail, but keep learning. I have a condition I´m triying to code and I ask for help:.
If (priceClose(0)>SMA(200)) during the last 100 bars. How can I code It?
Do I have to write 100 times the condition?
Because if I code this;
I guess enters Long if the condition is met any time during last 100 bars, and I want to enterLong only if the whole last 100 priceClose are above SMA(200).
Any clues?
Thank you very much
If (priceClose(0)>SMA(200)) during the last 100 bars. How can I code It?
Do I have to write 100 times the condition?
Code
vars priceC=series(priceClose()); vars mySMA200=series(SMA(priceC,200)); if(priceC[0]>mySMA200[0] and priceC[1]>mySMA200[1] and priceC[2]>mySMA200[2] ..... and priceC[100]>mySMA200[100]) enterLong()
Because if I code this;
Code
int i; for(i=0;i<100;i++) if (priceC[i]>mySMA200[i]) enterLong();
I guess enters Long if the condition is met any time during last 100 bars, and I want to enterLong only if the whole last 100 priceClose are above SMA(200).
Any clues?
Thank you very much