Array Out Of Range

Post Reply
Radar
Trader
Posts: 437
Joined: Fri Mar 23, 2012 5:39 pm
Location: Round the bend ;)

Array Out Of Range

Post by Radar »

Hey Gang,

I grabbed a few indicators the other day, and even though they work fine in the current version of Empty4, I thought I'd throw the old #property strict in to see what happens.

Well, what happens is it compiles fine, but I end up with Array Out Of Range :(

I've just spent the day trying to find the solution, but just got myself more confuzzled :(

I think it has something to do with counting bars... Then again, I don't code indies all that much, so I could be pulling a hair out of my arm-pit ;)

Could some kind soul point me in the right direction with this? Thanks.

Have fun!

Radar =8^)
You do not have the required permissions to view the files attached to this post.
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
jlcgarcia

Array Out Of Range

Post by jlcgarcia »

Radar » Fri Feb 19, 2016 6:07 pm wrote:Hey Gang,

I grabbed a few indicators the other day, and even though they work fine in the current version of Empty4, I thought I'd throw the old #property strict in to see what happens.

Well, what happens is it compiles fine, but I end up with Array Out Of Range :(

I've just spent the day trying to find the solution, but just got myself more confuzzled :(

I think it has something to do with counting bars... Then again, I don't code indies all that much, so I could be pulling a hair out of my arm-pit ;)

Could some kind soul point me in the right direction with this? Thanks.

Have fun!

Radar =8^)

Hi Radar,

perhaps you could try this:
VSAc MULTY VOLUME HISTOGRAM(easy on cpu) arrayresize.mq4
Regards


José Luis
You do not have the required permissions to view the files attached to this post.
Radar
Trader
Posts: 437
Joined: Fri Mar 23, 2012 5:39 pm
Location: Round the bend ;)

Array Out Of Range

Post by Radar »

Thanks JLC :)

I didn't bother with ArrayResize, because, according to the mql4/5 docs, buffers are supposed to be resized automatically.

Both the original that I uploaded, and your modified one work fine until I add #property strict.

It's just bugging me that I can't find how to rectify it.

Take care,
&
Have fun!
Radar =8^)
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

Array Out Of Range

Post by renexxxx »

Radar,

I have just added #property strict and removed the compiler warnings, but I can not reproduce the Array Out of Index - error. What am I doing wrong? See attached.
You do not have the required permissions to view the files attached to this post.
Radar
Trader
Posts: 437
Joined: Fri Mar 23, 2012 5:39 pm
Location: Round the bend ;)

Array Out Of Range

Post by Radar »

Hey Renexxx,

Thanks for taking a look-see :)

I dropped it on several charts, in 3 separate instances of Empty4, and got the Array out of range error in the Experts log each time :(

I commented out the #property strict, removed 2 declarations of int that the compiler complained about after that, dropped it on a chart, and it worked :( I don't know what's going on here :arrrg:

I can use it as is, but I'd rather make sure that it's compliant now, so that there'll be less to hunt down after the next update to mql4.

Take care,
&
Have fun!
Radar =8^)
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
Lowphat
Trader
Posts: 121
Joined: Fri Jun 27, 2014 12:20 am

Array Out Of Range

Post by Lowphat »

Radar » Fri Feb 19, 2016 11:07 am wrote:Hey Gang,

Well, what happens is it compiles fine, but I end up with Array Out Of Range :(

I've just spent the day trying to find the solution, but just got myself more confuzzled :(

Could some kind soul point me in the right direction with this? Thanks.

Have fun!

Radar =8^)

looking at the log it looks like it don't make it out of init. but it gets an array error beyond init.
im guessing the issue would be the init trying to run a function to an array it hasn't setup yet.

try commenting out the draw_objects in init

Code: Select all

   if (ShowText==True)
   {
      draw_objects();
   }
assuming your file is the same as mine as i already had the file from before and didnt download it from here.
Last edited by Lowphat on Sat Feb 20, 2016 9:45 pm, edited 2 times in total.
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

Array Out Of Range

Post by renexxxx »

Lowphat » Sun Feb 21, 2016 5:17 am wrote:try commenting out the draw_objects in init
Lowphat is right. You can not refer to an index buffer (v4[0]) in OnInit(), as it has not been initialized yet.
Radar
Trader
Posts: 437
Joined: Fri Mar 23, 2012 5:39 pm
Location: Round the bend ;)

Array Out Of Range

Post by Radar »

Bewdiful! :party:

Nice spot, Lowphat :) Thanks!

Thank you, gentlemen, much appreciated.

Take care,
&
Have fun!
Radar =8^)
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
Post Reply

Return to “Coders Hangout”