NexusFi: Find Your Edge


Home Menu

 





Dynamic array sum


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Fobos with 4 posts (0 thanks)
    2. looks_two ABCTG with 2 posts (1 thanks)
    3. looks_3 iq200 with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 1,872 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Dynamic array sum

  #1 (permalink)
Fobos
Ukraina
 
Posts: 18 since Aug 2010
Thanks Given: 5
Thanks Received: 0

Help is needed. The code I wrote gives an error "ARRAY BOUNDS. WRONG INDEX VALUE: 73"
The logic is this, I summarize the volume when the volume begins to grow after the decline. I do the summation through a dynamic array, since in the future we will need the values of the first and last element in the array.
Tell me what could be the error.

 
Code
Variables:

sput (0),
var0( 0 ),
Times ( 0 ),
lastVol (0),
firstVol (0),
TimeSput (0),
x (0),
VolSum( 0 );

Arrays:
VolSumArray[](0);

begin

if BarType >= 2 and BarType < 5 then 
	
var0 = Volume ;
var0 = Ticks ;
	
	
If (var0 > var0[1]and var0[1] <= var0[2] ) then begin
sput = Close[1];
End;

If sput = sput then begin
TimeSput = datetime;
End;

If TimeSput > TimeSput [1] then
x=x+1;
Array_SetMaxIndex(VolSumArray, x );


If TimeSput > TimeSput [1] then begin
VolSumArray[x] = var0;
End;

If TimeSput = TimeSput  then begin
lastVol = var0;
End;

If TimeSput[1] = TimeSput[1]  then begin
firstVol = var0;
End;


If (var0 > var0[1]and var0[1] <= var0[2] ) then 
VolSum = 0;

VolSum = Array_Sum(VolSumArray, firstVol, lastVol);


if Close[0] > sput then


Plot1( VolSum, "VolUp",Blue ) ;
	
if Close[0] < sput then 

Plot2( VolSum, "VolDn",Red ) ;

Plot3( 0, "Zero", black);

End;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
What broker to use for trading palladium futures
Commodities
Cheap historycal L1 data for stocks
Stocks and ETFs
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #3 (permalink)
 iq200 
London, UK
 
Experience: Intermediate
Platform: Ninjatrader, Tradestation
Broker: Kinetick, InteractiveBrokers
Trading: Equities, Futures
Posts: 408 since Jun 2010
Thanks Given: 145
Thanks Received: 278


Why don’t you use the EasyLanguage debugger?

I haven’t used Tradestation Easylanguage for years since I moved to Ninjatrader but most likely, I’d check the arguments to Array_Sum to see they are valid. In particular, I think arrays are 0 index based which means start index will be 0 and last index will be n-1 (for array of size n elements).


Sent from my iPhone using futures.io

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
Fobos
Ukraina
 
Posts: 18 since Aug 2010
Thanks Given: 5
Thanks Received: 0


iq200 View Post
Why don’t you use the EasyLanguage debugger?

I haven’t used Tradestation Easylanguage for years since I moved to Ninjatrader but most likely, I’d check the arguments to Array_Sum to see they are valid. In particular, I think arrays are 0 index based which means start index will be 0 and last index will be n-1 (for array of size n elements).


Sent from my iPhone using futures.io

Where can I find the EasyLanguage debugger?
As I understand it, in EasyLanguage Array indexes start at 0, and array size is equal to the value of MaxIndex plus one.

Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Fobos,

the debugger is built-in into the development environment and you can find more information in the platform help. Alternatively you can use the print reserved word to find out what is going within your code.
Check the indices you are using within Array_Sum. From glancing at your code it's not guaranteed that you the array size >= lastVol.

Regards,

ABCTG


Fobos View Post
Where can I find the EasyLanguage debugger?
As I understand it, in EasyLanguage Array indexes start at 0, and array size is equal to the value of MaxIndex plus one.


Follow me on Twitter Reply With Quote
Thanked by:
  #6 (permalink)
Fobos
Ukraina
 
Posts: 18 since Aug 2010
Thanks Given: 5
Thanks Received: 0


ABCTG View Post
Fobos,

the debugger is built-in into the development environment and you can find more information in the platform help. Alternatively you can use the print reserved word to find out what is going within your code.
Check the indices you are using within Array_Sum. From glancing at your code it's not guaranteed that you the array size >= lastVol.

Regards,

ABCTG

Thank. I figured out the debugger using print. Before the onset of the condition, is it necessary / possible to reset the array, max index?

Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

Fobos,

not from an EasyLanguage point of view, but your logic might dictate something else of course.

Regards,

ABCTG


Fobos View Post
Thank. I figured out the debugger using print. Before the onset of the condition, is it necessary / possible to reset the array, max index?


Follow me on Twitter Reply With Quote
  #8 (permalink)
Fobos
Ukraina
 
Posts: 18 since Aug 2010
Thanks Given: 5
Thanks Received: 0


ABCTG View Post
Fobos,

not from an EasyLanguage point of view, but your logic might dictate something else of course.

Regards,

ABCTG

So I described the logic and code in the first post. And since the indicator gives an error, I ask for help. Thanks anyway!

Reply With Quote




Last Updated on October 14, 2019


© 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