Welcome to the Traders Laboratory Forums.
Automated Trading Black box systems, strategy automation, algorithmic trading, etc...

Reply
Old 12-08-2010, 05:21 PM   #1

Join Date: Dec 2010
Posts: 3
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

Tradestation Pending Orders

Hi guys,

How to enter pending order that is valid all day or until canceled in tradestation ?
Now "buy stop/limit" order are valid only one second bar and if not executes they are canceled.
rublizz is offline  
Reply With Quote
Old 12-08-2010, 10:37 PM   #2

Jeff65's Avatar

Join Date: Apr 2010
Location: Gurnee
Posts: 24
Ignore this user

Thanks: 13
Thanked 13 Times in 6 Posts

Re: Tradestation Pending Orders

Quote:
Originally Posted by rublizz »
Hi guys,

How to enter pending order that is valid all day or until canceled in tradestation ?
Now "buy stop/limit" order are valid only one second bar and if not executes they are canceled.
Orders are placed on the next bar. That's is, the bar after the bar that just closed.

This is how I would do it. After determining my buy level I turn on a flag. Each time the current bar closes and my order is not filled, the order is replaced. If order is filled, my flag is disabled. At the end of day, my flag is disabled and all unfilled orders canceled.

Let me know if you want me to post a code example.
Jeff65 is offline  
Reply With Quote
Old 12-09-2010, 02:14 AM   #3

Join Date: Dec 2010
Posts: 3
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

Smile Re: Tradestation Pending Orders

Quote:
Originally Posted by Jeff65 »
Orders are placed on the next bar. That's is, the bar after the bar that just closed.

This is how I would do it. After determining my buy level I turn on a flag. Each time the current bar closes and my order is not filled, the order is replaced. If order is filled, my flag is disabled. At the end of day, my flag is disabled and all unfilled orders canceled.

Let me know if you want me to post a code example.
I get the concept.
But how can I catch bar close event?

Code would be good.
rublizz is offline  
Reply With Quote
Old 12-09-2010, 09:21 AM   #4

Jeff65's Avatar

Join Date: Apr 2010
Location: Gurnee
Posts: 24
Ignore this user

Thanks: 13
Thanked 13 Times in 6 Posts

Re: Tradestation Pending Orders

Quote:
Originally Posted by rublizz »
I get the concept.
But how can I catch bar close event?

Code would be good.
The code example of an Open Range Breakout system may help. Execute it on a 5-minute chart. I wrote it for the futures market but can be adapted to other markets. Orders are based upon the first 30-minutes of trading and remain active all day.

Let me know if you have questions.


Code:
// Example Open Range Breakout
// Executed on a 5-minute bar
// Order levels are based upon first 30-minutes of trading.
// Order levels and stop levels remain valid all day.

variables:
MP(0),
HH(0),
LL(0);

MP = MarketPosition;

{
----------------------------------------------------------
First 30 minutes of Market Open
Compute Opening Range 830 - 900 Central
----------------------------------------------------------
}

If ( Time = 900 ) Then
Begin    

   HH  = Highest( High, 6 );
   LL  = Lowest( Low, 6 );

  
End;

{
----------------------------------------------------------
Place orders between 900 and 1455 Central
Place only one trade per day
----------------------------------------------------------
}

If ( Time >= 900 ) And ( Time <= 1455 ) And ( MP = 0 ) And ( EntriesToday(Date) = 0 )  Then
Begin
   Buy ("LE") next bar at HH stop;
   Sellshort("SE") next bar at LL stop;
End;

// Set stop levels at opposite range

If ( MP = 1 ) Then Sell next bar at LL stop;
If ( MP = -1 ) Then Buy to cover next bar at HH stop;

// Exit all trades at 1500 Central
   
If ( Time = 1500 ) And ( MP <> 0 ) Then
Begin
   Sell this bar at close;
   Buy to cover this bar at close;
End;
Jeff65 is offline  
Reply With Quote
Old 12-19-2010, 08:58 AM   #5

Join Date: Dec 2010
Posts: 3
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

Re: Tradestation Pending Orders

Thanks Jeff65.

But isn't better to use "LimitOrder" function?
rublizz is offline  
Reply With Quote
Old 12-19-2010, 12:33 PM   #6

swansjr's Avatar

Join Date: Oct 2007
Location: Gurnee, IL
Posts: 282
Ignore this user

Thanks: 86
Thanked 132 Times in 69 Posts

Re: Tradestation Pending Orders

Quote:
Originally Posted by rublizz »
Thanks Jeff65.

But isn't better to use "LimitOrder" function?
I don't know if it's better, but it looks like you could use it. There are many ways to place order. I don't have much experience with using that function so I can't comment on the pros/cons of using it.
swansjr is offline  
Reply With Quote
Old 12-19-2010, 12:37 PM   #7

Jeff65's Avatar

Join Date: Apr 2010
Location: Gurnee
Posts: 24
Ignore this user

Thanks: 13
Thanked 13 Times in 6 Posts

Re: Tradestation Pending Orders

Quote:
Originally Posted by rublizz »
Thanks Jeff65.

But isn't better to use "LimitOrder" function?
I've never used that function. But yes, there are many ways to accomplish a single task.
Jeff65 is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone Program Custom OCOs for TradeStation? maxr Coding Forum 0 09-28-2010 06:33 AM
TradeStation Acquires the “Grail” Tams Tools of the Trade 1 06-21-2010 02:09 PM
Safe Martingale EA bnma Automated Trading 2 04-21-2010 11:44 PM
Corrupt Data on Tradestation Chart. Is This Common? Tasuki Brokers and Data Feeds 8 02-20-2010 08:26 PM
Daytrading - Big Picture/Volume Analysis EMC2Trader Technical Analysis 56 08-12-2008 12:26 PM

All times are GMT -4. The time now is 11:25 AM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.