NexusFi: Find Your Edge


Home Menu

 





Tradestation easylanguage indicators to Sierra Charts


Discussion in Sierra Chart

Updated
    1. trending_up 7,773 views
    2. thumb_up 4 thanks given
    3. group 4 followers
    1. forum 22 posts
    2. attach_file 1 attachments




 
Search this Thread

Tradestation easylanguage indicators to Sierra Charts

  #1 (permalink)
Renko123
Washington, DC USA
 
Posts: 64 since Nov 2013
Thanks Given: 12
Thanks Received: 6

I have been thinking about moving from Tradestation over to Sierra Charts because Sierra Charts are free with my futures broker.
The issue and concern I have is reproducing my TS easylanguage coded indicators and strats I created myself over to Sierra Charts.
I`m not a C++ developer, but i do know TS Easylanguage and VB.net coding.
Can Sierra Charts run/create studies using/with vb.net code?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Deepmoney LLM
Elite Quantitative GenAI/LLM
Futures True Range Report
The Elite Circle
Build trailing stop for micro index(s)
Psychology and Money Management
Exit Strategy
NinjaTrader
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
 
  #2 (permalink)
 ehlaban 
Netherlands
 
Experience: Advanced
Platform: Ensign, Multicharts
Trading: SP500
Posts: 91 since Nov 2009
Thanks Given: 66
Thanks Received: 57

No Sierrachart uses ACSIL and that's like c++. But if you can code in Easylanguage and vb.net learning how to do it in acsil is easy. I just made the switch myself. Once you've done your first indicator the rest is easy. Strategies is a bit harder i think.

Reply With Quote
  #3 (permalink)
Renko123
Washington, DC USA
 
Posts: 64 since Nov 2013
Thanks Given: 12
Thanks Received: 6


Thanks.
Hopefully, i can Google some open code sierra indicators and strats to learn from.
Off I go to learn c++ coding.

Reply With Quote
  #4 (permalink)
 ehlaban 
Netherlands
 
Experience: Advanced
Platform: Ensign, Multicharts
Trading: SP500
Posts: 91 since Nov 2009
Thanks Given: 66
Thanks Received: 57

Don't, just start with porting a simple indicator to Sierrachart. That way you can learn step by step by looking in the online Sierra ACSIl documentation. The first step is to make a template you can use over and over again. Like this:

 
Code
// The top of every source code file must include this line
#include <math.h> // other includes always before sierrachart.h !
#include "sierrachart.h"

/*****************************************************************************

	For reference, please refer to the Advanced Custom Study Interface
	and Language documentation on the Sierra Chart website. 
	
	Template is build up from 3 parts
	
*****************************************************************************/

// This line is required. Change the text within the quote marks to what you want to name your group of custom studies. 
SCDLLName("testIndicator") 

SCSFExport scsf_myIndicator(SCStudyInterfaceRef sc)
{	// Part 1 Reference and Initialize 3 things; the Plots and the inputs and if needed arrays
		CSubgraphRef 	IndicatorLine	 = sc.Subgraph[0];  //Output line an first array
		
		SCInputRef 	firstInput		= sc.Input[0]; // Input for Indicator
		
		SCFloatArrayRef calcArray  	= IndicatorLine.Arrays[0]; // can be used for calculations if needed
	
	
	if (sc.SetDefaults)
	{
	// Part 2 - Set the configuration variables and defaults
		sc.GraphName 		= "My first Indicator";
		sc.StudyDescription 	= "This is my Indicator template";		
				
		//sc.GraphRegion 	= 1;	// Set the Chart Region to draw the graph in.  Region 0 is the main price graph
		sc.FreeDLL 		= 1;	// During dev set this flag to 1, so DLL can be rebuilt without restarting Sierra 
		sc.AutoLoop 		= 1;	//Auto looping is enabled. 
		sc.ValueFormat 	= 2;
		
	// Reference the Plots and the inputs and define them
		IndicatorLine.Name 			= "EOT";
		IndicatorLine.DrawStyle 	        = DRAWSTYLE_LINE;		// Look in scconstants.h for other draw styles
		IndicatorLine.PrimaryColor 	= RGB(0,128,0);			// Green	
		IndicatorLine.SecondaryColor     = RGB(255, 128, 128);	      // Light Red
		IndicatorLine.LineWidth 	         = 3;
		IndicatorLine.AutoColoring	         = AUTOCOLOR_SLOPE;
				
		firstInput.Name			         = "Period";
		firstInput.SetInt(20);
		firstInput.SetIntLimits(1, INT_MAX);
				
		return;
	}

	// Part 3 - Do data processing here for real indicator building
	
		//SuperSmoother Filter
		float a1, b1, c2, c3, c1;
		a1 = exp((-1.414) * 3.14159 / firstInput.GetInt());
		b1 = 2 * a1 * cos(1.414*(180 * 3.14159 / 180) / firstInput.GetInt());
		c2 = b1;
		c3 = (-1)*a1*a1;
		c1 = 1 - c2 - c3;
				
		if (sc.Index < 2) IndicatorLine[sc.Index] = sc.BaseDataIn[SC_LAST][sc.Index];
		else IndicatorLine[sc.Index] = c1 * (sc.BaseDataIn[SC_LAST][sc.Index] + sc.BaseDataIn[SC_LAST][sc.Index -        1]) / 2 + c2 * IndicatorLine[sc.Index - 1] + c3 * IndicatorLine[sc.Index - 2];
}

Reply With Quote
Thanked by:
  #5 (permalink)
Renko123
Washington, DC USA
 
Posts: 64 since Nov 2013
Thanks Given: 12
Thanks Received: 6

Thanks for the code template.

Will go thru the online docs to learn how to manipulate bar color, create variables and presistant variables for strings, numbers and boolean.
How to access previous data from a variable ie ( value34[2] as used in TS coding).
Have to find the SC version of these TS functions (AVERAGE, MRO, BIGPOINTVALUE, ABSVALUE ) ;

Reply With Quote
  #6 (permalink)
Renko123
Washington, DC USA
 
Posts: 64 since Nov 2013
Thanks Given: 12
Thanks Received: 6

After going thru the sample code and online docs for Sierra, i see why there is hardly any commercial indicators or strats for Sierra Charts. You need to have a PHD to understand the code.


I still haven't figured out how to get the AVERAGE, MRO, ABSVALUE.

Tradestation its simple to do.
value18 = AVERAGE (ABSVALUE (high- high[5]), 8)
If MRO (value1 < value1[8] AND value1[1] > value1[3], 2, 1) > -1 then value2 = True;

All done in just 2 lines of code.

With Sierra Charts you need to be a professor at MIT.

Reply With Quote
  #7 (permalink)
 crazybears 
Alesia E.U.
 
Experience: Intermediate
Platform: Sierra chart
Trading: Futures
Posts: 168 since Feb 2011
Thanks Given: 146
Thanks Received: 115

Hi

see here:

ACSIL Interface Members - Functions - Sierra Chart

Table of Contents - Sierra Chart


Quoting 
sc.MovingAverage()
[link] - [Top]
Type: Intermediate Study Calculation Function

SCFloatArrayRef MovingAverage(SCFloatArrayRef FloatArrayIn, SCFloatArrayRef FloatArrayOut, unsigned int MovingAverageType, int Index, int Length);

SCFloatArrayRef MovingAverage(SCFloatArrayRef FloatArrayIn, SCFloatArrayRef FloatArrayOut, unsigned int MovingAverageType, int Length); Auto-looping only.

The sc.MovingAverage() function calculates a Moving Average of the specified Type and Length.

Parameters:
FloatArrayIn
FloatArrayOut
Index
Length
MovingAverageType
Example
sc.MovingAverage(sc.BaseDataIn[SC_LAST], sc.Subgraph[0], MOVAVGTYPE_SIMPLE, 20);

float MovingAverage = sc.Subgraph[0][sc.Index]; //Access the study value at the current index



Reply With Quote
  #8 (permalink)
 ehlaban 
Netherlands
 
Experience: Advanced
Platform: Ensign, Multicharts
Trading: SP500
Posts: 91 since Nov 2009
Thanks Given: 66
Thanks Received: 57

Actually they are quite similar. But easylanguage as the name implies is much easier then real programming languages like C# as used in Ninja and other programs or ACSIL which is like C++. So you need to have a grasp of programming when using something other then easylanguage. It doesn't matter what program you choose. So your first decision is if you want to go that route as you have to learn how to program a bit.

On top of your file, like in my template include
#include <math.h> // other includes always before sierrachart.h !

Then you can acces all the math function you like in Sierra
<cmath> (math.h) - C++ Reference

For the average look at:
ACSIL Interface Members - Functions - Sierra Chart

To get the array of price values:
sc.BaseDataIn[SC_HIGH][sc.Index] or in your case sc.BaseDataIn[SC_HIGH][5] you can even do
sc.Close[sc.Index]

abs or fabs goes like abs(sc.BaseDataIn[SC_HIGH] - sc.BaseDataIn[SC_HIGH][5] )

don't know what MRO is?
Is average the average between 2 values or a moving average?

In Sierra you have to use arrays to store calculation results and for input for indicators.

Don't you have the complete code for a simple indicator I or others can translate to sierra as an example?


Renko123 View Post
After going thru the sample code and online docs for Sierra, i see why there is hardly any commercial indicators or strats for Sierra Charts. You need to have a PHD to understand the code.

I still haven't figured out how to get the AVERAGE, MRO, ABSVALUE.

Tradestation its simple to do.
value18 = AVERAGE (ABSVALUE (high- high[5]), 8)
If MRO (value1 < value1[8] AND value1[1] > value1[3], 2, 1) > -1 then value2 = True;

All done in just 2 lines of code.

With Sierra Charts you need to be a professor at MIT.


Reply With Quote
  #9 (permalink)
Renko123
Washington, DC USA
 
Posts: 64 since Nov 2013
Thanks Given: 12
Thanks Received: 6

I think i have figured out the tradestation ABSVALUE function with fabs.
float value1 += fabs (sc.high[sc.Index] - sc.high[sc.Index-1]);

For the tradestation AVERAGE it looks like im going to have to loop.
float value2 = 0;
float average = 0.0;

for (int i=1; i<=sc.Index; i++)
{
average += fabs (sc.high[i] - sc.high[i -5]);

}
value2 = average / 18;

The tradestation MRO(Most Recent Occurance) function is going to be a brain buster for this c++ beginner.

The MRO (Most Recent Occurrence) function returns the number of bars ago the specified expression was True. Or, if the specified expression did not occur within the last x number of bars, the function informs you of such.

Example
Value1 = MRO(Close>Open, 5, 1);
I call the MRO function in my indicator as such.
If MRO (value1 < value1[8] AND value1[1] > value1[3], 2, 1) > -1 then value2 = True;

Tradestation MRO function below:

{ Wrapper function calling consolidated most/least recent occurrence function }

inputs:
Test( truefalseseries ),
Length( numericsimple ),
Instance( numericsimple ) ; { 0 < Instance <= Length }

MRO = RecentOcc( Test, Length, Instance, 1 ) ;

**** MRO function calls a separate RecentOcc function below****
{ RecentOcc }
{ Consolidated most/least recent occurrence function }

inputs:
Test( truefalseseries ),
Length( numericsimple ),
Instance( numericsimple ), { Length >= Instance > 0 }
MLFlag( numericsimple ) ; { pass in 1 for Most Recent, -1 for Least Recent }

variables:
LengthCntr( 0 ),
InstanceCntr( 0 ) ;

if MLFlag = 1 then
LengthCntr = 0
else if MLFlag = -1 then
LengthCntr = Length - 1 ;

InstanceCntr = 0 ;

while LengthCntr >= 0 and LengthCntr < Length and InstanceCntr < Instance
begin
if Test[LengthCntr] then
InstanceCntr = InstanceCntr + 1 ;
LengthCntr = LengthCntr + MLFlag ;
end ;

if InstanceCntr = Instance and Instance > 0 then
RecentOcc = LengthCntr - MLFlag + ExecOffset
else
RecentOcc = -1 ; { will get this also when Instance > Length }

Reply With Quote
Thanked by:
  #10 (permalink)
 ehlaban 
Netherlands
 
Experience: Advanced
Platform: Ensign, Multicharts
Trading: SP500
Posts: 91 since Nov 2009
Thanks Given: 66
Thanks Received: 57


In the ACS_Source folder there is a file called scstudyfunctions.cpp. In there are code examples to find the lowest and highest. Perhaps you can adapt them to find an input value. Arraysize - SrcIndex is difference in bars from last date i think.

Reply With Quote




Last Updated on February 6, 2015


© 2024 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 - Privacy Policy - Downloads - Top
no new posts