NexusFi: Find Your Edge


Home Menu

 





Dynamic Array Population Error


Discussion in TradeStation

Updated
    1. trending_up 2,369 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Dynamic Array Population Error

  #1 (permalink)
EatLiftTrade
san diego
 
Posts: 2 since Mar 2020
Thanks Given: 0
Thanks Received: 0

I'm trying to run the following code and run into an error shown on the Events Log of :

Quoting 
elsystem.UserException: Dynamic array index is out of bounds: index 1 size: 1

I'm not sure what I'm doing wrong but I am new to using arrays.

My code is below.

Essentially I'm trying to have an empty dynamic array named Pvt_ArrayH that is populated by Pivot() function's output of oPivotPriceH which i've made equal to Value 5. I don't have any errors in the TS Development Environment. I'm using this on a @MES daily candles chart.

 
Code
Vars: oPivotPriceL(0), oPivotBarL(0), oPivotPriceH(0), oPivotBarH(0), Counter(0);

Arrays: Pvt_ArrayH[](0);

//Pivot High (based on C)	
Value4 = Pivot(C, 4, 3, 3, 1, 1, oPivotPriceH, oPivotBarH);
Value5 = oPivotPriceH;
Value6 = oPivotBarH;

Counter = Counter + 1;
Pvt_ArrayH[Counter] = Value5;

Print(Pvt_ArrayH);

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Build trailing stop for micro index(s)
Psychology and Money Management
Better Renko Gaps
The Elite Circle
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

EatLiftTrade,

welcome to futures.io.

You will need to set the size of your dynamic array before you can store values in it.

The help file within the TDE has a section for arrays and the part about dynamic arrays should be helpful for you.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #3 (permalink)
EatLiftTrade
san diego
 
Posts: 2 since Mar 2020
Thanks Given: 0
Thanks Received: 0


I found what you mean ABCTG, I've done the following to adjust for size, see below.

I don't run into any errors; however, i'm not sure why it only prints 1.0. Given that Value5 is oPivotPriceH, I was expecting that the array was storing the price values which should be -1 and the price of the pivot when it occurs.

Thanks

 
Code
Vars: oPivotPriceL(0), oPivotBarL(0), oPivotPriceH(0), oPivotBarH(0), Counter(0);

Arrays: double Pvt_ArrayH[](0);
Clearprintlog;

//Pivot High (based on C)	
Value4 = Pivot(C, 4, 3, 3, 1, 1, oPivotPriceH, oPivotBarH);
Value5 = oPivotPriceH;
Value6 = oPivotBarH;

Counter = Counter + 1;
Array_setmaxindex(Pvt_ArrayH, Counter);
Pvt_ArrayH[Counter] = Value5;


Print(Pvt_ArrayH);

Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

EatLiftTrade,

you are not printing any index of the array. Something along the lines of "Print(Pvt_ArrayH[Counter])" might be what you have in mind.

Regards,

ABCTG


EatLiftTrade View Post
I found what you mean ABCTG, I've done the following to adjust for size, see below.

I don't run into any errors; however, i'm not sure why it only prints 1.0. Given that Value5 is oPivotPriceH, I was expecting that the array was storing the price values which should be -1 and the price of the pivot when it occurs.

Thanks

 
Code
Vars: oPivotPriceL(0), oPivotBarL(0), oPivotPriceH(0), oPivotBarH(0), Counter(0);

Arrays: double Pvt_ArrayH[](0);
Clearprintlog;

//Pivot High (based on C)	
Value4 = Pivot(C, 4, 3, 3, 1, 1, oPivotPriceH, oPivotBarH);
Value5 = oPivotPriceH;
Value6 = oPivotBarH;

Counter = Counter + 1;
Array_setmaxindex(Pvt_ArrayH, Counter);
Pvt_ArrayH[Counter] = Value5;


Print(Pvt_ArrayH);


Follow me on Twitter Reply With Quote




Last Updated on November 23, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts