Hello all,
I'm completely new to this language but have good programming experience, so most of my questions will be regarding the specifics of this language rather than a how-do-you-do-this (I hope I'm smart enough of figuring that out from the examples ;-) ).
So, my first question is:
1) You can have up to 8 indicator buffers linking them to an indicator using the SetIndexBuffer command but can I have more buffers not shown as an indicator but used internally?
2) In a loop going through all the bars, can i use someing like buffer[i+1] == buffer[i] comparing the value for the previous bar (with a 1 higher index) to the current bar I am evaluating?
The first question is not a problem but I'm just wondering if I can use buffer internally without displaying them for evaluation purposes. I know I can not display the buffer and still use it (tried it) but I don't know if I can go over 8 buffers with up to 8 shown on the graph and the rest not.
I find the second question to be my problem since I don't seem to get the proper value. The buffer[i+1] does not seem to work and I seem to get the buffer[i] value.
Thanks for any help.
Yves
buffers are just arrays, so all operations on buffers that pertain to can or can't do is in reference to arrays handling;
for indicators display there is a limit of 8 display buffers, so they are precious assets; treat non display items as arrays;
i try to transfer a custom indicator into ea can anyone tell me how to do the following in ea or what does it mean?
i having problem to understand what both extmapbuffer mean and how to translate them in ea since i cant just icustom (atleast i cant use icustom to get it to work)
for(i=CountBars-SSP;i>=0;i--) { smin = SsMin-(SsMax-SsMin)*Kmin/100; smax = SsMax-(SsMax-SsMin)*Kmax/100; ExtMapBuffer1[i-SSP+6]=smax; ExtMapBuffer2[i-SSP-1]=smax; val1 = ExtMapBuffer1[0]; val2 = ExtMapBuffer2[0]; if (val1 > val2) Comment("镱牦镪?buy ",val1); if (val1 < val2) Comment("镳钿噫?sell ",val2);
i try to transfer a custom indicator into ea can anyone tell me how to do the following in ea or what does it mean?
i having problem to understand what both extmapbuffer mean and how to translate them in ea since i cant just icustom (atleast i cant use icustom to get it to work)
in your EA:
double val1 =
iCustom( | S ymbol(),0, "indicatorname",all your extern values ..., 0, 0 ) |
; //can't give you more precise code without the actual indicator codes
double val2 =
iCustom( | S ymbol(),0, "indicatorname",all your extern values ..., 1, 0 ) |
if (val1> val2) buyoperation;
if (val1<val2) selloperation;
thanx to the reply, the following is the code for the indicator and i also include it in the attachment, does it mean putting that smax into extmapbuffer1 (array : i-ssp+6 ) ?
#property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Blue #property indicator_color2 Red //---- input parameters extern int CountBars=300; extern int SSP=7; extern double Kmin=1.6; extern double Kmax=50.6; //24 21.6 21.6 //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(2); SetIndexStyle(0,DRAW_LINE,0,2,Blue); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_LINE,0,2,Red); SetIndexBuffer(1,ExtMapBuffer2); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { if (CountBars>=Bars) CountBars=Bars; SetIndexDrawBegin(0,Bars-CountBars+SSP); SetIndexDrawBegin(1,Bars-CountBars+SSP); int i, i2,loopbegin,counted_bars=IndicatorCounted(); double SsMax, SsMin, K, val1, val2, smin, smax, price; if(Bars<=SSP+1) return(0); //---- initial zero //K=33-RISK; /* if (firstTime==true) { loopbegin = CountBars; if (loopbegin>(Bars-2*SSP+1)) loopbegin=Bars-2*SSP+1; firstTime=False; }; 痼滂戾眚 耱囵铋 镳钽疣祆? */ if(Bars<=SSP+1) return(0); //---- initial zero //+++++++ if(counted_bars<SSP+1) { for(i=1;i<=SSP;i++) ExtMapBuffer1[CountBars-i]=0.0; for(i=1;i<=SSP;i++) ExtMapBuffer2[CountBars-i]=0.0; } //+++++++-SSP for(i=CountBars-SSP;i>=0;i--) { SsMax = High[Highest(NULL,0,MODE_HIGH,SSP,i-SSP+1)]; SsMin = Low[Lowest(NULL,0,MODE_LOW,SSP,i-SSP+1)]; smin = SsMin-(SsMax-SsMin)*Kmin/100; smax = SsMax-(SsMax-SsMin)*Kmax/100; ExtMapBuffer1[i-SSP+6]=smax; ExtMapBuffer2[i-SSP-1]=smax; val1 = ExtMapBuffer1[0]; val2 = ExtMapBuffer2[0]; if (val1 > val2) Comment("buy ",val1); if (val1 < val2) Comment("sell ",val2);
double v1 = iCustom( Symbol(),0, "a",300,7,1.6,50.6, 0, 1 );
double v2 = iCustom( Symbol(),0, "a",300,7,1.6,50.6, 1, 1 );
I am having similar problems. Except that when I pull the value from my buffer in my ea I get a large numeric value that appears to be a pointer rather than
the value from the buffer.
Here is the relevant code
double b2[]; Declare the array, outside all functions.
SetIndexBuffer(2, b2); I link my array to buffer 2
SetIndexStyle(2, DRAW_NONE); Its a non drawing buffer.
Later in the code
b2[i] = -1; I set the value in the array, i is the number of the bar.
Then I call it with iCustom from the ea, there are 2 externs in the indicator.
flag = iCustom(NULL, 0, "PerkyAsctrend1",4,250,2,0);
and rather than the -1 value I am expecting, I get 2147483647 all the time.
I have done this on other indicators and it works fine. I am stumped here.
I'm having the exact same problem with both PerkyAsctrend1 and another indicator. For one reason or another, all my iCustom commands in my indicator are returning the value of the number of bars in my chart/history (2149483647). I have absolutely no idea why this is happening. When you max out the number of bars in the history and charts in MT4 options (9999999999), it defaults to 2149483647 the next time MT4 is loaded. But why isn't it returning the values for the indicators instead?? I've tried it every which way and everything looks correct. I'll keep testing and see what happens.
Here is the link to the thread I started for it:
https://forum.mql4.com/29431
Please let me know if you have any idea why this is happening.
Thanks.
bney wrote >>
I am having similar problems. Except that when I pull the value from my buffer in my ea I get a large numeric value that appears to be a pointer rather than
the value from the buffer.
Here is the relevant code
double b2[]; Declare the array, outside all functions.
SetIndexBuffer(2, b2); I link my array to buffer 2
SetIndexStyle(2, DRAW_NONE); Its a non drawing buffer.
Later in the code
b2[i] = -1; I set the value in the array, i is the number of the bar.
Then I call it with iCustom from the ea, there are 2 externs in the indicator.
flag = iCustom(NULL, 0, "PerkyAsctrend1",4,250,2,0);
and rather than the -1 value I am expecting, I get 2147483647 all the time.
I have done this on other indicators and it works fine. I am stumped here.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello all,
I'm completely new to this language but have good programming experience, so most of my questions will be regarding the specifics of this language rather than a how-do-you-do-this (I hope I'm smart enough of figuring that out from the examples ;-) ).
So, my first question is:
1) You can have up to 8 indicator buffers linking them to an indicator using the SetIndexBuffer command but can I have more buffers not shown as an indicator but used internally?
2) In a loop going through all the bars, can i use someing like buffer[i+1] == buffer[i] comparing the value for the previous bar (with a 1 higher index) to the current bar I am evaluating?
The first question is not a problem but I'm just wondering if I can use buffer internally without displaying them for evaluation purposes. I know I can not display the buffer and still use it (tried it) but I don't know if I can go over 8 buffers with up to 8 shown on the graph and the rest not.
I find the second question to be my problem since I don't seem to get the proper value. The buffer[i+1] does not seem to work and I seem to get the buffer[i] value.
Thanks for any help.
Yves