Big Mike's Trading Forum
 

Go Back   Big Mike's Trading Forum

> Trading Forums > Platforms and Indicators > TradeStation > EasyLanguage Programming


Notices
     

trailing stop la LeBeau
Started:June 24th, 2010 (04:21 PM) by kiasom Views / Replies:3,275 / 4
Last Reply:May 13th, 2011 (05:13 PM) Attachments:0

Welcome to Big Mike's Trading Forum.

Welcome, Guest!

This forum was established to help traders by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

BMT is fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.


You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike
     

Reply
 
Thread Tools Search this Thread

trailing stop la LeBeau

Old June 24th, 2010, 04:21 PM   #1 (permalink)
Elite Member
Stockholm
 
Trading Experience: Intermediate
Platform: MC
Favorite Instrument: fx
 
Posts: 15 since Apr 2010
Thanks: 103 given, 21 received

trailing stop la LeBeau

This is a package of trailing stops by Chuck LeBeau.
It's a HH/LL stop (called a Chandelier' stop), a Parabolic stop, and a so called Yo-yo stop. They work together, all of the stops are applied at once and the closest one to the price becomes the dominant/active one.
Below is code for a Stops Strategy, and in the next post an indicator that plots what the signal is doing.

Set Strategy MaxBarsBack = 150 -- set indicator same *

If you use Range or Renko Bars - The Chandelier Stop turns into a conventional Trailing Stop.
The indicator will not show the stops unless the chart is in a trade position.
The indicator has the option of displaying all of the stop plots or just the plot closest
to the price - using the True/False "Show_All_Stops" switch in the indicator format.

 
Code
//***************************************************************************************
// LeBeau Stops Strategy (!G_LeBeau_Stops)                                                *
// JRG 2004, 2005, v8.1i, 20 Jul 2005                                                    *
//***************************************************************************************
//    NOTES:    Implements Chuck LeBeau's family of stop loss techniques as briefed at         *
//                TradeStation World 2004.                                                *
//            Includes protective stop on entry bar equal to YoYo stop.                    *
//            Allows negative numbers for optimization -- converts to absolute for        *
//                strategy execution.  ex = from -10 to -5, step 1.                        *
//            Sends strategy INPUT setings to compatible indicator for visual plotting    * 
//                using "native" Global Variables.  GlobalVariable.dll must be installed    *
//                in the "TradeStation/Program" folder.                                    *
{Set Strategy MaxBarsBack = 150 -- set indicator same                        *
All of the stops are applied at once -- 
The closest one to the price (tightest) becomes the dominant/active one.    
If you use Range or Renko Bars - The Chandelier Stop turns into a conventional Trailing Stop.
The indicator will not show the stops unless the chart is in a trade position.
The indicator has the option of displaying all of the stop plots or just the plot closest 
to the price - using the True/False "Show_All_Stops" switch in the indicator format. 
CurrentBar=2 is used to make sure the strategy is fully loaded before the GV is retrieved.
}

    [IntrabarOrderGeneration = True]

    INPUTS:    Chandelier_AvgRange        (2.5),
            YoYo_AvgRange            (2),
            Times_Touched            (10),        // MIT only if Chandelier and YoYo
            Parabolic_Accel_Factor    (.05),        // equity default -- for futures use 0.01 +-
            AvgRange_Length            (21),
            Profit_AvgRange            (1),
            Profit_Switch_Factor    (0.6),
             Commentary_On              ( False ) ;                                

 VARIABLES:                 aChandelier_AvgRange( AbsValue( Chandelier_AvgRange ) ),    //----------------------------------|
                            aYoYo_AvgRange        ( AbsValue( YoYo_AvgRange ) ),            //                                    |
                            Parabolic_AF        ( AbsValue( Parabolic_Accel_Factor ) ),    // convert inputs to absolute value    |
                            aAvgRange_Length    ( AbsValue( AvgRange_Length) ),            //                                    |
                            aProfit_AvgRange    ( AbsValue( Profit_AvgRange ) ),        //----------------------------------|
                            Acceleration_Factor    ( Parabolic_AF ),
                            Parabolic_AF_Limit    ( Parabolic_AF * 10 ),    // set limit 10x factor
                            Average_Range        ( 0 ),
                            Market_Position        ( 0 ),
            IntrabarPersist Trade_High            ( 0 ),        // highest high of current trade
            IntrabarPersist    Trade_Low            ( 0 ),        // lowest low of current trade
                            YoYo_Amount            ( 0 ),        // YoYo stop amount
                            YoYo_Price            ( 0 ),        // pin price to last bar close
            IntrabarPersist Chandelier_Stop        ( 0 ),        //--------------|
            IntrabarPersist YoYo_Stop            ( 0 ),        // stop prices    |
                            Parabolic_Stop        ( 0 ),        //--------------|
                            Profit_Amount        ( 0 ),
            IntrabarPersist    Profit_Switch        ( False ),    // point at which Chandalier Stop tightens
                            Not_Optimizing        ( True ),
                            GV_Name                ( NumToStr( AbsValue( GetAppInfo( aiAppID ) ), 0 ) ),
                            PT_On                ( False ),    // get from PT_MIT strategy
            IntrabarPersist Chandelier_Touched    ( 0 ),
            IntrabarPersist YoYo_Touched        ( 0 ),
            IntrabarPersist Bar_Number            ( 0 ),
                            PT_Range_Mult        ( aProfit_AvgRange ),
                            PT_Range_Length        ( aAvgRange_Length ),
                            PT_Average_Range    ( 0 ),
                            Avg_Entry_Price        ( 0 ),
                            aProfit_Switch_Fac     ( AbsValue( Profit_Switch_Factor ) ),
                            New_Entry            ( False ) ;

//***** Housekeeping *****
    if CurrentBar = 1 then
        Not_Optimizing = GetAppInfo( aiOptimizing ) <> 1 ;
//------------------------------------------------------------------------------------------|
//    This code gets the PT_MIT strategy settings to calculate the PT settings of the LeBeau    |
//        Stops.  If no PT_MIT present, then uses local LeBeau settings.                      |    
//------------------------------------------------------------------------------------------|
    if CurrentBar = 2 then
        begin
            PT_Range_Mult = GVGetNamedDouble( GV_Name + "PT_Range_Mult", aProfit_AvgRange ) ;
            PT_Range_Length = GVGetNamedDouble( GV_Name + "PT_Range_Length", aAvgRange_Length ) ;
            if Not_Optimizing then
                begin
                    Value1 = GVSetNamedDouble( GV_Name + "Chandelier_AvgRange", aChandelier_AvgRange ) ;
                    Value2 = GVSetNamedDouble( GV_Name + "YoYo_AvgRange", aYoYo_AvgRange ) ;
                    Value3 = GVSetNamedDouble( GV_Name + "Parabolic_AF", Parabolic_AF ) ;
                    Value4 = GVSetNamedDouble( GV_Name + "LeBeau_AvgRange_Length", aAvgRange_Length ) ;                    
                    Value6 = GVSetNamedDouble( GV_Name + "Parabolic_AF_Limit",Parabolic_AF_Limit ) ; 
                    Value5 = GVSetNamedDouble( GV_Name + "Profit_AvgRange", PT_Range_Mult ) ;
                    Value7 = GVSetNamedDouble( GV_Name + "LePT_Range_Length", PT_Range_length ) ;
                    Value8 = GVSetNamedDouble( GV_Name + "Profit_Switch_Factor", aProfit_Switch_Fac ) ;
                end ;    // not optimizing
        end ;    // 2nd bar housekeeping

//***** Compute Stops *****
    Market_Position = MarketPosition ;        // in order to access historical bar market position
    if BarStatus(1) = 2 then                // calc only once per bar
        begin
            Average_Range = AvgRange( aAvgRange_Length ) ;
            Avg_Entry_Price = AvgEntryPrice ;
            New_Entry = Avg_Entry_Price[1] <> Avg_Entry_Price ;
            PT_Average_Range = AvgRange( PT_Range_Length ) ;
            Profit_Amount = roundInst( PT_Range_Mult * PT_Average_Range) ;
            YoYo_Amount = aYoYo_AvgRange * Average_Range ;
        end            // calc once
    else if Bar_Number <> CurrentBar then        // calc on first tick of new bar formation
        begin
            Bar_Number = CurrentBar ;
            if Not_Optimizing and
                GetAppInfo( aiRealTimeCalc ) = 1 then
                begin
                    Chandelier_Touched = 0 ;
                    YoYo_Touched = 0 ;
                end        // reset at end of bar if not optimizing
            else begin
                    Chandelier_Touched = Times_Touched ;
                    YoYo_Touched = Times_Touched ;
                end ;    // if optimizing, set to limit
        end ;    // reset touched each new bar

    if Market_Position[1] <> 0 then
        YoYo_Price = Close[1] 
    else YoYo_Price = Open ;
    if Market_Position <> 0 then            // eval market position on current bar
        begin

    //*** Long Position ***
            if Market_Position = 1 then    
                begin
                    if Market_Position[1] <> 1 or
                        New_Entry then        // eval market position on prior bar and reset variables if 
                        begin
                            Profit_Switch = False ;        // reset profit switch
                            Trade_High = High ;            // reset trade high
                        end        // reset
                    else if High > Trade_High then        // find new high
                        Trade_High = High ;
                    
        //* Chandelier Stop *    
                    if Profit_Switch or                    // if switch = true
                        Trade_High >= AvgEntryPrice + ( Profit_Amount * aProfit_Switch_Fac ) then
                            begin
                                Profit_Switch = True ;
                                Chandelier_Stop = roundInst( Trade_High - ( aChandelier_AvgRange * Average_Range * aProfit_Switch_Fac )) ;// tighten stop
                            end        // tighten Chandelier stop when profit point exceeded
                    else Chandelier_Stop = roundInst( Trade_High - ( aChandelier_AvgRange * Average_Range )) ;// normal stop
                    if Market_Position[1] = 1 and
                        New_Entry = False and
                        Chandelier_Stop < Chandelier_Stop[1] then
                            Chandelier_Stop = Chandelier_Stop[1] ;        // prevent retracement
                    if Close <= Chandelier_Stop then 
                        Chandelier_Touched = Chandelier_Touched + 1 ;

        //* YoYo Stop *
                    YoYo_Stop = roundInst( YoYo_Price - YoYo_Amount) ;
                    if Close <= YoYo_Stop then 
                        YoYo_Touched = YoYo_Touched + 1 ;

        //* Parabolic Stop *
                    if Market_Position[1] <> 1 or
                        New_Entry then
                            begin
                                Parabolic_Stop = Chandelier_Stop ;        // initial setting
//                                    roundInst( AvgEntryPrice - ( aChandelier_AvgRange * Average_Range ), 2 ) ;    // tie to entry price
                                Acceleration_Factor = Parabolic_AF ;
                            end            // eval market postion on prior bar
                        else begin
                            {if BarStatus(1) = 2 then
                                begin}
                                    if Trade_High > Trade_High[1] and
                                        Acceleration_Factor < Parabolic_AF_Limit then
                                            Acceleration_Factor = Acceleration_Factor + MinList( Parabolic_AF, Parabolic_AF_Limit - Acceleration_Factor ) ;
                                    Parabolic_Stop = Parabolic_Stop + Acceleration_Factor * ( Trade_High - Parabolic_Stop ) ;
                                     if Parabolic_Stop > Low then     // force stop <= low of last bar
                                        Parabolic_Stop = Low ;
                                {end ;}     // update only at end of bar
                            end ;        // long parabolic stop 
                end            // long market postion

    //*** Short Position ***
            else begin        // short market position
                if Market_Position[1] <> -1 or
                    New_Entry then        // eval market position on prior bar
                        begin
                            Profit_Switch = False ;        // reset profit switch
                            Trade_Low = Low ;        // reset trade low
                        end
                else if Low < Trade_Low then        // find new low
                    Trade_Low = Low ;
                                    
        //* Chandelier Stop *
                if Profit_Switch or        // if switch  = true
                    Trade_Low <= AvgEntryPrice - ( Profit_Amount * aProfit_Switch_Fac ) then
                        begin
                            Profit_Switch = True ; 
                            Chandelier_Stop = roundInst( Trade_Low + ( aChandelier_AvgRange * Average_Range * aProfit_Switch_Fac )) ;// tighten stop
                        end        // tighten Chandelier stop when profit point exceeded
                else Chandelier_Stop = roundInst( Trade_Low + ( aChandelier_AvgRange * Average_Range )) ;    // normal stop
                if Market_Position[1] = -1 and
                    New_Entry = False and 
                    Chandelier_Stop > Chandelier_Stop[1] then
                        Chandelier_Stop = Chandelier_Stop[1] ;    // prevent retracement
                if Close >= Chandelier_Stop then
                    Chandelier_Touched = Chandelier_Touched + 1 ;

        //* YoYo Stop *
                YoYo_Stop = roundInst( YoYo_Price + YoYo_Amount) ;
                if Close >= YoYo_Stop then 
                    YoYo_Touched = YoYo_Touched + 1 ;

        //* Parabolic Stop *
                if Market_Position[1] <> -1 or
                    New_Entry then
                        begin
                            Parabolic_Stop = Chandelier_Stop ;
//                                roundInst( AvgEntryPrice + ( aChandelier_AvgRange * Average_Range ), 2 ) ;    // tie to entry price
                            Acceleration_Factor = Parabolic_AF ;
                        end            // eval market postion on prior bar
                    else begin
                        {if BarStatus(1) = 2 then
                            begin}
                                Parabolic_Stop = Parabolic_Stop + Acceleration_Factor * ( Trade_Low - Parabolic_Stop ) ;
                                if Trade_Low < Trade_Low[1] and
                                    Acceleration_Factor < Parabolic_AF_Limit then
                                        Acceleration_Factor = Acceleration_Factor + MinList( Parabolic_AF, Parabolic_AF_Limit - Acceleration_Factor ) ;
                                if Parabolic_Stop < High[1] then
                                    Parabolic_Stop = High[1] ;
                            {end ;}    // only once per bar
                        end ;        // short parabolic stop
                end ;         // short market position 
                
//***** Exits *****
            if Market_Position = 1 then
                begin
                      if Chandelier_Touched >= Times_Touched then
                        Sell ( "LX_Cdlr" ) currentshares shares next bar at Chandelier_Stop STOP ;
                    if YoYo_Touched >= Times_Touched then
                         Sell( "LX_YoYo" ) currentshares shares next bar at YoYo_Stop STOP ;
                    Sell ( "LX_Pblc" ) currentshares shares next bar at Parabolic_Stop STOP ;
                end        // long stops
            else begin
                      if Chandelier_Touched >= Times_Touched then
                        BuyToCover ( "SXCdlr" ) currentshares shares next bar at Chandelier_Stop STOP ;
                    if YoYo_Touched >= Times_Touched then                    
                        BuyToCover ( "SXYoYo" ) currentshares shares next bar at YoYo_Stop STOP ;
                    BuyToCover ( "SXPblc" ) currentshares shares next bar at Parabolic_Stop STOP ;
                end ;        // short stops
        end ;         // set stops -- MarketPostion <> 0

//***** Commentary *****
    if Commentary_On and
        AtCommentaryBar then
            Commentary( 
                ( Date - ( Year( Date ) *  10000 ) ):0:0,     Time:5:0, 
                " -- BarNumber = ",                         CurrentBar:5:0,             NewLine,
                "High = ",                                     High,                         NewLine,
                "Low = ",                                     Low,                         NewLine,
                "Open = ",                                     Open,                         NewLine,
                "Close = ",                                 Close,                         NewLine,
                "PT_On = ",                                 PT_On,                         NewLine,
                "AvgRange Length = ",                         aAvgRange_Length:0:0,         NewLine,
                "AvgRange = ",                                 Average_Range:0:2,             NewLine,
                "Chandelier AvgRange Multip lier = ",         aChandelier_AvgRange:0:2,     NewLine,
                "YoYo AvgRange Multiplier =",                 aYoYo_AvgRange:0:2,         NewLine,
                "Times Touched = ",                            Times_Touched:0:2,            NewLine,
                "Parabolic Acceleration Factor = ",         Parabolic_AF:0:3,             NewLine,
                "Parabolic AF Limit = ",                     Parabolic_AF_Limit:0:2,     NewLine,
                "Acceleration Factor = ",                    Acceleration_Factor:0:3,    NewLine,
                "Profit Point AvgRange Multiplier = ",         PT_Range_Mult:0:2,             NewLine,
                "Profit Switch = ",                         Profit_Switch,                 Newline,
                "Market Position = ",                         Market_Position:0:0,         NewLine,
                "Trade High = ",                             Trade_High:0:2,             NewLine,
                "Trade Low = ",                              Trade_Low:0:2,                 NewLine,
                "Profit Amount = ",                         Profit_Amount:0:2,             NewLine,
                "Chandelier Stop = ",                         Chandelier_Stop:0:2,         NewLine,
                "YoYo Stop = ",                             YoYo_Stop:0:2,                 NewLine,
                "Parabolic Stop = ",                         Parabolic_Stop:0:2,         NewLine
                ) ;

// ***** Print 2 Log 4 Debug *****
 Variables: IntrabarPersist    Count( 0 );

    if BarStatus(1) = 2 then 
        Count = 0 ;
    
    if Not_Optimizing and
        LBOC and
        ( Chandelier_Touched <> 0 or 
        YoYo_Touched <> 0 ) and
        Market_Position <> 0 then
            begin
                Count = Count + 1 ;
                Print(
                    Count:0:0, "  ",
                    "Bar # ", CurrentBar:0:0, "  ",
                    TimeToString( ComputerDateTime ), 
                    "  Setting = ",    Times_Touched:0:0, 
                    "  Cdlr = ", Chandelier_Touched:0:0,
                    "  YoYo = ", YoYo_Touched:0:0, "  ",
                    Close
                    ) ;
            end ;
I found this on the TS forum, hope it's ok to repost here?

Reply With Quote
     
The following 4 users say Thank You to kiasom for this post:
     

Old June 24th, 2010, 04:21 PM   #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

     

Old June 24th, 2010, 04:29 PM   #3 (permalink)
Elite Member
Stockholm
 
Trading Experience: Intermediate
Platform: MC
Favorite Instrument: fx
 
Posts: 15 since Apr 2010
Thanks: 103 given, 21 received


Here's the indicator, that plots what the signal reacts on:

 
Code
// LeBeau Stops Indicator (!G_LeBeau_Stops)                                                *
// JRG 2004, 2005, v8.1i, 20 Jul 2005                                                    *
//    NOTES:    Implements Chuck LeBeau's family of stop loss techniques as briefed at         *
//                TradeStation World 2004                                                    *
//            Sends setings to compatible indicator for visual plotting using Global         *
//                Variables                                                                *

{Set Strategy MaxBarsBack = 150 -- set indicator same                        *
All of the stops are applied at once --
the closest one to the price (tightest) becomes the dominant/active one.    
if you use Range or Renko Bars - The Chandelier Stop turns into a conventional Trailing Stop.
The indicator will not show the stops unless the chart is in a trade position.
The indicator has the option of displaying all of the stop plots or just the plot closest
to the price - using the True/False "Show_All_Stops" switch in the indicator format.
CurrentBar=2 is used to make sure the strategy is fully loaded before the GV is retrieved.
}
INPUTS: Show_All_Stops    ( False ),
            Commentary_On    ( False ) ;
    
 VARIABLES:             Chandelier_AvgRange    ( 3 ),        // inputs from strategy
                             YoYo_AvgRange        ( 2 ),
                            Parabolic_AF        ( 0 ),
                            Acceleration_Factor    ( 0.02 ),
                            Parabolic_AF_Limit    ( 0 ),                    
                            AvgRange_Length        ( 21 ),
                            Average_Range        ( 0 ),
                             Market_Position        ( 0 ),
            IntrabarPersist    Trade_High            ( 0 ),
            IntrabarPersist    Trade_Low            ( 0 ),
            IntrabarPersist    YoYo_Amount            ( 0 ),        // YoYo stop amount
                            YoYo_Price            ( 0 ),        // pin price to last bar close
            IntrabarPersist    Chandelier_Stop        ( 0 ),
            IntrabarPersist    YoYo_Stop            ( 0 ),
                            Parabolic_Stop        ( 0 ),
                            Profit_AvgRange        ( 0 ),
                            PT_Average_Range    ( 0 ),
                            PT_Range_Length        ( 21 ),
                            Profit_Amount        ( 0 ),
                            Profit_Switch_Fac    ( 1 ),
                            EntryBar_Stop        ( 0 ),
            IntrabarPersist    Profit_Switch        ( False ),
                            GV_Name                ( NumToStr( AbsValue( GetAppInfo( aiAppID ) ), 0 ) ),    // 19 = aiWindowID
                            Avg_Entry_Price        ( 0 ),
                            New_Entry            ( False ) ;

//***** Housekeeping *****
    if CurrentBar = 2 then        // get Inputs from Strategy
        begin
            Chandelier_AvgRange    = GVGetNamedDouble( GV_Name + "Chandelier_AvgRange", 3 ) ;        // get strategy settings from global memory
             YoYo_AvgRange        = GVGetNamedDouble( GV_Name + "YoYo_AvgRange", 2 ) ;
            Parabolic_AF        = GVGetNamedDouble( GV_Name + "Parabolic_AF", 0.02 ) ;
            AvgRange_Length        = GVGetNamedDouble( GV_Name + "LeBeau_AvgRange_Length", 21 ) ;
            Parabolic_AF_Limit  = GVGetNamedDouble( GV_Name + "Parabolic_AF_Limit", 10 ) ;        // set limit 10x factor
            Profit_AvgRange        = GVGetNamedDouble( GV_Name + "Profit_AvgRange", 4 ) ;
            Profit_Switch_Fac     = GVGetNamedDouble( GV_Name + "Profit_Switch_Factor", 1 ) ;
            PT_Range_Length        = GVGetNamedDouble( GV_Name + "LePT_Range_Length", AvgRange_Length ) ;
        end ;        // housekeeping

//***** Compute Stops *****
    Market_Position = I_MarketPosition ;    // in order to access historical bar market positions
    if BarStatus(1) = 2 then                // calc only once per bar
        begin
            Average_Range = AvgRange( AvgRange_Length ) ;
            Avg_Entry_Price = I_AvgEntryPrice ;
            New_Entry = Avg_Entry_Price[1] <> Avg_Entry_Price ;
            PT_Average_Range = AvgRange( PT_Range_Length ) ;
            Profit_Amount = roundInst( Profit_AvgRange * PT_Average_Range) ;
            YoYo_Amount = YoYo_AvgRange * Average_Range ;
        end ;        // calc once
    if Market_Position[1] <> 0 then
        YoYo_Price = Close[1]
    else
        YoYo_Price = Open ;

    if Market_Position <> 0 then            // eval market position on current bar
        begin

    //*** Long Position ***
            if Market_Position = 1 then    
                begin
                    if Market_Position[1] <> 1 or        // eval market position on prior bar and reset variables if
                        New_Entry then
                            begin
                                Profit_Switch = False ;        // reset profit switch
                                Trade_High = High ;            // reset trade high
                            end        // reset
                    else if High > Trade_High then        // find new high
                        Trade_High = High ;
                    
        //* Chandelier Stop *
                    if Profit_Switch or                    // if switch = true
                        Trade_high >= I_AvgEntryPrice + ( Profit_Amount * Profit_Switch_Fac ) then
                            begin
                                Profit_Switch = True ;
                                Chandelier_Stop = roundInst(Trade_High-(Chandelier_AvgRange*Average_Range*Profit_Switch_Fac)) ; // tighten stop
                            end        // tighten Chandelier stop when profit point exceeded
                    else Chandelier_Stop = roundInst(Trade_High -(Chandelier_AvgRange*Average_Range)) ; // normal stop
                    if Market_Position[1] = 1 and
                        New_Entry = False and
                        Chandelier_Stop < Chandelier_Stop[1] then
                            Chandelier_Stop = Chandelier_Stop[1] ;        // prevent retracement

        //* YoYo Stop *
                    YoYo_Stop = roundInst( YoYo_Price - YoYo_Amount) ;

        //* Parabolic Stop *
                    if Market_Position[1] <> 1 or
                        New_Entry then
                            begin
                                Parabolic_Stop = Chandelier_Stop ;        // initial setting
//                                    roundInst( I_AvgEntryPrice - ( Chandelier_AvgRange * Average_Range ), 2 ) ;    // tie to entry price
                                Acceleration_Factor = Parabolic_AF ;
                            end            // eval market postion on prior bar
                        else begin
                            {if BarStatus(1) = 2 then
                                begin}
                                    if Trade_High > Trade_High[1] and
                                        Acceleration_Factor < Parabolic_AF_Limit then
                                            Acceleration_Factor = Acceleration_Factor + MinList( Parabolic_AF, Parabolic_AF_Limit - Acceleration_Factor ) ;
                                    Parabolic_Stop = Parabolic_Stop + Acceleration_Factor * ( Trade_High - Parabolic_Stop ) ;
                                     if Parabolic_Stop > Low then     // force stop <= low of last bar
                                        Parabolic_Stop = Low ;
                                {end ;}     // update only at end of bar
                            end ;        // long parabolic stop

                end            // long market postion

    //*** Short Position ***
            else begin        // short market position
                if Market_Position[1] <> -1 or        // eval market position on prior bar
                    New_Entry then
                        begin
                            Profit_Switch = False ;        // reset profit switch
                            Trade_Low = Low ;        // reset trade low
                        end
                else if Low < Trade_Low then        // find new low
                    Trade_Low = Low ;
                                    
        //* Chandelier Stop *
                if Profit_Switch or        // if switch  = true
                    Trade_Low <= I_AvgEntryPrice - ( Profit_Amount * Profit_Switch_Fac ) then
                        begin
                            Profit_Switch = True ;
                            Chandelier_Stop = roundInst(Trade_Low+(Chandelier_AvgRange*Average_Range*Profit_Switch_Fac)) ;// tighten stop
                        end        // tighten Chandelier stop when profit point exceeded
                else Chandelier_Stop = roundInst(Trade_Low+(Chandelier_AvgRange * Average_Range )) ;            // normal stop
                if Market_Position[1] = -1 and
                    New_Entry = False and
                    Chandelier_Stop > Chandelier_Stop[1] then
                        Chandelier_Stop = Chandelier_Stop[1] ;        // prevent retracement

        //* YoYo Stop *
                YoYo_Stop = roundInst(YoYo_Price+ YoYo_Amount) ;

        //* Parabolic Stop *
                if Market_Position[1] <> -1 OR
                    New_Entry then
                        begin
                            Parabolic_Stop = Chandelier_Stop ;
//                                    roundInst( I_AvgEntryPrice + ( Chandelier_AvgRange * Average_Range ), 2 ) ;    // tie to entry price                        
                            
                            Acceleration_Factor = Parabolic_AF ;
                        end            // eval market postion on prior bar
                    else begin
                            {if BarStatus(1) = 2 then
                                begin}
                                    Parabolic_Stop = Parabolic_Stop + Acceleration_Factor * ( Trade_Low - Parabolic_Stop ) ;
                                    if Trade_Low < Trade_Low[1] and
                                        Acceleration_Factor < Parabolic_AF_Limit then
                                            Acceleration_Factor = Acceleration_Factor + MinList( Parabolic_AF, Parabolic_AF_Limit - Acceleration_Factor ) ;
                                    if Parabolic_Stop < High then
                                        Parabolic_Stop = High ;
                                {end ;}    // run once per bar
                        end ;        // short parabolic stop
                end ;         // short market position
            end ;        // in position

//***** Plots *****
    if Market_Position[1] <> 0 or
        Market_Position <> 0 then
            begin
                if Show_All_Stops then
                    begin
                        Plot2( Parabolic_Stop, "Parabolic", Red ) ;
                        Plot3( YoYo_Stop, "YoYo", Cyan ) ;
                        Plot4( Chandelier_Stop, "Chandelier", White ) ;
                    end     // show all stops
                else begin        // plot only closest stop
                    if Market_Position = 1 or
                        Market_Position[1] = 1 then
                            begin
                                if Chandelier_Stop > YoYo_Stop and
                                    Chandelier_Stop > Parabolic_Stop then
                                        Plot4( Chandelier_Stop, "Chandelier", White )
                                else if YoYo_Stop > Parabolic_Stop then
                                        Plot3( YoYo_Stop, "YoYo", Cyan )
                                    else Plot2( Parabolic_Stop, "Parabolic", Red ) ;
                            end ;        //  closest long stop
                    if Market_Position = -1 or
                        Market_Position[1] = -1 then
                            begin
                                if Chandelier_Stop < YoYo_Stop and
                                    Chandelier_Stop < Parabolic_Stop then
                                        Plot4( Chandelier_Stop, "Chandelier", White )
                                else if YoYo_Stop < Parabolic_Stop then
                                        Plot3( YoYo_Stop, "YoYo", Cyan )
                                    else Plot2( Parabolic_Stop, "Parabolic", Red ) ;
                            end ;        //  closest short stop
                    end ;        // only closest stop
            end ;        // plots

Reply With Quote
     
The following 2 users say Thank You to kiasom for this post:
     

Old June 24th, 2010, 05:41 PM   #4 (permalink)
Elite Member
Stockholm
 
Trading Experience: Intermediate
Platform: MC
Favorite Instrument: fx
 
Posts: 15 since Apr 2010
Thanks: 103 given, 21 received

Here's one more variant, with just the Chandelier TS.
This is more professionally coded, with the signal drawing the plots as well (no need for a separate indicator).

 
Code
IF BARTYPE < 2 or bartype=5 THEN BEGIN //Intraday Data1 Only, or point bars

     
inputs: 
    CSFactor( 3 ), 
    CSLength( 20 ); 
 
variables: 
    MP( 0 ), 
    HH( 0 ), 
    LL( 0 ), 
    LeBeauStopHH( 0 ), 
    LeBeauStopLL( 0 ), 
    LBSHlast( 0 ), 
    LBSLlast( 0 ), 
    TL_LBCS( -1 ) ; 
 
{ Demo/Test Entry }  
if CurrentBar = 200 then Buy next bar at market ;  
//if CurrentBar = 200 then SellShort next bar at market ;  
 
MP = MarketPosition ; 
 
if MP[1] = 1 then 
    begin 
    { Display LeBeau Stop HH } 
    TL_LBCS = TL_New( D[1], T[1], LBSHlast, D, T, LeBeauStopHH ) ; 
    TL_SetColor( TL_LBCS, Magenta ) ; 
    TL_SetStyle( TL_LBCS, 3 ) ; 
    end 
 
else if MP[1] = -1 then 
    begin 
    { Display LeBeau Stop LL } 
    TL_LBCS = TL_New( D[1], T[1], LBSLlast, D, T, LeBeauStopLL ) ; //draws from bar to bar
    TL_SetColor( TL_LBCS, Yellow ) ; 
    TL_SetStyle( TL_LBCS, 3 ) ; 
    end ; 
 
if MP = 1 then 
    begin 
 
    { Demo LeBeau Chandelier Long Stop } 
    if MP[1] = 1 then 
        HH = MaxList( HH, High ) 
    else 
        HH = High ; 
    LBSHlast = LeBeauStopHH ; 
    LeBeauStopHH = HH - CSFactor * XAverage( Range, CSLength ) ; 
    if MP[1] <> 1 then LBSHlast = LeBeauStopHH ; 
 
    { LeBeau Stops - Reverse Long to Short } 
    SellShort ( "SX" ) next bar at LeBeauStopHH stop ; 
 
    end 
 
else if MP = -1 then 
    begin 
 
    { Demo LeBeau Chandelier Short Stop } 
    if MP[1] = -1 then 
        LL = MinList( LL, Low ) 
    else 
        LL = Low ; 
    LBSLlast = LeBeauStopLL ; 
    LeBeauStopLL = LL + CSFactor * XAverage( Range, CSLength ) ; 
    if MP[1] <> -1 then LBSLlast = LeBeauStopLL ; 
 
    { LeBeau Stops - Reverse Short to Long } 
    Buy ( "LX" ) next bar at LeBeauStopLL stop ; 
     
    end ; 
 
END ;

Reply With Quote
     
The following 2 users say Thank You to kiasom for this post:
     

Old May 13th, 2011, 05:13 PM   #5 (permalink)
Elite Member
Dallas, Texas, USA
 
Trading Experience: Beginner
Platform: NT 6.5 & Tradestation
Favorite Instrument: Equities & ES
 
Posts: 42 since Sep 2010
Thanks: 19 given, 7 received

Hello Kaisom,

Thanks much for the indicator & Strategy. when I tried to compile the codes, both the indicator & strategy are getting stuck at

"GVSetNamedDouble" as unknown identifier.

What could be the issue? Pl advice.

Reply With Quote
     

Reply



Tags
buytocover, chart, code, color, compile, currentshares, data, demo, dll, easylanguage, entry, equity, es, execution, format, futures, global, global variables, high, historical, indicator, indicators, intraday, limit, list, low, market, mit, mp, multicharts, neoticker, open, optimization, option, order, package, parabolic, price, price_action, profit, program, programming, puts, range, renko, reverse, settings, signal, stop, stop loss, stops, strategy, techniques, tick, trade, trades, tradestation, trailing, trailing stop, trailing stops, update
     

Big Mike's Trading Forum > Trading Forums > Platforms and Indicators > TradeStation > EasyLanguage Programming > trailing stop la LeBeau

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads
Thread Thread Starter Forum Replies Last Post
Limit Order and Trailing Stop Tiger45 NinjaTrader Programming 7 May 9th, 2013 05:57 AM
Trailing stop following an indicator nanobiotech NinjaTrader Programming 9 October 3rd, 2011 09:50 AM
Drawing trailing stop on chart protrader007 NinjaTrader Programming 6 July 22nd, 2011 12:47 AM
Trailing Stop - how to use by trading futures Blackburn NinjaTrader Programming 2 May 27th, 2011 11:59 PM
Trailing stop loss kavin729 NinjaTrader Programming 1 August 20th, 2010 01:17 PM


All times are GMT -4. The time now is 02:34 PM.

Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
Copyright © 2014 by Big Mike Trading. All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
 
no new posts

Page generated 2014-04-17 in 0.25 seconds with 19 queries on phoenix via your IP 54.196.196.72