NexusFi: Find Your Edge


Home Menu

 





Does this simple EL code actually work in TradeStation?


Discussion in EasyLanguage Programming

Updated
    1. trending_up 2,728 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Does this simple EL code actually work in TradeStation?

  #1 (permalink)
Genesis13
Brisbane Australia
 
Posts: 4 since Jun 2021
Thanks Given: 0
Thanks Received: 1

Hello, before I sign up to use the TS platform for backtesting I need to know if my EL code posted below actually works and prints out the number 7 in the TS platform print log. Could someone please test this on their machine. Here is the code that I need tested. Does the EL code below print out the number 7 in the TS Print Log or does it not work for some reason? Really appreciate any help, huge thanks in advance.


[IntrabarOrderGeneration = TRUE]

variables:

intrabarpersist AD_Max_Pos_Acc_1(0),
intrabarpersist AD_Max_Pos_Acc_1_S(""),
intrabarpersist AD_Get_Pos_Acc_1(0),
intrabarpersist AD_Get_Pos_Acc_1_S(""),
intrabarpersist Count(0),
intrabarpersist Count_S(""),
intrabarpersist Lots(0);

AD_Max_Pos_Acc_1 = 13 ;

AD_Max_Pos_Acc_1_S = NumToStr(AD_Max_Pos_Acc_1,0);

AD_Get_Pos_Acc_1 = 6 ;

AD_Get_Pos_Acc_1_S = NumToStr(AD_Get_Pos_Acc_1,0);

Count = 1 ;

Count_S = NumToStr(Count,0) ;

Lots = StrToNum("AD_Max_Pos_Acc_" + Count_S + "_S") - StrToNum("AD_Get_Pos_Acc_" + Count_S + "_S") ;

Print("Lots = ",Lots) ; // Question: Does this Print statement print out the number 7 ?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
ZombieSqueeze
Platforms and Indicators
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

Genesis13,

welcome to futures.io. Your code will print 0 due to the way StrToNum works.

Take a look at the description for this reserved word taken from the TS help file:

Quoting 
If any non-numeric characters are included in the string expression, zero (0) is returned. The only exception is when non-numeric characters are located at the end of the string expression, in which case, they are dropped from the numeric expression.

While your expression "AD_Max_Pos_Acc_" + Count_S + "_S" evaluates to the string AD_Max_Pos_Acc_1_S within EasyLanguage, the compiler will treat this as a new string literal and not access the value stored in the variable with the same name.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #3 (permalink)
Genesis13
Brisbane Australia
 
Posts: 4 since Jun 2021
Thanks Given: 0
Thanks Received: 1


Hi ABCTG, huge thanks for your help and advice, I really appreciate this. Will my code print the number 7 (instead of 0) if I change the code to the following syntax? If not, can you think of any solution here to get the code to print the number 7 ?

[IntrabarOrderGeneration = TRUE]

variables:

intrabarpersist AD_Max_Pos_Acc_1(0),
intrabarpersist AD_Max_Pos_Acc_1_S(""),
intrabarpersist AD_Get_Pos_Acc_1(0),
intrabarpersist AD_Get_Pos_Acc_1_S(""),
intrabarpersist Count(0),
intrabarpersist Count_S(""),
intrabarpersist String1(""),
intrabarpersist String2(""),
intrabarpersist Lots(0);

AD_Max_Pos_Acc_1 = 13 ;

AD_Max_Pos_Acc_1_S = NumToStr(AD_Max_Pos_Acc_1,0);

AD_Get_Pos_Acc_1 = 6 ;

AD_Get_Pos_Acc_1_S = NumToStr(AD_Get_Pos_Acc_1,0);

Count = 1 ;

Count_S = NumToStr(Count,0) ;

String1 = "AD_Max_Pos_Acc_" + Count_S + "_S" ;

String2 = "AD_Get_Pos_Acc_" + Count_S + "_S" ;

Lots = StrToNum(String1) - StrToNum(String2) ;

Print("Lots = ",Lots) ; // Question: Does this Print statement print out the number 7 ?

Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

Genesis13,

it will also print 0, as you are basically trying the same just storing the string in another variable. You cannot dynamically set variable names and access the values of these variables within EasyLanguage the way you intend to do it.

One idea that comes to mind is using a Dictionary where you can store and lookup values using keys (strings).

Regards,

ABCTG


Genesis13 View Post
Hi ABCTG, huge thanks for your help and advice, I really appreciate this. Will my code print the number 7 (instead of 0) if I change the code to the following syntax? If not, can you think of any solution here to get the code to print the number 7 ?

[IntrabarOrderGeneration = TRUE]

variables:

intrabarpersist AD_Max_Pos_Acc_1(0),
intrabarpersist AD_Max_Pos_Acc_1_S(""),
intrabarpersist AD_Get_Pos_Acc_1(0),
intrabarpersist AD_Get_Pos_Acc_1_S(""),
intrabarpersist Count(0),
intrabarpersist Count_S(""),
intrabarpersist String1(""),
intrabarpersist String2(""),
intrabarpersist Lots(0);

AD_Max_Pos_Acc_1 = 13 ;

AD_Max_Pos_Acc_1_S = NumToStr(AD_Max_Pos_Acc_1,0);

AD_Get_Pos_Acc_1 = 6 ;

AD_Get_Pos_Acc_1_S = NumToStr(AD_Get_Pos_Acc_1,0);

Count = 1 ;

Count_S = NumToStr(Count,0) ;

String1 = "AD_Max_Pos_Acc_" + Count_S + "_S" ;

String2 = "AD_Get_Pos_Acc_" + Count_S + "_S" ;

Lots = StrToNum(String1) - StrToNum(String2) ;

Print("Lots = ",Lots) ; // Question: Does this Print statement print out the number 7 ?


Follow me on Twitter Reply With Quote




Last Updated on June 17, 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