Convert TradeStation XAverage function to Sierra code - Sierra Chart | futures io social day trading
futures io futures trading


Convert TradeStation XAverage function to Sierra code
Updated: Views / Replies:1,380 / 15
Created: by Renko123 Attachments:0

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
 

Convert TradeStation XAverage function to Sierra code

  #1 (permalink)
Trading for Fun
Washington, DC USA
 
Futures Experience: Intermediate
Platform: Tradestation, SC
Favorite Futures: NQ, ES, YM
 
Posts: 56 since Nov 2013
Thanks: 9 given, 2 received

Convert TradeStation XAverage function to Sierra code

Could someone be so kind as to convert this tradestation function over to a Sierra function?
Thanks in advance.

 
Code
inputs: 
	Price( numericseries ), { price to average }
	Length( numericsimple ) ; { this input must be a constant >= 0 }

variables: 
	intrabarpersist SmoothingFactor( 0 ) ;

once
	begin
	if Length >= 0 then
		SmoothingFactor =  2 / ( Length + 1 )
	else
		RaiseRuntimeError( "The Length input of the XAverage function must be " +
		 "greater than or equal to 0." ) ;
	end ;
	
if CurrentBar = 1 then
	XAverage = Price
else
	XAverage = XAverage[1] + SmoothingFactor * ( Price - XAverage[1] ) ;

Reply With Quote
 
  #2 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,238 since Jun 2009
Thanks: 29,350 given, 83,218 received

Isn't XAverage just an EMA? It's built-in to Sierra as Exponential Moving Average under Moving Averages.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #3 (permalink)
Trading for Fun
Washington, DC USA
 
Futures Experience: Intermediate
Platform: Tradestation, SC
Favorite Futures: NQ, ES, YM
 
Posts: 56 since Nov 2013
Thanks: 9 given, 2 received


The entire code i posted is the XAverage function itself.
I have no idea if its an Exponential Moving Average or not.
If the sierra Exponential Moving Average returns the exact same value with the same given input then i guess that would work.
However the the function appears to call itself at least twice with its previous value XAverage [1]
and I have no idea how to do that.


Big Mike View Post
Isn't XAverage just an EMA? It's built-in to Sierra as Exponential Moving Average under Moving Averages.

Mike


Reply With Quote
 
  #4 (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

ACSIL Interface Members - Functions - Sierra Chart

XAverage (Function)

Reply With Quote
 
  #5 (permalink)
Trading for Fun
Washington, DC USA
 
Futures Experience: Intermediate
Platform: Tradestation, SC
Favorite Futures: NQ, ES, YM
 
Posts: 56 since Nov 2013
Thanks: 9 given, 2 received

The SC sc.ExponentialMovAvg() takes in arrays and spits out arrays.
The Tradestation XAverage function does not appear to deal with arrays.
As my calling code in my TS indicator is:

Var1 = (HIGH[2] - LOW[4]) ; //one single value not array
Var2 = HIGH - Var1 ; // one single value not array
Var4 = XAverage (Var2, 6) ; // XAverage returns one single value not an array

I`m guessing that converting the Tradestation function to a SC function must be a very difficult task, since no one has tried.

If someone could take 60 seconds to post a custom created function as a sample template and tell me in where or what file i need to place it in to be able to call it from my indicator code.
I will tackle the difficult task of converting the XAverage to SC code.

Reply With Quote
 
  #6 (permalink)
Elite Member
Netherlands
 
Futures Experience: Advanced
Platform: Ensign, Multicharts
Favorite Futures: SP500
 
Posts: 95 since Nov 2009
Thanks: 66 given, 56 received

I'm no easy language expert but think you are wrong. Almost everything is an array in easy language.

Var4 is also an array and i think you can read former value by Var4[3] etc

Regardless if i look at the XAverage (Function)

I see the line XAverage = XAverage[1] + var0 * ( PriceValue - XAverage[1] ) ;

it references a back value in the input array: XAverage[1] and that shouldn't be possible if the input was only a number

 
Code
SCSubgraphRef 	Renko123 = sc.Subgraph[0];

SCFloatArrayRef Var1 = Renko123.Arrays[0];
SCFloatArrayRef Var2 = Renko123.Arrays[1];
SCFloatArrayRef Var4 = Renko123.Arrays[2];

Var1[sc.Index] = sc.BaseDataIn[SC_HIGH][2] - sc.BaseDataIn[SC_LOW][4];
Var2[sc.Index] = sc.BaseDataIn[SC_HIGH][sc.Index] - Var1[sc.Index];
sc.MovingAverage(Var2, Var4, MOVAVGTYPE_EXPONENTIAL, 6);

Renko123[sc.Index] = Var4[sc.Index];

Reply With Quote
 
  #7 (permalink)
Trading for Fun
Washington, DC USA
 
Futures Experience: Intermediate
Platform: Tradestation, SC
Favorite Futures: NQ, ES, YM
 
Posts: 56 since Nov 2013
Thanks: 9 given, 2 received

In Tradestation if I want a variable.
Variables: Var4(1) ;
Var4 = 1;

If I want to create an Array in Tradestation.
Array: int Var4[2];
Var4[0] = 1
Var4[1] = 2

If tradestation is converting a single created variable into a one dimensional array behind the scenes then i didn't know about that.
I tried to use Var4 as an input to the sc.ExponentialMovAvg and it chocked since Var4 wasn't a manual created array.

Thanks for the code you posted, but it isn't in in the form of a callable function since the XAverage function even calls itself several times.

The code i previous posted is the entire XAverage function itself and i need the converted code to be in the form of a function.
Since I will need to call the converted function several times in my current indicator code and future indicators I need to convert to SC

Thanks again.


ehlaban View Post
I'm no easy language expert but think you are wrong. Almost everything is an array in easy language.

Var4 is also an array and i think you can read former value by Var4[3] etc

Regardless if i look at the XAverage (Function)

I see the line XAverage = XAverage[1] + var0 * ( PriceValue - XAverage[1] ) ;

it references a back value in the input array: XAverage[1] and that shouldn't be possible if the input was only a number

 
Code
SCSubgraphRef 	Renko123 = sc.Subgraph[0];

SCFloatArrayRef Var1 = Renko123.Arrays[0];
SCFloatArrayRef Var2 = Renko123.Arrays[1];
SCFloatArrayRef Var4 = Renko123.Arrays[2];

Var1[sc.Index] = sc.BaseDataIn[SC_HIGH][2] - sc.BaseDataIn[SC_LOW][4];
Var2[sc.Index] = sc.BaseDataIn[SC_HIGH][sc.Index] - Var1[sc.Index];
sc.MovingAverage(Var2, Var4, MOVAVGTYPE_EXPONENTIAL, 6);

Renko123[sc.Index] = Var4[sc.Index];


Reply With Quote
 
  #8 (permalink)
Trading for Fun
Washington, DC USA
 
Futures Experience: Intermediate
Platform: Tradestation, SC
Favorite Futures: NQ, ES, YM
 
Posts: 56 since Nov 2013
Thanks: 9 given, 2 received

Do anyone know how to create a SC function that takes 2 inputs an array and an Integer?
Also what file do I place the function in to be able to call it via a indicator or another function?

Reply With Quote
 
  #9 (permalink)
Elite Member
Netherlands
 
Futures Experience: Advanced
Platform: Ensign, Multicharts
Favorite Futures: SP500
 
Posts: 95 since Nov 2009
Thanks: 66 given, 56 received

Place the function before the Sierra Chart function call: SCSFExport scsf_MyFunction(SCStudyInterfaceRef sc)
just like the example in the link below.


float Renko123function(float data[], int ndata)
{
float x = a * b;

return x;
}

Sierra Chart
Functions - C++ Tutorials

Reply With Quote
The following user says Thank You to ehlaban for this post:
 
  #10 (permalink)
Trading for Fun
Washington, DC USA
 
Futures Experience: Intermediate
Platform: Tradestation, SC
Favorite Futures: NQ, ES, YM
 
Posts: 56 since Nov 2013
Thanks: 9 given, 2 received


Thanks.


ehlaban View Post
Place the function before the Sierra Chart function call: SCSFExport scsf_MyFunction(SCStudyInterfaceRef sc)
just like the example in the link below.


float Renko123function(float data[], int ndata)
{
float x = a * b;

return x;
}

Sierra Chart
Functions - C++ Tutorials


Reply With Quote

Reply



futures io > > > > Convert TradeStation XAverage function to Sierra code

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
TradeStation Pivot function conversion petelegus72 ThinkOrSwim 0 December 19th, 2014 01:06 PM
convert indicators from Tradestation,MultiChart to TOS platform justtradeit84 ThinkOrSwim 2 November 21st, 2013 02:28 AM
Can anyone convert a code from TOS j8fire ThinkOrSwim 8 July 18th, 2012 09:24 PM
Convert Ninja Indicators to Tradestation daytrader4 The Elite Circle 2 December 15th, 2010 05:16 PM


All times are GMT -4. The time now is 06:44 AM.

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-12 in 0.13 seconds with 19 queries on phoenix via your IP 54.145.51.250