NexusFi: Find Your Edge


Home Menu

 





TradeStation \ Easy Language life hacks


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one swingbatter with 1 posts (2 thanks)
    2. looks_two artisanpro with 1 posts (3 thanks)
    3. looks_3 MasterYan with 1 posts (1 thanks)
    4. looks_4 njh1618 with 1 posts (1 thanks)
      Best Posters
    1. looks_one artisanpro with 3 thanks per post
    2. looks_two swingbatter with 2 thanks per post
    3. looks_3 MasterYan with 1 thanks per post
    4. looks_4 njh1618 with 1 thanks per post
    1. trending_up 4,370 views
    2. thumb_up 7 thanks given
    3. group 5 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

TradeStation \ Easy Language life hacks

  #1 (permalink)
MasterYan
San Francisco, CA
 
Posts: 30 since Jul 2016
Thanks Given: 13
Thanks Received: 4

Do you have any life hacks in TradeStation or Easy Language that you can share ?

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Strategy stop orders partially filled
EasyLanguage Programming
REcommedations for programming help
Sierra Chart
Cheap historycal L1 data for stocks
Stocks and ETFs
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #2 (permalink)
 njh1618 
Provo, Utah
 
Experience: Advanced
Platform: TradeStation
Trading: NQ, YM, RTY, ES, US, CL, EC, JY
Posts: 5 since Mar 2020
Thanks Given: 1
Thanks Received: 5

What type of thing are you looking for?

njh

Reply With Quote
Thanked by:
  #3 (permalink)
artisanpro
montreal, qc, canada
 
Posts: 28 since May 2021
Thanks Given: 28
Thanks Received: 18


Here are four very similar hacks that work with Mutlichart Easy Language. The key hacks here are: how to change an indicator used in many windows/workspaces "all at once" as opposed to change single occurrences.

Hack 1:
How to change "all at once" the input values of an indicator that is being used in multiple windows and multiple workspaces.

As an example, you have an EMA using an input value of 14 but would prefer now to use 21 as the indicator input.

1. Open your indicator in the "power language editor".
2. Move the input to the "variable section"
3. Change the value.
4. Compile.
5. Move the input currently in the "variable section" back to the "input section"
6. Compile.

Hack 2:
Create a function that only contains/returns a value. Use that function as an input value to any/all indicators.

Function:
__fff_RngeExtrLong = 14 ;

Indicator Input:
iRERangeLength( __fff_RngeExtrLong ),

If you change the function value to 21 (i.e .__fff_RngeExtrLong = 21 ; and recompile) all indicators with this input will now use 21 in their calculations.


Hack 3:
How to change "all at once" the plot visual of an indicator that is being used in multiple windows and multiple workspaces.

As an example, you have an EMA that plots a Solid Line ______ but you want to change it in every occurrences of windows and workspaces "all at once" with a plot of a Dashed Line - - - - - .

This is fairly obvious once you know these keywords: SetPlotBGColor, SetPlotColor, Setplotstyle, SetPlotWidth. Open your indicator in the "power language editor", add the appropriate keyword in your code before the plot and recompile. See this link for how to use them: https://www.multicharts.com/trading-software/index.php?title=Category:Plotting

Hack 4:
How to change "all at once" the input values, properties, code, visual, etc of an indicator that is being used in multiple windows and multiple workspaces.

As an example, you want to do many changes to the input values and to the plotting visuals of a few plots in your indicator.

1. Open your indicator in the "power language editor".
2. Make the changes to the input values, code or code properties (with right click to open up the sub-menu), etc.
3. Compile ( if needed).
4. Comment the entire code by using '{' at the beginning of the code and '}' at the end of the code.
5. Compile again. I know, there nothing to compile but .... it is necessary.
6. Delete the added '{' and '}'.
7. Compile again and all your changes (input values, properties, etc, ) have been replicated in all the opened windows/workspaces.

This may read like tedious / complicated but once you have done it 1-2 times it becomes easy and you wonder why it is not a standard feature to be used by people like that change their mind sometimes. One caution, the "format study template" will not be changed.


General Comment:
Hack 4 is not obvious and I came to notice that sometimes my changes were replicated so I started paying a bit more attention and wrote this "recipe".

Hack 3 is simple but also can be used to change automatically the color, line style of a plot using conditions. Here is an example:
If iRERangeLength = __fff_RngeExtrLong then begin
vTaTplotColour = green ;
// setplotstyle(21, 3 ) ;
// setplotstyle(33, 3 ) ;
end else
If iRERangeLength = __fff_RngeExtrShort then begin
vTaTplotColour = magenta ;
setplotstyle(21, 4 ) ;
setplotstyle(33, 4 ) ;
end else
If iRERangeLength <> __fff_RngeExtrLong OR iRERangeLength <> __fff_RngeExtrShort then begin
vTaTplotColour = darkgreen ;
setplotstyle(21, 2 ) ;
setplotstyle(33, 2 ) ;
end ;

Hack 2 works also for something like """__ffPrix = (Open + High + Low + Close) / 4) ;"""

I hope that these hacks will prove useful to some of you and if it works with Tradestation let me know.

Reply With Quote
  #4 (permalink)
swingbatter
Arlington
 
Posts: 18 since Feb 2020
Thanks Given: 6
Thanks Received: 3

Multiple Conditions Hack 1:
To test a strategy in which at least k out of n conditions (like MACD cross, RSI threshold, etc) are satisfied to execute a trade (regardless of which ones), you can just keep a count.
For instance if I wanted 3 out of 5 conditions to be met before buying a stock:
--------------------------------------------------------------------
input: minNumConditionsMet(3);
var: NumConditionsMet(0);

NumConditionsMet=0;
if condition_1 then NumConditionsMet+=1;
if condition_2 then NumConditionsMet+=1;
if condition_3 then NumConditionsMet+=1;
if condition_4 then NumConditionsMet+=1;
if condition_5 then NumConditionsMet+=1;

if NumConditionsMet >= minNumConditionsMet then
buy 1 share next bar at market;
setprofittarget(10);
--------------------------------------------------------------------

Multiple Conditions Hack 2:
To determine exactly which conditions work best together (and which to ditch), you can make the optimizer turn on/off the conditions sequentially. (So we're optimizing conditions instead of just variables.)
If we have 5 conditions (n=5), there are actually 2^n = 32 ways we can implement those 5 conditions: utilize all of them, or only 1, only 1&4, only 1,3&5, etc.
Stick your conditions in the code below, and then, during optimization, set the "combinations" input variable to iterate from 1 to 32, incrementing by 1, and this will test every combination of your conditions and arrive at the best mix.

------------------------------------------------------------------
input: combinations(32);
var: int n(0), bool shouldBuy(true);
shouldBuy=true;
n=1;
if mod(combinations, power(2,n) ) < power(2,n-1) and shouldBuy=true then
if condition_1 then
shouldBuy=true else shouldBuy=false;
n=2;
if mod(combinations, power(2,n) ) < power(2,n-1) and shouldBuy=true then
if condition_2 then
shouldBuy=true else shouldBuy=false;
n=3;
if mod(combinations, power(2,n) ) < power(2,n-1) and shouldBuy=true then
if condition_3 then
shouldBuy=true else shouldBuy=false;
n=4;
if mod(combinations, power(2,n) ) < power(2,n-1) and shouldBuy=true then
if condition_4 then
shouldBuy=true else shouldBuy=false;
n=5;
if mod(combinations, power(2,n) ) < power(2,n-1) and shouldBuy=true then
if condition_5 then
shouldBuy=true else shouldBuy=false;

if shouldBuy=true then
buy 1 share next bar at market;
setprofittarget(10);
--------------------------------------------------------------------

The code comes in handy when dealing with 4 or more conditions and is easily scalable for as many conditions as you want.

Reply With Quote
Thanked by:




Last Updated on September 15, 2021


© 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