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,914 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 Rewrites the Rulebook -- Kalshi Cracks $1B Non-Spor …
Prediction Markets & Event Contracts
April FOMC Minutes: Most Divided Fed Since 1992 -- Many …
Traders Hideout
$12M Ceasefire Contract Goes Disputed as Bandar Abbas St …
Prediction Markets & Event Contracts
Probability Collapse: Bitcoin $150k Craters from 15% to …
Prediction Markets & Event Contracts
Asia Equities Crash Overnight -- Nikkei -5.2%, KOSPI -6. …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Hello Im new here
5 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,971 since Jun 2009
Thanks Given: 534
Thanks Received: 3,711


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,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

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,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

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,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

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