Trading Articles
Article Categories
Article Tools
Does this simple EL code actually work in TradeStation?
Updated June 17, 2021
trending_up
2,430 views
thumb_up
0 thanks given
group
2 followers
forum
3 posts
attach_file
0 attachments
Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
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
(If you already have an account, login at the top of the page)
Does this simple EL code actually work in TradeStation?
(login for full post details)
#1 (permalink )
Brisbane Australia
Posts: 4 since Jun 2021
Thanks: 0 given,
1
received
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 ?
Can you help answer these questions from other members on futures io?
Best Threads (Most Thanked) in the last 7 days on futures io
(login for full post details)
#2 (permalink )
Posts: 2,361 since Apr 2013
Thanks: 426 given,
1,578
received
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
(login for full post details)
#3 (permalink )
Brisbane Australia
Posts: 4 since Jun 2021
Thanks: 0 given,
1
received
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 ?
(login for full post details)
#4 (permalink )
Posts: 2,361 since Apr 2013
Thanks: 426 given,
1,578
received
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
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 ?
Last Updated on June 17, 2021
Ongoing