[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Re: I need some loop-... / KASE indicators



PureBytes Links

Trading Reference Links

Attached my version of KASE indicators

Ara

----- Original Message ----- 
From: "Ahmad" <alwalad2002@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Friday, July 20, 2007 8:27 AM
Subject: [amibroker] Re: I need some loop-... / KASE indicators


> Hello, 
> 
> The Kase indicators were discussed some time back within this group.
> Does anybody have the afl's for the Kase indicators?
> 
> Thanks and regards,
> 
> Ahmed
> --- In amibroker@xxxxxxxxxxxxxxx, "Byron Porter" <bporter@xxx> wrote:
>>
>> You are probably right. This code is some tinkering that I was doing.
>> When it had been checked out, I will clean it up and put it in the files
>> section.
>> Byron
>> 
>> -----Original Message-----
>> From: Arthur Sawilejskij [mailto:arthur@...] 
>> Sent: Wednesday, March 10, 2004 1:23 PM
>> To: amibroker@xxxxxxxxxxxxxxx
>> Subject: RE: [amibroker] Re: I need some loop-... / KASE indicators
>> 
>> 
>> At 01:13 PM 10/03/2004 -0600, you wrote:
>> :
>>  >Treliff and Owen - Thanks for the info on the Kase Book.  >Wayne -
>> Thanks for the Kase code.  I have some different interpretations  >but I
>> do not know if mine are correct.
>> 
>> The param line in the first code - KSDL.afl - doesn't seem to be
>> implemented.
>> 
>> 
>> 
>> 
>> --
>> Arthur
>> 
>> 
>> 
>> Send BUG REPORTS to bugs@xxx
>> Send SUGGESTIONS to suggest@xxx
>> -----------------------------------------
>> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
>> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
>> --------------------------------------------
>> Check group FAQ at:
>> http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
>> Yahoo! Groups Links
>>
> 
> 
> 
> 
> Please note that this group is for discussion between users only.
> 
> To get support from AmiBroker please send an e-mail directly to 
> SUPPORT {at} amibroker.com
> 
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> 
> Yahoo! Groups Links
> 
> 
> 


Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 
//File: DEV - Kase dynamic Stops
//Obtained from AB board
//March 28, 2006

/*As can be seen from the formula, Kase uses standard deviations for the user to decide at what point to exit a position. Stops are set where there is increasing statistical probability of reversal against the trend. This issupposedly based on the log normal shape of the curve of the range curve.The manual which describes how to operate the software is at http://www.fimi.com/Kase/k0.htm





Philosophy:

The DevStop is the closest we can come to an ideal stop level in the real world. The indicator mathematics accounts for volatility (which is directly proportional to risk), AND also for the variance of volatility (how much risk changes from bar to bar) AND volatility skew (the propensity for volatility to spike higher from time to time).

Specifically, the DevStop places exit points at 1, 2 AND 3 standard deviations over the mean two bar True Range, corrected for skew. So we can take profit OR cut losses at levels at which the probability of a trade remaining profitable is Low, without taking more of a loss OR cutting profits any sooner than necessary.

Interpretation:

The stop consists of four exit points, a Warning line AND Dev 1, 2 AND 3. Two closes against the warning count as Dev 1.*/


//Kase DevStop I

AVTR= MA(HHV(H,3) - LLV(L,2),21);
SD= StDev(HHV(H,3) - LLV(L,2),21);

Val4= HHV(H-AVTR-3.4*SD,21);
Val3= HHV(H-AVTR-2.1*SD,10);
Val2= HHV(H-AVTR-SD,34);
Val1= HHV(H-AVTR,21);


/* Kase DevStop II

Pd= Param("Max Length",13,100,30,2);

RWH= (H-Ref(L,-Pd))/(ATR(Pd)*sqrt(Pd));
RWL= (Ref(H,-Pd)- L)/(ATR(Pd)*sqrt(Pd));

Pk= WMA((RWH-RWL),3);
AVTR= MA(HHV(H,2) - LLV(L,2),20);
SD= StDev(HHV(H,2) - LLV(L,2),20);

Val4= IIf(Pk>0,HHV(H - AVTR-3.6*SD,21),LLV(L + AVTR+3*SD,21));
Val3= IIf(Pk>0,HHV(H - AVTR-2.2*SD,10),LLV(L + AVTR+2*SD,10));
Val2= IIf(Pk>0,HHV(H - AVTR-1.0*SD,30),LLV(L + AVTR+SD,30));
Val1= IIf(Pk>0,HHV(H - AVTR,21),LLV(L + AVTR,21));*/

Plot(Val4,"3SDev",IIf(Val4 > C OR Val4 < Ref(Val4,-1),colorLime,colorYellow),styleDots|styleNoLine);
Plot(Val3,"2SDev",IIf(Val3 > C OR Val3 < Ref(Val3,-1),colorBlack,colorLime),styleDots|styleNoLine);
Plot(Val2,"1SDev",colorBlue,styleDots|styleNoLine);
Plot(Val1,"Warning",colorRed,styleLine);
Plot(C,"close",colorBlack,styleCandle);


Title = Name() + " Kase Stops " + EncodeColor(colorYellow) + " 3SDev " + WriteVal(Val4,1.2) + EncodeColor(colorLime) + " 2SDev " + WriteVal(Val3,1.2) + EncodeColor(colorBlue) + " 1SDev " + WriteVal(Val2,1.2) + EncodeColor(colorRed) + " Warning " + WriteVal(Val1,1.2);
//FIle: DEV - Kase Peak Oscillator
//March 28, 2006
//Obtained from AB Board

RWLoop = Param("RWLoop",1,0,1,1); KCD_Plot = Param("KCD_Plot",0,0,1,1);

GraphXSpace= 5;
GraphZOrder= 1;

truHi= IIf(H > Ref(C,-1),H,Ref(C,-1));
truLo= IIf(L < Ref(C,-1),L,Ref(C,-1));

truRange= truHi - truLo;
AvgTR = //Pd= Param("max length",13,5,100,1); // Needs to be adaptive - Use loop to fid max / min values, 8 to 64 . Done in loop below




//Find Highest / Lowest value over range of bars
RWH_Max = -999999;
RWL_Max = -999999;

if (RWLoop == 1)
{
for (pd=8; pd<65; pd++)       //  <<< ================================ Problem Area ???
{
//AvgTR   = MA(truRange,pd);
//RWH= (truHi-Ref(truLo,-Pd))/AvgTR*sqrt(Pd));
//RWL= (Ref(truHi,-Pd)-truLo)/AvgTR*sqrt(Pd));

RWH= (truHi-Ref(truLo,-Pd))/(ATR(Pd)*sqrt(Pd));
RWL= (Ref(truHi,-Pd)-truLo)/(ATR(Pd)*sqrt(Pd));
//Pk= WMA((RWH-RWL),3);  // Weighted MA


RWH_Max = IIf(RWH > RWH_Max,RWH,RWH_Max);
RWL_Max = IIf(RWL > RWL_Max,RWL,RWL_Max);
Pk      = WMA((RWH_Max - RWL_Max),3);
}
}
else
{
pd = 13;
RWH= (truHi-Ref(truLo,-Pd))/(ATR(Pd)*sqrt(Pd));
RWL= (Ref(truHi,-Pd)-truLo)/(ATR(Pd)*sqrt(Pd));
Pk= WMA((RWH-RWL),3);  // Weighted MA
}


MN= MA(Pk,Pd);
SD= StDev(Pk,Pd);

Val1= IIf(MN+(1.33*SD) > 2.08, MN+(1.33*SD), 2.08);
Val2= IIf(MN-(1.33*SD) < -1.92, MN-(1.33*SD), -1.92);

Line= IIf(Ref(Pk,-1) >= 0 AND Pk > 0,Val1, IIf(Ref(Pk,-1) <= 0 AND Pk < 0, Val2, 0));

Red= IIf(Ref(Pk,-1) > Pk, Pk, 0);
Yellow= IIf(Pk > Ref(Pk,-1), Pk, 0);
OscEnv  = EMA(PK,1);

Plot(Red,"Red",colorRed,styleHistogram|styleThick);
Plot(Yellow,"Yellow",colorYellow,styleHistogram|styleThick);
Plot(OscEnv,"",colorBlack,styleLine);
Plot(Line,"Line",colorGreen,styleLine);
PlotGrid(0,55);

// ====================================================================================
//Compute KCD
if (KCD_Plot==1)
{
Pk2 = RWH-RWL;

KCD = EMA((Pk2 - EMA(Pk2,Pd)),3);
KCD_Env = EMA(KCD,1);
Plot(KCD,"KCD",IIf(KCD>0,colorGreen,colorOrange),styleHistogram|styleThick);
Plot(KCD_Env,"",colorBlue,styleLine);
}

Title= "Kase Peak Oscillator   " + Name() + "  Pd " + WriteVal(Pd,1.0) +
"\n   Peak Osc Red="+WriteVal(Red,1.2)+
"\n     Peak Osc Yellow="+WriteVal(Yellow,1.2);