PureBytes Links
Trading Reference Links
|
Stephane,
I see what you mean about changing v to vv, that makes good sense. On
the w & y issue, I think the equation goes slope=(endval-startval)/
(time or bars) and the way you have it written would give me a
negative # of bars I think. Peak(c,p,3) should give me the largest
bar count "minus" Peak(c,p,2) which would be the smallest bar count,
leaving me with a positive #, yes? Or we could do it the other way
and make it an ABS()value I think. I probably should have noted my
code so it wasn't so confusing, Sorry.
Thanks for all your help
wdbaker
--- In amibroker@xxxx, "Stephane Carrasset" <nenapacwanfr@xxxx> wrote:
> I read two bad codes
>
> 1/ you use V=IIf(Trough(C,q,1)==C,Trough(Close,q,2),Trough(C,q,1));
>
> V is reserved to Volume, change it to vv
>
> 2/ tha code of a slope is
> x=cum(1);
> startbar = LastValue( x-start );
> endbar = LastValue(x- end );
> Slope = (endval-startval)/(endbar-startbar);
>
> in our case, end bar-startbar = X-end-(X-start)=start-end
> so you should write
> w=IIf(Peak(C,p,1)==C,(PeakBars(C,p,2)-PeakBars(C,p,3)),(PeakBars
> (C,p,1)-PeakBars(C,p,2))); and
> idem for y
>
> stephane
>
> > Stephane,
> > Here is my code for a Trendline Break System
> > I used this on MSFT 5min data
> > Let me know if this works OK. I tried to build it
> > so that it wouldn't look forward even though using
> > Peak() & Trough(), let me know if this is valid.
> >
> > //*Trendline Break System*//
> > Filter=TimeNum()>080000 AND TimeNum()<=150000;
> > //PositionSize=2500;
> > PositionSize=BuyPrice*1000;
> > q=Optimize("q",1.4,1,2,.1);//.4/.2
> > p=Optimize("p",.8,.5,1.5,.1);//.2/.2
> > //p=.2;
> > s=IIf(Peak(C,p,1)==C,Peak(Close,p,3),Peak(C,p,2));
> > t=IIf(Peak(C,p,1)==C,Peak(Close,p,2),Peak(C,p,1));
> > u=IIf(Trough(C,q,1)==C,Trough(Close,q,3),Trough(C,q,2));
> > V=IIf(Trough(C,q,1)==C,Trough(Close,q,2),Trough(C,q,1));
> > w=IIf(Peak(C,p,1)==C,(PeakBars(C,p,3)-PeakBars(C,p,2)),(PeakBars
> > (C,p,2)-PeakBars(C,p,1)));
> > x=IIf(Peak(C,p,1)==C,PeakBars(C,p,3),PeakBars(C,p,2));
> > y=IIf(Trough(C,q,1)==C,(TroughBars(C,q,3)-TroughBars(C,q,2)),
> > (TroughBars(C,q,2)-TroughBars(C,q,1)));
> > z=IIf(Trough(C,q,1)==C,TroughBars(C,q,3),TroughBars(C,q,2));
> >
> > slope=(t-s)/w;
> > slope2=(C-s)/x;
> > test1=Cross(slope2,slope)AND s>t AND C>t;//
> >
> >
> > slope3=(V-u)/y;
> > slope4=(C-u)/z;
> > test2=Cross(slope3,slope4) AND u<V AND C<V;//
> >
> >
> > Buy=Filter AND test1 ;
> > Sell=TimeNum()>150000;
> >
> >
> > Short=Filter AND test2 ;
> > Cover=TimeNum()>150000;
|