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,377 / 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

  #11 (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

My task now is to get the function to be able to call itself.
This is what i have so far.
Need help with the code section in the red font.
Anyone?

 
Code
	float XAverge(SCStudyInterfaceRef sc,SCFloatArrayRef Arraydata, SCFloatArrayRef Arraydata2, int ndata)
{
 
	float SmoothingFactor = 0;

	  if (ndata >= 0)
	   {
		   SmoothingFactor =  2 / ( ndata + 1 );
           }


	  if (sc.Index == 1) 
			{
			   sc.ExponentialMovAvg(Arraydata, Arraydata2, ndata);
				
			  return Arraydata2[sc.Index];
			}
		else
			
			{
      //XAverage = XAverage[1] + SmoothingFactor * ( Price - XAverage[1] ) ;//recursive call inside the TS version
			
// does not work gives an error "expression must have pointer- to- object type" need help with the following line
  return XAverge(sc, Arraydata , Arraydata2, ndata)[sc.Index - 1] + SmoothingFactor *  ( Arraydata[sc.Index] - XAverge(sc, Arraydata, Arraydata2, ndata)[sc.Index - 1] );
 

	  }

}


Last edited by Renko123; March 23rd, 2015 at 07:29 PM.
Reply With Quote
 
  #12 (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


Renko123 View Post

// does not work gives an error "expression must have pointer- to- object type" need help with the following line
return XAverge(sc, Arraydata , Arraydata2, ndata)[sc.Index - 1] + SmoothingFactor * ( Arraydata[sc.Index] - XAverge(sc, Arraydata, Arraydata2, ndata)[sc.Index - 1] );

Guess that line of code not working has got the pro`s here out of ideas also.

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


Something like this:

 
Code
SCFloatArrayRef XAverage(SCFloatArrayRef In, SCFloatArrayRef Out, int Index, int Length)
{
	float SmoothingFactor = 0;

	if (Index >= In.GetArraySize())
		return Out;

	if (Index < 1 || Length < 1)
		return Out;

	if (Index < Length - 1)
		Length = Index + 1;

	if (Length >= 0)
		SmoothingFactor = 2 / (Length + 1);


	if (Index < 1)
		Out[Index] = In[Index];
	else
		Out[Index] = Out[Index - 1] + SmoothingFactor * (In[Index] - Out[Index - 1]);

		return Out;
}

Reply With Quote
The following user says Thank You to ehlaban for this post:
 
  #14 (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 .
Got the function working and returning the correct value.
Here is the completed function for anyone in the future who may need it for a conversion from tradestation EL.
 
Code
	
float XAverge(SCStudyInterfaceRef sc,SCFloatArrayRef Arraydata, SCFloatArrayRef Arraydata2, int ndata)
{
 
float SmoothingFactor = 0;
	
    if (ndata >= 0)
	   {
	     SmoothingFactor =  2 / ( ndata + 1 );
           }
	
 

	    if (sc.Index == 1) 
			{
			 
			  return Arraydata[sc.Index];

			}
		else
			
			{

                           sc.ExponentialMovAvg(Arraydata, Arraydata2, ndata);
				
		            Arraydata2[sc.Index ] = Arraydata2[sc.Index - 1] + SmoothingFactor * (Arraydata[sc.Index] - Arraydata2[sc.Index- 1]);

		           return Arraydata2[sc.Index];
	                }
}

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

Now that the TS XAverge function is converted to SC.
I have a custom TS function that calls the XAverge function and need help with how to call the XAverge function multiple times in one line of code.

 
Code
float TrendCalu(SCStudyInterfaceRef sc,SCFloatArrayRef Arraydata, SCFloatArrayRef Arraydata2, int ndata)
{
//Variables: Var1(0.0); //tradestation code for a variable
	float array1[1]; // create array to replace the simple TS variable

// Var1 = XAverage (XAverage (XAverage (Log (Price), Length), Length), Length) ;// the original TS XAverge calls
	array1[1] = log(Arraydata[sc.Index]);//pulled out the log function and did the cal separate

//the follow code line below is what i need help with. Compile errors.
Arraydata2[sc.Index] = XAverge(sc,XAverge(sc,XAverge(sc,array1[1],Arraydata2,ndata),Arraydata2,ndata),Arraydata2,ndata);

return Arraydata2[sc.Index];


         if (sc.Index > 1.0) 
			{
			 
			  return Arraydata2[sc.Index] = (Arraydata[sc.Index] - Arraydata2[sc.Index- 1]) * 10000.0 ;
                         }
	
}

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

Did the line of code not working, finally get the best of the pro`s ?


Renko123 View Post
Now that the TS XAverge function is converted to SC.
I have a custom TS function that calls the XAverge function and need help with how to call the XAverge function multiple times in one line of code.

 
Code
float TrendCalu(SCStudyInterfaceRef sc,SCFloatArrayRef Arraydata, SCFloatArrayRef Arraydata2, int ndata)
{
//Variables: Var1(0.0); //tradestation code for a variable
	float array1[1]; // create array to replace the simple TS variable

// Var1 = XAverage (XAverage (XAverage (Log (Price), Length), Length), Length) ;// the original TS XAverge calls
	array1[1] = log(Arraydata[sc.Index]);//pulled out the log function and did the cal separate

//the follow code line below is what i need help with. Compile errors.
Arraydata2[sc.Index] = XAverge(sc,XAverge(sc,XAverge(sc,array1[1],Arraydata2,ndata),Arraydata2,ndata),Arraydata2,ndata);

return Arraydata2[sc.Index];


         if (sc.Index > 1.0) 
			{
			 
			  return Arraydata2[sc.Index] = (Arraydata[sc.Index] - Arraydata2[sc.Index- 1]) * 10000.0 ;
                         }
	
}


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 10:37 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-10 in 0.08 seconds with 19 queries on phoenix via your IP 54.221.73.186