Download MetaTrader 5

Some help with arrays needed

To add comments, please log in or register
Toast
226
Toast  

Hello,

I'm struggling to get my head around the following:


#property indicator_buffers 5

double Buff1[];

// ---

int init()

SetIndexBuffer(4, Buff1);

// ---

int start()

CVF()

// ---

void CVF()

double Var1 = 1.33;

Buff1[i] = Var1;

Print("Debug " + Var1 + " - " + Buff[i] + " - " + i);

This will return something like:

Debug 1.33 - 0 - 197

So why isn't Buff[i] taking the value of Var1?

Any pointers greatly appreciated!

Alain Verleyen
Moderator
32809
Alain Verleyen  
toast:

Hello,

I'm struggling to get my head around the following:


This will return something like:

So why isn't Buff[i] taking the value of Var1?

Any pointers greatly appreciated!

void CVF()

double Var1 = 1.33;

Buff1[i] = Var1;

Print("Debug " + Var1 + " - " + Buff[i] + " - " + i);
whroeder1
15706
whroeder1  
int init()

SetIndexBuffer(4, Buff1);
Start with getting your code to compile. ^ that won't.
Toast
226
Toast  
angevoyageur:



Sorry, a typo in what I posted on here. They match in the code (and compile without error; there is no array called Buff[])
Alain Verleyen
Moderator
32809
Alain Verleyen  
toast:

Sorry, a typo in what I posted on here. They match in the code (and compile without error; there is no array called Buff[])
Follow WHRoeder advice, please post code that compiles if you need help.
Toast
226
Toast  
WHRoeder:
Start with getting your code to compile. ^ that won't.


It compiles without error or warning (on both old build and new build). There is nearly 1000 lines of code, so I've snipped the relevant parts for simplicity which may be causing confusion. I was merely trying to indicate which sections the various bits came from.


Toast
226
Toast  
toast:


It compiles without error or warning (on both old build and new build). There is nearly 1000 lines of code, so I've snipped the relevant parts for simplicity which may be causing confusion. I was merely trying to indicate which sections the various bits came from.




My stupid mistake.. overlooked increasing the IndicatorBuffers from earlier on.

But it didn't throw up any compile errors. Odd!

Thanks anyway.

To add comments, please log in or register