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

[amibroker] Re: SignalZig



PureBytes Links

Trading Reference Links

Herman,
In http://www.amibroker.com/library/detail.php?id=105 there was an 
effort to plot historical trendlines. It was posted on March 2002. As 
you remember, this period we did not have AFL loops.
Now, it is much easier to link Buy/Sell points.
In the following example, the zig line will link the H of the 
Buy/Sell bars.

 x = Cum(1);Plot(C,"",1,64);
Buy=Cross(StochD(),30);Sell=Cross(StochD(),70);
Buy=ExRem(Buy,Sell);Sell=ExRem(Sell,Buy);
PlotShapes(shapeUpArrow*Buy,colorGreen);
PlotShapes(shapeDownArrow*Sell,colorRed);
tot=LastValue(2*Cum(Sell));
for(rank=1;rank<tot;rank++)
{
s1=H;
pS = Buy OR Sell;
endt= LastValue(ValueWhen( pS, x, RANK ));
startt=LastValue(ValueWhen( pS, x, RANK+1 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, RANK) );
startS = LastValue( ValueWhen( pS, s1, RANK+1 ));
aS = (endS-startS)/dtS;bS = endS;
line = aS * ( x -endt ) + bS;
Plot(IIf(x>=startt AND x<=endt,line,-1e10),"",colorBlue,1);
}
Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, "Herman van den Bergen" 
<psytek@xxxx> wrote:
> Below is the code to plot a straight line from Bar1 to Bar2. I 
want  to
> adapt this code to plot straight lines between my trade entry 
(BuyPrice or
> ShortPrice) and exit (SellPrice and CoverPrice) points but somehow 
I can't
> solve this programming problem. The final plot would appear like a 
ZigZag
> line from trade to trade.
> 
> If anybody has done this or can help me on my way it would be much
> appreciated,
> 
> happy trading,
> Herman.
> 
>  // Straight line from Bar1 to Bar2
> LB     = 10;  //Number of bars ago to start
> Length = 5;  //Length of line in bars
> X      = C;    //Variable to be sampled
> Bar1   = LastValue(Cum(1)) - LB;  //Start of line
> Bar2   =  Bar1 + Length;          //End of line
> InLine = Cum(1) >= bar1 AND Cum(1) <= bar2;
> Bar    = IIf(InLine,(Cum(1) - Bar1),0);
> StartX = ValueWhen(Cum(1) == Bar1, X); //Startvalue for line
> LastX  = LastValue(ValueWhen(Cum(1) == Bar2, X)); //End value of 
line
> Incr   = (LastX - StartX)/Length;          //Line increment/bar
> Line   = IIf(InLine, StartX + bar * Incr,-1e10);
> Plot(Line,"",4,1);
> Plot(C,"C",1,1);


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
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 

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