NexusFi: Find Your Edge


Home Menu

 





Passing array to function such as average or RSI?


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #1 (permalink)
maisatomai
Singapore
 
Posts: 3 since Apr 2014
Thanks Given: 0
Thanks Received: 0

 
Code
Hivalue10=average(HighDaily[0],2); 
value11=(HighDaily[0]+HighDaily[1])/2;
This works as value10 has same value as value11

 
Code
value10=average(HighDaily[0],3); 
value11=(HighDaily[0]+HighDaily[1]+HighDaily[2])/3;
This don't work as value10 has different value as value11

HighDaily is of type Array. Anyone know why and how can I fix it? I hope to convert array into a PriceSeries as I suspect we need to pass PriceSeries into average for it to work well. I need this to work as I need it to use on other functions like RSI


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
Roland Garros Final Day: $3M on Zverev at 80.5% -- Leban …
Prediction Markets & Event Contracts
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
Warsh Rate Hike at 40%, Iran June 15 Expires Tonight at …
Prediction Markets & Event Contracts
June 15 Peace Odds Surge From 3.6% to 12.25% After Trump …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
196 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #3 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,972 since Jun 2009
Thanks Given: 534
Thanks Received: 3,714


instead of

 
Code
value10=average(HighDaily[0],3);
I think you should try

 
Code
value10=average(HighDaily,3);
If you call average on HighDaily[0] it's just averaging 1 value I suppose. I'm not a EL programmer but either way it just doesn't look right.


Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

maisatomai,

in my opinion it's just a coincidence that your first example gives the correct result.

 
Code
Arrays:
	HighDaily[2]	(0);
	
once 
begin
	HighDaily[0] = 100 ;
	HighDaily[1] = 200 ;	
	HighDaily[2] = 300 ;
	
	Value1 = Average(HighDaily[0],2); 
	Value2 = (HighDaily[0]+HighDaily[1])/2;
	
	Print("Value1: ", Value1, "; Value2: ", Value2);

end;
The output looks like this: Value1: 50.00; Value2: 150.00

This example also demonstrates why what you are trying doesn't work, the functions don't cycle through your arrays, but reference the previous bar's value for the same position in the array.

You can pass arrays to functions, but you'd need to rewrite those functions to handle the array properly.

Regards,
ABCTG





maisatomai View Post
 
Code
Hivalue10=average(HighDaily[0],2); 
value11=(HighDaily[0]+HighDaily[1])/2;
This works as value10 has same value as value11

 
Code
value10=average(HighDaily[0],3); 
value11=(HighDaily[0]+HighDaily[1]+HighDaily[2])/3;
This don't work as value10 has different value as value11

HighDaily is of type Array. Anyone know why and how can I fix it? I hope to convert array into a PriceSeries as I suspect we need to pass PriceSeries into average for it to work well. I need this to work as I need it to use on other functions like RSI


Follow me on X Reply With Quote
  #5 (permalink)
maisatomai
Singapore
 
Posts: 3 since Apr 2014
Thanks Given: 0
Thanks Received: 0

@ABCTG

I understand what you mean. So is there any way I can pass my array into default function such as RSI and average? Or must I write my own RSI as RSI seems to take in NumericSeries and Array is NumericSimple


Reply With Quote
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

maisatomai,

in my opinion you'll have to rewrite/adapt the functions.

Regards,
ABCTG


Follow me on X Reply With Quote
  #7 (permalink)
maisatomai
Singapore
 
Posts: 3 since Apr 2014
Thanks Given: 0
Thanks Received: 0


ABCTG View Post
maisatomai,

in my opinion you'll have to rewrite/adapt the functions.

Regards,
ABCTG

thanks a lot for your help


Reply With Quote
  #8 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

maisatomai,

you are welcome. In case you run into any issues with the rewrite, just post back here and I am sure someone is able to steer you into the right direction.

Regards,
ABCTG


Follow me on X Reply With Quote




Last Updated on April 24, 2014


© 2026 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 - Downloads - Top
no new posts