[size=18:ecadf6ea1d]Dear Members,[/size:ecadf6ea1d]
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:1:ecadf6ea1d]
==============
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<-----------------------------[/code:1:ecadf6ea1d]
Thanks for any help or suggestion
redrunner