i'm still learning, so this may be a very stupid question..bear with me..
So..i always use for's with no big problem, but i only can do so with the usual format (example for(cnt=0;cnt<100;cnt++))..if i only try to throw into the mix another variable i miserably fail..here's an example i a dont know how to write correctly, i've tried multiple ways but it keeps not doing what i want it to do.
int lookback()
{
double cnt_psar = iSAR(NULL,Timeframe,0.02,0.2,cnt+1);
double cntb_psar = iSAR(NULL,Timeframe,0.02,0.2,cnt+2);
double cnt_close = iClose(NULL,Timeframe,cnt+1);
double cntb_close = iClose(NULL,Timeframe,cnt+2);
backchange=100;
for (cnt=0;cnt<backchange;cnt++)
{
if(cnt_psar<cnt_close&&cntb_psar>cntb_close){backchange=cnt;break;}
if(cnt_psar>cnt_close&&cntb_psar<cntb_close){backchange=cnt;break;}
}
}
What i would like this function to do, as u probably understood is to find the last PSAR change in the nearest past and tell me on wich bar that was.
So..i always use for's with no big problem, but i only can do so with the usual format (example for(cnt=0;cnt<100;cnt++))..if i only try to throw into the mix another variable i miserably fail..here's an example i a dont know how to write correctly, i've tried multiple ways but it keeps not doing what i want it to do.
int lookback()
{
double cnt_psar = iSAR(NULL,Timeframe,0.02,0.2,cnt+1);
double cntb_psar = iSAR(NULL,Timeframe,0.02,0.2,cnt+2);
double cnt_close = iClose(NULL,Timeframe,cnt+1);
double cntb_close = iClose(NULL,Timeframe,cnt+2);
backchange=100;
for (cnt=0;cnt<backchange;cnt++)
{
if(cnt_psar<cnt_close&&cntb_psar>cntb_close){backchange=cnt;break;}
if(cnt_psar>cnt_close&&cntb_psar<cntb_close){backchange=cnt;break;}
}
}
What i would like this function to do, as u probably understood is to find the last PSAR change in the nearest past and tell me on wich bar that was.