easylanguage stop-limit order

w4rri0r

Newbie
Messages
2
Likes
0
Hi,
i'm trying to code a Stop-Limit order with easylanguage for Tradestation.
Unfortunately (!) TS don not provide a built -in stop-limit order to insert in strategies so as reported by tech support (!) one need to "mimic" the order and coding a "synth stop-limit" with Intrabar Order Generation (IOG)

I've tryied but IOG seems to overcomplicate simple task so maybe someone can help me to solve the issue...

below the code provided by the support

Code:
[intrabarordergeneration = true]
inputs:
LimitOffsetTicks( 5 ),
BarsToSetRange( 5 ) ;
variables:
OpenRange( false ),
OpenRangeHigh( 0 ),
OpenRangeLow( 0 ),
LongStopPrice( 0 ),
ShortStopPrice( 0 ),
Count( 0 ),
intrabarpersist EnterLong( false ),
intrabarpersist EnterShort( false ),
intrabarpersist EnteredToday( false ),
ATick( MinMove / PriceScale ),
MP( 0 ) ;

MP = MarketPosition ;

if MP <> 0 then
begin
EnteredToday = true ;
EnterLong = false ;
EnterShort = false ;
end ;

if Date <> Date[1] then
begin
OpenRangeHigh = High ;
OpenRangeLow = Low ;
Count = 1 ;
EnteredToday = false ;
end
else if Count < BarsToSetRange then
begin
OpenRangeHigh = MaxList( High, OpenRangeHigh ) ;
OpenRangeLow = MinList( Low, OpenRangeLow ) ;
Count += 1 ;
end
else if EnteredToday = false then
begin
if Close crosses above OpenRangeHigh + ATick then
begin
EnterLong = true ;
EnterShort = false ;
end
else if Close crosses below OpenRangeLow - ATick then
begin
EnterShort = true ;
EnterLong = false ;
end ;
end ;


if EnterLong then
begin
Buy next bar at OpenRangeHigh + ATick + LimitOffsetTicks * ATick Limit ;
end ;

if EnterShort then
begin
SellShort next bar at OpenRangeLow - ATick - LimitOffsetTicks * ATick Limit ;
end ;

if BarsSinceEntry = 5 then
begin
Sell next bar at Market ;
Buy to Cover next bar at Market ;
end ;

IBB = 1 tik
The code should trade the break of the range of the first candle of the day, regardless the timeframes - because Tradestation don't allow stop-limit orders in it's code (there not a built-in for stop-limit), and because the slippages are very very large (on MSFT i can have a 20 cents slippage for a stop order!), I was trying to "mimic" a stop-limit...to protect me from the exorbitant slippage provided....

(maybe easylanguage ond IOG are not the best to code something like that...maybe better drop Tradestation and go with a C# or C++ based coding language?)
 
Top