in Search

Chandelier Exit problem

Last post 08-02-2006, 1:03 by Jose. 5 replies.
Sort Posts: Previous Next
  •  07-31-2006, 7:57 19471

    Chandelier Exit problem

    Dear Members,


    I am a new newbee here.

    I am trying to code Chandelier Exit with reducing ATR stop in function of reached profit.
    I know that Richard Dale has an excellent one but I want to code my own.

    It seems to be working but there are 2 problems:



    1, Code is quite slow...

    CAN ANYONE FIX IT?



    2, After droping this indicator to a chart (with merging, of course), its values are correct but not scaling.
    Stop loss indicator "finds" the right place only after a big zoom in or rescaling (stop loss is above and not below the chart before hitting that). Sometimes the same situation occured with Richard Dale's code as well...

    IS IT A MS SCALING BUG?



    Code:

    ==============
    Chandelier Exit
    ==============

    {----8<-----------------------------

    EntYR:=Input("Year",1980,2006,2006);
    EntMTH:=Input("Month",1,12,3);
    EntDY:=Input("Day",1,31,5);


    AvgTR:= Mov( ATR(1),20,S );
    EntLong:= Year()=EntYR AND Month()=EntMTH AND DayOfMonth()=EntDY;

    PeriodFrom:=Year()>EntYR
    OR (Year()=EntYR AND (Month()>EntMTH
    OR Month()=EntMTH AND DayOfMonth()>=EntDY));


    EntryPrice:= ValueWhen(1, EntLong, C);

    Mplier:= If( C=EntryPrice, 2,
    If( C < EntryPrice + 4*AvgTR, 3.5,
    If( C < EntryPrice + 6*AvgTR, 3,
    If( C >= EntryPrice + 6*AvgTR, 2.5,
    0))));

    HV:=Highest(ValueWhen(1, PeriodFrom, H));
    StopLoss:=Ref(HV - Mplier*AvgTR, 0);


    StopActivated:= (C < StopLoss);
    State:= If( StopActivated, 1, PREV);

    If(Cum(1)=1,
    StopLoss,
    If(StopLoss >= PREV AND State=0,
    Stoploss,
    PREV));

    {----8<-----------------------------




    Thanks for any help or suggestion

    redrunner
  •  07-31-2006, 8:30 19472 in reply to 19471

    PREV = sloooow processing

    RedRunner, there is a bug there, but it has nothing to do with MetaStock of its formula language. ;)

    Try the ATR trailing stop from MetaStockTools.com.


    jose '-)
    MetaStockTools.com
  •  07-31-2006, 12:43 19474 in reply to 19471

    Re: Sloooow PRE

    Dear Jose,

    Thanks for your quick reply.


    I am sad a little bit because your code is too complex for me to understand and has no stop loss reduction function.
    If you have some free time, will you be so kind and post core part of your very well written parameterised code?

    Is TradeSim.dll available for free of charge?


    Thanks again.
    RedRunner
  •  07-31-2006, 13:31 19475 in reply to 19471

    Re: Re: Sloooow PRE

    redrunner:
    ...and has no stop loss reduction function.

    Not so - all trailing stop parameters are available from the indicator's user inputs.

    I also offer more advanced trailing stop functions, but these are part of commercial packages.

    TradeSim.dll is only available with the purchase of TradeSim, but Richard Dale's
    Advanced Trailing Stop dll is free - you'll find basic trailing stop code examples there.


    jose '-)
    MetaStockTools.com
  •  08-01-2006, 16:03 19720 in reply to 19475

    Re: Re: Sloooow PRE

    Dear Jose,

    Thank you for help. I will start to study your code (and try to understand that...)

     

    RedRunner

  •  08-02-2006, 1:03 19741 in reply to 19720

    understanding code construction

    redrunner:
    I will start to study your code (and try to understand that...)

    The best way to understand any code, is to pull it apart and plot it line by line.


    jose '-)
    MetaStockTools.com
View as RSS news feed in XML