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

Re: Stephane re: Trendline Break System Test



PureBytes Links

Trading Reference Links

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;