| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Can't put double into double array? what? https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2643 |
Page 1 of 1 |
| Author: | aSushiRoll [ Wed Jul 03, 2013 2:29 pm ] |
| Post subject: | Can't put double into double array? what? |
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 So this is the same as the other arrays. further in the start() code:
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. |
|
| Author: | garyfritz [ Wed Jul 03, 2013 3:31 pm ] |
| Post subject: | Re: Can't put double into double array? what? |
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)); |
|
| Author: | aSushiRoll [ Wed Jul 03, 2013 4:19 pm ] |
| Post subject: | Re: Can't put double into double array? what? |
sorry, in the init() I also set is as an index buffer (and I increased the buffersize in the #property) 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 |
|
| Author: | garyfritz [ Wed Jul 03, 2013 4:29 pm ] |
| Post subject: | Re: Can't put double into double array? what? |
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[]. |
|
| Author: | aSushiRoll [ Wed Jul 03, 2013 5:34 pm ] |
| Post subject: | Re: Can't put double into double array? what? |
Ah thnx! Willy misstaken, but ti's my first doding attent in mql4 and an error easy overseen. Thnx for THE help. Sushi |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|