Question with arrays in MultiCharts - EasyLanguage Programming | futures io social day trading
futures io futures trading


Question with arrays in MultiCharts
Updated: Views / Replies:3,505 / 5
Created: by Xyzzy Attachments:2

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Question with arrays in MultiCharts

  #1 (permalink)
Elite Member
Seattle, WA
 
Futures Experience: Intermediate
Platform: MultiCharts
Broker/Data: IB/IQFeed
Favorite Futures: ES
 
Posts: 20 since Dec 2010
Thanks: 27 given, 7 received

Question with arrays in MultiCharts

Hi all,

I apologize in advance for a newbie question -- I have a C# background, but I'm just getting started with MultiCharts/EasyLanguage.

I'm trying to create a modified version of the built-in "Mov Av Exp Ribbon" indicator. I've defined a numeric array of eight elements called "XAvg." The program then assigns each element an exponential moving average of a different length based on the inputs "Price" and "Length," and then plots the contents of that array.

This code works fine, and gives me the results I expect:

 
Code
XAvg[1] = XAverage( Price, Length ) ;
XAvg[2] = XAverage( Price, Length * 2 ) ;
XAvg[3] = XAverage( Price, Length * 3 ) ;
XAvg[4] = XAverage( Price, Length * 4 ) ;
XAvg[5] = XAverage( Price, Length * 5 ) ;
XAvg[6] = XAverage( Price, Length * 6 ) ;
XAvg[7] = XAverage( Price, Length * 7 ) ;
XAvg[8] = XAverage( Price, Length * 8 ) ;
However, I tried to shorten the block of array-assignment code with a for loop, below. When I comment out that code and use the for loop instead, I get completely different and unpredicted results.

 
Code
for index = 1 to 8 begin 
	XAvg[ index ] = XAverage( Price, Length * index ) ;
end;
At least in C#, the comparable code for these two blocks of code are equivalent and would give the same results. However, they don't seem to be working that way here. In particular, in the "for loop" code, it looks like XAvg[1] to AXvg[8] are each getting assigned the same value (i.e., the same moving average), rather than different moving averages. Consequently, I'm not seeing a ribbon effect plotted on the graph, but just eight lines that all have the same value.

Is there some difference here that I'm missing between these two blocks of code? Perhaps is there some difference in the way that the XAverage function is being called, or that results from that function are getting assigned to the array elements? I'm stumped. Many thanks.

Attached Files
Register to download File Type: pla Xyzzy Mov Avg Exp Ribbon.pla (6.2 KB, 14 views)
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Alesia E.U.
 
Futures Experience: Intermediate
Platform: Sierra chart
Favorite Futures: Futures
 
Posts: 166 since Feb 2011
Thanks: 139 given, 109 received


Hi
maybe i didn't understand well your question , but if you use
 
Code
XAvg[8] = XAverage( Price, Length * 8 ) ;
you use a prebuilt function of MC as array. is not possible( i think)
try this code
 
Code
Inputs:Length(3),price(close); 
variables:index(0),cont(0);
array:a1[7](0);
cont=1;
for index = 0 to 7 begin 
 a1[ index ] = XAverage( Price, Length * cont ) ;
 cont=cont+1;
end;
plot1(a1[ 0 ]);plot2(a1[ 7 ]);plot3(a1[ 1 ]);plot2(a1[ 6 ]);

Reply With Quote
The following 2 users say Thank You to crazybears for this post:
 
  #4 (permalink)
Trading Apprentice
vienna
 
Futures Experience: Master
Platform: MultiCharts
Favorite Futures: NQ
 
Posts: 22 since Aug 2009
Thanks: 0 given, 37 received

Series functions will return incorrect results if called within loop, last Point 7
Best Practice for working with Functions

at

https://www.tradestation.com/wiki/display/EasyLanguage/Understanding+Functions

Reply With Quote
The following user says Thank You to insideday for this post:
 
  #5 (permalink)
Elite Member
Seattle, WA
 
Futures Experience: Intermediate
Platform: MultiCharts
Broker/Data: IB/IQFeed
Favorite Futures: ES
 
Posts: 20 since Dec 2010
Thanks: 27 given, 7 received

Thanks everyone. Insideday, I can't access the link, which might be caused by my not having a TradeStation account. (I'm using MultiCharts instead.)

Regardless, I found a post here that describes the source of my problem. Specifically, there's some bad juju with using recursive functions within a For... next loop.

http://www.jurikres.com/down/Some%20Programming%20Issues%20in%20Easy%20Language.pdf

I'm still trying to figure out the subtleties of EasyLanguage programming, but for now the short answer seems to be don't use loops for situations like this. It makes the code a bit less elegant, but oh well.

Reply With Quote
The following 2 users say Thank You to Xyzzy for this post:
 
  #6 (permalink)
Trading Apprentice
vienna
 
Futures Experience: Master
Platform: MultiCharts
Favorite Futures: NQ
 
Posts: 22 since Aug 2009
Thanks: 0 given, 37 received

Best Practice for working with Functions

Attached Thumbnails
Question with arrays in MultiCharts-best-practice-working-functions.jpg  
Reply With Quote
The following 6 users say Thank You to insideday for this post:

Reply



futures io > > > > > Question with arrays in MultiCharts

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
MultiCharts Webinar: Peter Campbell - Systematic Trading with MultiCharts MultiCharts MultiCharts 25 August 31st, 2015 09:32 PM
This is how you do Global Arrays. bjschwenzer EasyLanguage Programming 4 January 27th, 2012 12:19 AM
Help with Arrays not DataSeries Compiles won't run Crassius NinjaTrader Programming 4 February 25th, 2011 04:18 AM
MultiCharts Bar Magnifier Question benharrell EasyLanguage Programming 2 January 11th, 2011 07:22 PM
Multicharts tinkerz EasyLanguage Programming 2 May 13th, 2010 12:08 PM


All times are GMT -4. The time now is 06:40 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-18 in 0.10 seconds with 21 queries on phoenix via your IP 54.221.93.187