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

[EquisMetaStock Group] Re: Cup and Handle Exploration modification help



PureBytes Links

Trading Reference Links


Hi,

Here is an example.  Say you have a moving average crossover system
and want to know the maximum price since you went long.  The system is say

    C > Mov(C,50,S)

and

    BarsSince( C <= Mov(C,50,S) )

will be the number of bars since you went long, and if the HHV
function allowed a 'data array' in stead of periods, you could use

    HHV( C, BarsSince( C <= Mov(C,50,S) ) )

to get the highest since you went long.  Now, the latter part does not
gel with MSFL and you have to make a different plan.  One way is to do
something like

    ( C > Mov(C,50,S) ) * If( PREV > C, PREV, C )

which calculates a 'rolling' maximum as long as you are long.  It will
plot a zero if you are short or out and the value of the highest close
since you went long.

Regards
MG Ferreira
TsaTsa EOD Programmer and trading model builder
http://www.ferra4models.com
http://fun.ferra4models.com 




--- In equismetastock@xxxxxxxxxxxxxxx, dmyy2k <no_reply@xxxx> wrote:
> 
> 
> Could you post a simple example to how u overcome this type of 
> problem ?
> 
> Thank you and appreciate
> .dmyy2k
> 
> --- In equismetastock@xxxxxxxxxxxxxxx, "MG Ferreira" <quant@xxxx> 
> wrote:
> > 
> > This particular problem is a pain in the backside and I often run 
> into
> > it.  Whenever a function indicates that it takes 'Periods' as an
> > argument, then it can not take an array, only a constant.  Almost
> > anything in MS then can not be used here.  What I do is to rewrite 
> the
> > function - this is usually quite a struggle - to not use an array in
> > say the HHV function.  I have only looked very briefly at your code,
> > and have no solution but this suggestion.  Also, I think the error
> > actually starts earlier, at the following line:
> > 
> > > BH:=LLV(Close,BLH);
> > 
> > as this is the first time you use an 'array' BLH in the LLV 
> function.
> > 
> > Regards
> > MG Ferreira
> > TsaTsa EOD Programmer and trading model builder
> > http://www.ferra4models.com
> > http://fun.ferra4models.com 
> > 
> > 
> > 
> > --- In equismetastock@xxxxxxxxxxxxxxx, dmyy2k <no_reply@xxxx> wrote:
> > > 
> > > 
> > > Some very kind forumer has recommended ( in amibroker language)
> > > http://www.amibroker.com/library/detail.php?id=306
> > > 
> > > I tried to convert it to metastock language but hit some command 
> error
> > > 
> > > Problem:
> > > Hit syntax error:" LLV and LLVBars expecting constant instead of
> > > variable in metastock"
> > > anyone has workaround if we can't solve the problem with that
> > > MetaStock ommand ?
> > > 
> > > Thank you and appreciate very very much.
> > > best wishes
> > > //dmyy2k@xxxx
> > > ====
> > > MinPrice:=0.20; { 2}
> > > MinVolume:=200000; {100K}
> > > 
> > > LH:=HHV(Close,25);
> > > BLH:=HHVBars(Close,25);
> > > 
> > > 
> > > BH:=LLV(Close,BLH);
> > > BBH:=LLVBars(Close,BLH);
> > > 
> > > NBLH:=BLH-BBH;
> > > 
> > > BC:=LLV(Close,BLH+25); {e.g. !!!! hit error here }
> > > BBC:=LLVBars(Close,BLH+25);
> > > 
> > > 
> > > LC:=Ref(HHV(Close,120),BBC*-1);
> > > BLC:=Ref(HHVBars(Close,120),BBC*-1);
> > > 
> > > 
> > > KC:=Ref(HHV(Close,30),BLC*-1);
> > > BKC:=Ref(HHVBars(Close,120),BLC*-1);
> > > 
> > > Delta:= LC/KC;
> > > 
> > > URPV=DRPV=0;
> > > i=barssince(BLH);
> > > j=barssince(BBC);
> > > countback:=j-i
> > > UPRV:= sum(
> > > if(Ref(C,i*-1) >Ref(i+1)*-1),
> > > Ref(V,i*-1) * ( Ref(C,(i*-1)) - Ref(C,(i+1)*-1) ),
> > > UPRV) , countback) ;
> > > DRPV:= sum(
> > > if(Ref(C,i*-1) Ref(V,i*-1) * ( Ref(C,(i+1)*-1) - Ref(C,(i*-1)) ),
> > > DRPV) , countback);
> > > 
> > > 
> > > Alpha := URPV/DRPV; { // Should be>1}
> > > 
> > > 
> > > DRPV:=0;
> > > i:=barssince(BBH);
> > > j:=barssince(BLH);
> > > countback2=j-i
> > > DRPV:= sum(
> > > if(Ref(C,i*-1) Ref(V,i*-1) * ( Ref(C,(i+1)*-1) - Ref(C,(i*-1)) ),
> > > DRPV) , countback);
> > > 
> > > 
> > > Beta := URPV/DRPV;
> > > Gamma := log(Alpha) + log(Beta) + delta;
> > > 
> > > {NBHL ?}
> > > NBLH >2 AND C>BH AND BC (0.8*LH + 0.2*BC)) AND
> > > KC < LC AND C>MinPrice AND MOV(V,30)>MinVolume
> > > 
> > > {
> > > AddColumn(LH,"Left Handle");
> > > AddColumn(BH,"Bottom Handle");
> > > AddColumn(BC,"Bottom Cup");
> > > AddColumn(LC,"Left Cup");
> > > AddColumn(ALPHA,"Alpha");
> > > AddColumn(DELTA,"Delta");
> > > AddColumn(BETA,"BETA");
> > > AddColumn(GAMMA,"Gamma");
> > > 
> > > }
> > > { // Filter Criteria as follows: }
> > > { // 1. Right side of handle must be at least 2 bars. NBHL>2 }
> > > { // 2. Bottom of the cup must be lower than the left top of the
> > > cup. }
> > > { // 3. Left handle must be lower than or equal to the lect cup
> > > formation. }
> > > { // 4. Bottom of the cup must be less than the left handle. }
> > > { // 5. Bottom of the handle must be > 80% of the left handle + 
> 20%
> > > of the bottom cup. }
> > > { // 6. Start of cup/handle formation must be greater than 
> precedding
> > > chart value. LC>LC }
> > > { // 7. Minimum price and volume you can set any way you like. }
> > > {Filter= NBLH>2 AND Close>BH AND BC.8*LH+.2*BC
> > > AND KCMinPrice AND MA(Volume,30)>MinVolume;}





------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/BefplB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

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

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

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/