TradeStation 9.5 - Strange strategy execution

Discussion in 'Strategy Building' started by eddyb, Oct 11, 2020.

  1. eddyb

    eddyb

    Hmm, but this is my exit code:


    Code:
            If Close < Average(Close,50) and Close[1] > Average(Close,50) then
                Print("Selling") ;
                Sell next bar at market ;
    So essentially I'm saying if we have an open position and then Close falls below the Average then we sell next bar at market which unless I'm mistaken (and I might be) that should sell an equal amount to what it bought and exit the trade?

    Thanks
     
    #11     Oct 12, 2020
  2. SunTrader

    SunTrader

    Try instead:-

    Code:
    
    If MarketPosition = 1 and 
    Close < Average(Close,50) and Close[1] > Average(Close,50) then
                Print("Selling") ;
                Sell next bar at market ;
    
     
    #12     Oct 12, 2020
  3. eddyb

    eddyb

    Same issue I'm afraid. I'm wondering if there is something wrong with the platform as I have to remove and add the strategy each time I want to test it as well, otherwise it won't appear on the chart. This kind of logic also works fine in other backtesting tools. I've submitted a ticket with TradeStation Global anyway.

    Thanks for the help.
     
    #13     Oct 13, 2020
  4. longshort

    longshort

    Your code is the issue, the conditional only worked on the print statement. Try it like this:
    Code:
    If Close < Average(Close,50) and Close[1] > Average(Close,50) then begin
        Print("Selling") ;
        Sell next bar at market ;
    end;
     
    #14     Oct 13, 2020
    lizmerrill likes this.
  5. eddyb

    eddyb

    Aha thats fixed it! Thankyou! I’m new to EasyLanguage and should have checked the if syntax.
     
    #15     Oct 14, 2020
  6. MarkBrown

    MarkBrown

    ok some of your problem is marketposition < it only occurs after the fact. if you want market position to work make it a variable

    var:mp(0):

    then define what mp is for example;

    if average(c, 10) > average(c, 10)[1]then mp = 1;
     
    #16     Oct 17, 2020
  7. 1. Use Tradestation 9.5, NOT TS 10.0.
    2. Learn at least the rudiments of Easy Language. There are many Youtube videos.
    3. Create a strategy that has a chance of working. (Yours doesn't)

    Best wishes...
     
    #17     Oct 17, 2020
  8.  
    #18     Jun 13, 2021