Can't put double into double array? what?

Post Reply
User avatar
aSushiRoll
Trader
Posts: 74
Joined: Fri Apr 05, 2013 10:54 pm

Can't put double into double array? what?

Post by aSushiRoll »

Guys,

I hope you can help me out here. Maybe I've been coding too long today and I just don't see it.... I'm trying to play with the CSS code and create a new indicator from it. ANyway that's besides my question. The thing is:

I have a double array:
double arrTEST[];
this is just copied from the top of the CSS indi:
// indicator buffers
double arrUSD[];
double arrEUR[];
double arrGBP[];
double arrCHF[];
double arrJPY[];
double arrAUD[];
double arrCAD[];
double arrNZD[];
double arrTEST[];
So this is the same as the other arrays.

further in the start() code:
arrTEST = currencyValues[1];
Alert("i is " + i + " arrTest is: " + arrTEST + " currval1: " + currencyValues[1] );

The only thing I'm doing is putting a double value, from currencyValues[1] into arrTEST array. For some reason when I'm displaying the value it says 0 as shown in the screenshot below.

This is turning me completely mental. As far as I can see I"m doing the same thing as in the lines above, the original CSS code, yet when I retreive arrTEST it gives a 0.000000000

and I'm working on the EURGBP chart here so all the EUR & GBP values have been calculated...
It's just that.. I have a double that I can display in an alert. I have a double array, I put the double in the array.. and it's gone.
You do not have the required permissions to view the files attached to this post.
garyfritz

Re: Can't put double into double array? what?

Post by garyfritz »

Did you do an ArrayResize() on arrTEST[] ?

All the other arrUSD[] &etc arrays are indicator buffers. That means Empty4 automatically resizes them every time it adds a candle to the chart.

But arrTEST[] is NOT a buffer. It doesn't get resized automatically -- so it has no elements in it. Hard telling what you're overwriting when you write into it, but you don't have a reliable place to store values in arrTEST[].

If you want arrTEST[] to be the same size as your indicator buffers, you could do something like

ArrayResize(arrTEST, ArraySize(arrUSD));
User avatar
aSushiRoll
Trader
Posts: 74
Joined: Fri Apr 05, 2013 10:54 pm

Re: Can't put double into double array? what?

Post by aSushiRoll »

sorry, in the init() I also set is as an index buffer (and I increased the buffersize in the #property)
currencyColors[0] = Color_USD;
SetIndexBuffer(0, arrUSD);
SetIndexLabel(0, "USD");

currencyColors[1] = Color_EUR;
SetIndexBuffer(1, arrEUR);
SetIndexLabel(1, "EUR");

currencyColors[2] = Color_GBP;
SetIndexBuffer(2, arrGBP);
SetIndexLabel(2, "GBP");

currencyColors[3] = Color_CHF;
SetIndexBuffer(3, arrCHF);
SetIndexLabel(3, "CHF");

currencyColors[4] = Color_JPY;
SetIndexBuffer(4, arrJPY);
SetIndexLabel(4, "JPY");

currencyColors[5] = Color_AUD;
SetIndexBuffer(5, arrAUD);
SetIndexLabel(5, "AUD");

currencyColors[6] = Color_CAD;
SetIndexBuffer(6, arrCAD);
SetIndexLabel(6, "CAD");

currencyColors[7] = Color_NZD;
SetIndexBuffer(7, arrNZD);
SetIndexLabel(7, "NZD");

SetIndexBuffer(8, arrTEST);
SetIndexLabel(8, "TEST");
I figured this would indeed have it behave as the other buffers and so it would work as indicated. So even with this it gave 0.000000 as results.

Any other ideas?

Thanks for your reply btw
garyfritz

Re: Can't put double into double array? what?

Post by garyfritz »

Hm. I assume you meant you increased the indicator_buffers property?

I suspect your problem is that you can only have 8 buffers. 8 is the max value for #property indicator_buffers. It was already 8 -- buffers 0 through 7 -- and I'm guessing it just doesn't work for the 9th buffer. Probably the SetIndexBuffer(8, arrTEST) call failed (returned FALSE), and therefore it didn't automatically resize arrTEST[].
User avatar
aSushiRoll
Trader
Posts: 74
Joined: Fri Apr 05, 2013 10:54 pm

Re: Can't put double into double array? what?

Post by aSushiRoll »

Ah thnx! Willy misstaken, but ti's my first doding attent in mql4 and an error easy overseen. Thnx for THE help.

Sushi
Post Reply

Return to “Coders Hangout”