Use variable for "Entry Name" in buy - tradestation - futures io
futures io



Use variable for "Entry Name" in buy - tradestation


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ttinkham with 4 posts (1 thanks)
    2. looks_two ColoradoCliff with 2 posts (2 thanks)
    3. looks_3 abev with 2 posts (1 thanks)
    4. looks_4 ABCTG with 1 posts (2 thanks)
      Best Posters
    1. looks_one ABCTG with 2 thanks per post
    2. looks_two ColoradoCliff with 1 thanks per post
    3. looks_3 abev with 0.5 thanks per post
    4. looks_4 ttinkham with 0.3 thanks per post
    1. trending_up 377 views
    2. thumb_up 6 thanks given
    3. group 5 followers
    1. forum 8 posts
    2. 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)

 
Search this Thread
 

Use variable for "Entry Name" in buy - tradestation

(login for full post details)
  #1 (permalink)
 ttinkham 
Charlotte, NC
 
Experience: Intermediate
Platform: Tradestation
Broker: Tradestation, IB
Trading: Futures
 
Posts: 4 since Jun 2012
Thanks: 4 given, 1 received

I have the following statement that works:

Buy("Long Entry") PS contract next bar market;

I want to do the following:

myvariable="Long Entry";
Buy(myvariable) PS contract next bar market;

The buy command does not seem to accept a variable no matter what I do. Tried every syntax under the sun around myvariable and spent hours doing google searches. Hope someone here knows how to do this.

Thanks

Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
strategy builder help
Traders Hideout
CME 2023 Fee Increases (MES +16%!)
Traders Hideout
Asking Wall Street Billionaire for Investment Advice
Psychology and Money Management
Sierra Chart Teton_Denali vs TT Platform
Platforms and Indicators
IKYP - How I solved email troubles on VPS
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on futures io
1 Tick from the ES/Per day
18 thanks
What if a broker declare bankruptcy!!! Ftx first whose next?
12 thanks
HFT Algo: anyone doing HFT here?
8 thanks
commission
7 thanks
Want your NinjaTrader indicator created, free?
7 thanks
 
(login for full post details)
  #2 (permalink)
ColoradoCliff
Parker CO/USA
 
 
Posts: 16 since Jun 2017
Thanks: 0 given, 4 received

Did you define myVariable and initialize it as a String before referencing it in your code?

I will admit that the EL Essentials Guide only shows a constant value enclosed by Double Quotes and never a variable reference....perhaps that's not possible.


ttinkham View Post
I have the following statement that works:

Buy("Long Entry") PS contract next bar market;

I want to do the following:

myvariable="Long Entry";
Buy(myvariable) PS contract next bar market;

The buy command does not seem to accept a variable no matter what I do. Tried every syntax under the sun around myvariable and spent hours doing google searches. Hope someone here knows how to do this.

Thanks


Reply With Quote
The following user says Thank You to ColoradoCliff for this post:
 
(login for full post details)
  #3 (permalink)
abev
seattle washington
 
 
Posts: 50 since Feb 2019
Thanks: 8 given, 24 received


Mmmmm..... Not sure I'm getting what you are attempting but I may be reading too much into the question but I'll attempt to give you an answer.

The "Buy" command sends an order to purchase the default quantity of whichever symbol is open on the chart where the strategy is running. No variable for the "Buy" command is necessary.

If you are attempting to enter an order (buy or sell) for a symbol other than the one that is open on the chart, then you will need to either use Global Variables or data streams. Global variables and pass variables to other charts (i.e. the chart that is running the symbol you wish to buy). Or..... you can open the symbol you wish to buy on a second window in the same chart and direct the buy command to the data stream used by the symbol you are attempting to buy...or sell...which ever.

For example: I buy and sell options when the underlying reaches a specific strike price. I have a chart open with the underlying on it and a strategy that changes the value of a global variable when a specific strike price is reached. That global variable is read by a second chart which is a chart of the option I wish to buy or sell and I have a strategy running on that chart. The strategy running on the chart of the option reads the global variable at the open of each bar and buys or sells the option when the variable is true. I've not done this using data streams but I don't see why it wouldn't work with data streams -- the concept is the same.

Hope that helps.


PS I'm using Multichart's Power language so there is a possibility that what I do is specific to Powerlanguage -- but I don't think so. Someone else might want to chime in here.

Reply With Quote
The following user says Thank You to abev for this post:
 
(login for full post details)
  #4 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,355 since Apr 2013
Thanks: 425 given, 1,575 received

ttinkham,

legacy EasyLanguage in Tradestation will require a constant order name (string literal) that is set together with the order command.
You will not be able to set them with variables unfortunately.

Regards,

ABCTG


ttinkham View Post
I have the following statement that works:

Buy("Long Entry") PS contract next bar market;

I want to do the following:

myvariable="Long Entry";
Buy(myvariable) PS contract next bar market;

The buy command does not seem to accept a variable no matter what I do. Tried every syntax under the sun around myvariable and spent hours doing google searches. Hope someone here knows how to do this.

Thanks


Follow me on Twitter Reply With Quote
The following 2 users say Thank You to ABCTG for this post:
 
(login for full post details)
  #5 (permalink)
 ttinkham 
Charlotte, NC
 
Experience: Intermediate
Platform: Tradestation
Broker: Tradestation, IB
Trading: Futures
 
Posts: 4 since Jun 2012
Thanks: 4 given, 1 received

Thanks guys,

in response to ColoradoCliff, the answer is yes, I did define the string variable and I ran some tests with it and proved I can use it in other places.

I believe ABCTG is probably correct in that it is a limitation of Tradestation that variables can't be used which is really disappointing. I have a strategy that uses a bunch of different rules for entry so I wanted to label the entry with the corresponding entry rule name so that I could tell by looking at the chart what rule was used for the entry.

I eventually found in a Google search that Multicharts had the same issue, and they came out with a new command that allows the use of variables when doing a buy order. However, the new Multicharts commands don't work in Tradestation.

I can accomplish the same thing I am trying to do with a huge case statement with a separate buy command for every entry name I want to use but it is pretty clucky to do it that way and will make my code a lot longer. Guess that is the only option I have unless someone has a bright idea to get around this limitation.

Started this thread Reply With Quote
 
(login for full post details)
  #6 (permalink)
ColoradoCliff
Parker CO/USA
 
 
Posts: 16 since Jun 2017
Thanks: 0 given, 4 received

Given your test results, I would suggest having different buy instructions within each rule set to identify which rule triggered the buy event. Yes, it's not very elegant, but that should take care of your needs. Then submit an update request to the TS folks asking them to enhance that function.


ttinkham View Post
Thanks guys,

in response to ColoradoCliff, the answer is yes, I did define the string variable and I ran some tests with it and proved I can use it in other places.

I believe ABCTG is probably correct in that it is a limitation of Tradestation that variables can't be used which is really disappointing. I have a strategy that uses a bunch of different rules for entry so I wanted to label the entry with the corresponding entry rule name so that I could tell by looking at the chart what rule was used for the entry.

I eventually found in a Google search that Multicharts had the same issue, and they came out with a new command that allows the use of variables when doing a buy order. However, the new Multicharts commands don't work in Tradestation.

I can accomplish the same thing I am trying to do with a huge case statement with a separate buy command for every entry name I want to use but it is pretty clucky to do it that way and will make my code a lot longer. Guess that is the only option I have unless someone has a bright idea to get around this limitation.


Reply With Quote
The following user says Thank You to ColoradoCliff for this post:
 
(login for full post details)
  #7 (permalink)
 ttinkham 
Charlotte, NC
 
Experience: Intermediate
Platform: Tradestation
Broker: Tradestation, IB
Trading: Futures
 
Posts: 4 since Jun 2012
Thanks: 4 given, 1 received

Hey folks,

just wanted to give an update. I figured out a solution to accomplish what I was trying to do. Not perfect but works pretty well in the absence of TS functionality. I had not done much with text labels in the past so this part was fairly new to me.

It is pretty simple really.


earlier in my code where all my logic is I set the variable EntryName like so:

EntryName="my custom name that changes frequently and assigned to variable";



In the section of my code where I do the order entries the following is used:

Buy("") PS contract next bar market;
value1=Text_new(D,T,low,newline+newline+EntryName);

Notice I used Buy("") instead of Buy("Entry Name") to blank out the original text from the buy command.
Then I just placed the text below the bar with the label I really want. Notice the "newline+newline+EntryName". I added this "newline+newline" to give me some consistent spacing below the bar for my entry label regardless of scaling.

I actually tried to figure out a way to get the value of the most recent text object ID on the chart of the original text created by the Buy command and then use the Text_setstring command to change the text to what I set the EntryName variable to. Not sure if this is even possible but can't even seem to easily get the object ID without using the Text_getfirst command and then looping forward with the Text_getnext until hitting the last ID on the chart which would slow my code way down.

Happy Trading

Started this thread Reply With Quote
 
(login for full post details)
  #8 (permalink)
abev
seattle washington
 
 
Posts: 50 since Feb 2019
Thanks: 8 given, 24 received

Nice solution! I think I may have a place in my Options trading algo to try that.

Reply With Quote
 
(login for full post details)
  #9 (permalink)
 ttinkham 
Charlotte, NC
 
Experience: Intermediate
Platform: Tradestation
Broker: Tradestation, IB
Trading: Futures
 
Posts: 4 since Jun 2012
Thanks: 4 given, 1 received


ttinkham View Post

I actually tried to figure out a way to get the value of the most recent text object ID on the chart of the original text created by the Buy command and then use the Text_setstring command to change the text to what I set the EntryName variable to. Not sure if this is even possible but can't even seem to easily get the object ID without using the Text_getfirst command and then looping forward with the Text_getnext until hitting the last ID on the chart which would slow my code way down.

Another update. I did more testing on the getting the object ID of the text put on the chart with the "buy" command so that I could use the "Text_setstring" command to change it to whatever I want by using a variable. I found that TradeStation does not assign text object IDs to that text the "buy" command places on the chart so the idea of changing the text the "buy" command places on the chart will not work. So I think the solution in my previous post is the best option.

Started this thread Reply With Quote
The following user says Thank You to ttinkham for this post:


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Use variable for "Entry Name" in buy - tradestation


Last Updated on November 23, 2022


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2022 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
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.
no new posts