Stop-Limit order in easylanguage (tradestation)

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 TS support

[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 ;


The code should trade the break of the range of the first candle of the day, regardless the timeframes.
Sadly, it doesn't work......
 
Last edited:
checkout etrade api, it's free, works with all the programming languages. There's a learning curve but well supported, plus whatever programming language you choose will be usable elsewhere. ETrade has trailing stops.
Let me know what you think.
https://us.etrade.com/ctnt/dev-portal
 
Last edited:
Use StopLimitOrder function.

The StopLimitOrder function is used to configure and send a stop limit order using the order entry macro .PlaceOrder. You can call this function directly from your own EasyLanguage code to simplify the formatting and generation of macro orders.

Syntax:
StopLimitOrder(Frequency, Account, Action, SymbolCategory, Symbol, Quantity, Duration, GTDDate, StopPrice, LimitPrice)
 
Use StopLimitOrder function.

The StopLimitOrder function is used to configure and send a stop limit order using the order entry macro .PlaceOrder. You can call this function directly from your own EasyLanguage code to simplify the formatting and generation of macro orders.

Syntax:
StopLimitOrder(Frequency, Account, Action, SymbolCategory, Symbol, Quantity, Duration, GTDDate, StopPrice, LimitPrice)

can't be used with intraday strategies
 
why did you create a new account warning? You're asking the exact same, how do I code questions for your "innovative" indicator.
 
tradestation and easylanguage sucks, learn a real programming language and use API's
______________________________________________________________________

TS has a web API. I am discretionary so I could care less, but here you go anyway.


upload_2016-12-20_15-25-48.png


http://tradestation.github.io/webapi-docs/
 
Back
Top