Tradestation Easy Language Codes

Discussion in 'Automated Trading' started by gdtrader, Apr 9, 2012.

  1. Does anyone have TS codes they are willing to post or swap maybe from popular systems or books ? Looking to build several strategies new to easy language just helps to take bits and pieces from other codes I see.

    Anyone ever testing any systems from this book ?
    Professional Stock Trading: System Design and Automation
     
  2. Surdo

    Surdo

    You are really better off on The TradeStation forum for help coding, and tons of free EL.
     
  3. Rol

    Rol

    Sure, here is the Turtle System:

    Code:
    //heres the complete code to the 20-day strategy.
    //again, make sure you allow for *4* multiple entries
    //when *generated by different orders* in the "strategy properties".
    //also, on the "DV = (N*10000) * 10;" line, you have to change the "10000"
    //to the dollar value of one point. i was using 10000 on forex. 
    
    vars: N(0),StopLoss(1),DV(0),BB(0),AccountBalance(0),DollarRisk(0),LTT(0), 
    Tracker(0),LastTrade(0),HBP(0),LBP(0); input: InitialBalance(10000000); 
    
    /// Turtle 20-Day Breakout Replica ////////////////////////////////////// 
    
    if marketposition = 0 then begin 
    BB = 0; 
    
    N = AvgTrueRange(20);
    DV = N*BigPointValue; 
    AccountBalance = InitialBalance;	// + netprofit; 
    DollarRisk = AccountBalance * .01; 
    LTT = IntPortion(DollarRisk/DV); 
    StopLoss = 2 * DV * LTT; 
    if LastTrade = -1 then begin 
    buy LTT shares next bar highest(h,20) or higher; 
    buy LTT shares next bar highest(h,20) + (0.5*N) or higher; 
    buy LTT shares next bar highest(h,20) + (1.0*N) or higher; 
    buy LTT shares next bar highest(h,20) + (1.5*N) or higher; 
    sellshort LTT shares next bar lowest(l,20) or lower; 
    sellshort LTT shares next bar lowest(l,20) - (0.5*N) or lower; 
    sellshort LTT shares next bar lowest(l,20) - (1.0*N) or lower; 
    sellshort LTT shares next bar lowest(l,20) - (1.5*N) or lower; 
    end; 
    if LastTrade = 1 then begin 
    buy LTT shares next bar highest(h,55) or higher; 
    buy LTT shares next bar highest(h,55) + (0.5*N) or higher; 
    buy LTT shares next bar highest(h,55) + (1.0*N) or higher; 
    buy LTT shares next bar highest(h,55) + (1.5*N) or higher; 
    sellshort LTT shares next bar lowest(l,55) or lower; 
    sellshort LTT shares next bar lowest(l,55) - (0.5*N) or lower; 
    sellshort LTT shares next bar lowest(l,55) - (1.0*N) or lower; 
    sellshort LTT shares next bar lowest(l,55) - (1.5*N) or lower; 
    end; 
    end; 
    
    // PREVIOUS TRADE TRACKER 
    if HBP = 0 and h > highest(h,19)[1] then begin 
    Tracker = 1; HBP = h; LBP = 0; 
    end; 
    if LBP = 0 and l < lowest(l,19)[1] then begin 
    Tracker = -1; LBP = l; HBP = 0; 
    end; 
    if Tracker = 1 then begin 
    if l < HBP - (2*N) then LastTrade = -1; 
    if h > HBP + (4*N) then LastTrade = 1; 
    end; 
    if Tracker = -1 then begin 
    if h > LBP + (2*N) then LastTrade = -1; 
    if l < LBP - (4*N) then LastTrade = 1; 
    end; 
    
    // LONG 20 
    if LastTrade = -1 and marketposition = 1 then begin 
    BB = BB + 1; 
    if currentshares = LTT then begin 
    buy LTT shares next bar highest(h,20)[BB] + (0.5*N) or higher; 
    buy LTT shares next bar highest(h,20)[BB] + (1.0*N) or higher; 
    buy LTT shares next bar highest(h,20)[BB]+ (1.5*N) or higher; 
    end; 
    if currentshares = LTT * 2 then begin 
    buy LTT shares next bar highest(h,20)[BB] + (1.0*N) or higher; 
    buy LTT shares next bar highest(h,20)[BB] + (1.5*N) or higher; 
    end; 
    if currentshares = LTT * 3 then 
    buy LTT shares next bar highest(h,20)[BB] + (1.5*N) or higher; 
    end; 
    // LONG 55 
    if LastTrade = 1 and marketposition = 1 then begin 
    BB = BB + 1; 
    if currentshares = LTT then begin 
    buy LTT shares next bar highest(h,55)[BB] + (0.5*N) or higher; 
    buy LTT shares next bar highest(h,55)[BB] + (1.0*N) or higher; 
    buy LTT shares next bar highest(h,55)[BB]+ (1.5*N) or higher; 
    end; 
    if currentshares = LTT * 2 then begin 
    buy LTT shares next bar highest(h,55)[BB] + (1.0*N) or higher; 
    buy LTT shares next bar highest(h,55)[BB] + (1.5*N) or higher; 
    end; 
    if currentshares = LTT * 3 then 
    buy LTT shares next bar highest(h,55)[BB] + (1.5*N) or higher; 
    end; 
    sell ("out-S") next bar lowest(l,10) or lower; 
    
    // SHORT 20 
    if LastTrade = -1 and marketposition = -1 then begin 
    BB = BB + 1; 
    if currentshares = LTT then begin 
    sellshort LTT shares next bar lowest(l,20)[BB] - (0.5*N) or lower; 
    sellshort LTT shares next bar lowest(l,20)[BB] - (1.0*N) or lower; 
    sellshort LTT shares next bar lowest(l,20)[BB] - (1.5*N) or lower; 
    end; 
    if currentshares = LTT * 2 then begin 
    sellshort LTT shares next bar lowest(l,20)[BB] - (1.0*N) or lower; 
    sellshort LTT shares next bar lowest(l,20)[BB] - (1.5*N) or lower; 
    end; 
    if currentshares = LTT * 3 then 
    sellshort LTT shares next bar lowest(l,20)[BB] - (1.5*N) or lower; 
    end; 
    // SHORT 55 
    if LastTrade = 1 and marketposition = -1 then begin 
    BB = BB + 1; 
    if currentshares = LTT then begin 
    sellshort LTT shares next bar lowest(l,55)[BB] - (0.5*N) or lower; 
    sellshort LTT shares next bar lowest(l,55)[BB] - (1.0*N) or lower; 
    sellshort LTT shares next bar lowest(l,55)[BB] - (1.5*N) or lower; 
    end; 
    if currentshares = LTT * 2 then begin 
    sellshort LTT shares next bar lowest(l,55)[BB] - (1.0*N) or lower; 
    sellshort LTT shares next bar lowest(l,55)[BB] - (1.5*N) or lower; 
    end; 
    if currentshares = LTT * 3 then 
    sellshort LTT shares next bar lowest(l,55)[BB] - (1.5*N) or lower; 
    end; 
    buytocover ("out-B") next bar highest(h,10) or higher; 
    
    // STOPS 
    if currentshares = (2 * LTT) then StopLoss = DV * 3.5 * LTT; 
    if currentshares = (3 * LTT) then StopLoss = DV * 4.5 * LTT; 
    if currentshares = (4 * LTT) then StopLoss = DV * 5.0 * LTT; 
    setstoploss (StopLoss); 
    
    // COMMENTARY 
    commentary ("LTT: ",LTT,Newline); 
    commentary ("CurrentShares: ",CurrentShares,Newline); 
    commentary ("StopLoss: ",StopLoss,Newline); 
    commentary ("AccountBalance:",AccountBalance,NewLine); 
    commentary ("LastTrade: ",LastTrade,NewLine);
    
    
     
  4. gaj

    gaj