Stop-Limit order in easylanguage (tradestation)

Discussion in 'Automated Trading' started by w4rri0r, Dec 19, 2016.

  1. w4rri0r

    w4rri0r

    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: Dec 19, 2016
  2. tradestation and easylanguage sucks, learn a real programming language and use API's
     
  3. w4rri0r

    w4rri0r

    yea i know.......what would be your suggestion as broker and platform to accomplish the task?
     
  4. 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: Dec 20, 2016
  5. A_B

    A_B

    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)
     
  6. w4rri0r

    w4rri0r

    can't be used with intraday strategies
     
  7. w4rri0r

    w4rri0r

    since i'm not in US, i need to check if etrade open account to foreign people
    thanks
     
  8. algofy

    algofy

    why did you create a new account warning? You're asking the exact same, how do I code questions for your "innovative" indicator.
     
  9. w4rri0r

    w4rri0r

    ?
     
  10. comagnum

    comagnum

    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/
     
    #10     Dec 20, 2016