12-09-2010, 09:21 AM
|
#4 |
Join Date: Apr 2010 Location: Gurnee 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; |
| |