Nope, you can try using For loops for somethings but for assigning values its not going to make the codes much shorter.
something like
#define BARS 3 #define SHFT 5 int i,shift; double macd[BARS], macd_signal[BARS]; for(i=0,shift=0;i<BARS;i++,shift+=SHFT) { macd[i]=iCustom(NULL,0,"MACD True",0,shift); macd_signal[i]=iCustom(NULL,0,"MACD True",1,shift); } if(macd[0] > macd_signal[0] && macd[1] < macd_signal[1] ...
or
#define BARS 3 #define SIGN 2 #define SHFT 5 int i,j,shift; double macd[BARS,SIGN]; for(i=0,shift=0;i<BARS;i++,shift+=SHFT) { for(j=0;j<SIGN;j++) { macd[i,j]=iCustom(NULL,0,"MACD True",j,shift); } } if(macd[0,0] > macd[0,1] && macd[1,0] < macd[1,1] ...
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
I am trying to find values of an iCustom indicator at different bars back. Is there anyway to get the values by a bar number without making a seperate iCustom lines with each bar number?
For example if I had the below and wanted to find the values of the 10th, 5th, and current bars, would I have to list six iCustom lines with the appropriate shift?
double macd=iCustom(NULL,0,"MACD True",0,0);
double macd_signal=iCustom(NULL,0,"MACD True",1,0);