NexusFi: Find Your Edge


Home Menu

 





Does this simple EL code actually work in TradeStation?


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #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?
Iran Update May 8: Still Reviewing MOU, Demands Reparati …
Traders Hideout
ATFX Suspends Prop Trading Unit ATFunded -- Full Review …
Funded Trading Evaluation Firms
Election Sunday Resolves: Peru Heads to Runoff at 42pct, …
Prediction Markets & Event Contracts
Powell in 48 Hours: Word Markets Give 78% on Inflation, …
Prediction Markets & Event Contracts
UMA Votes Tonight: Polymarkets $80M Strategy Bitcoin Bat …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
196 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

Genesis13,

welcome to NexusFi. 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 X 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,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

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 X Reply With Quote




Last Updated on June 17, 2021


© 2026 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 - Downloads - Top
no new posts