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

[amibroker] Plotting Line Segments and Rays



PureBytes Links

Trading Reference Links




I gutted one of my do-hickeys for the 
plotting core to help 'youse guys in drawing particular segments.
 
This is set up for a black background and EOD 
data.
Change 'BC' to your screen background 
color.
 
Use Parameters to adjust the Span and Offset of 
the lines.
Change 'Y' to whatever you want to 
track.
 
I included examples of lines above and below, 
dashed lines, finding line spacing, and etc. (ad nauseum).
 
Obviously, if you extend the lines off the edge of 
the screen, things get screwy. So don't. You were warned. It will cost $1500 to 
explain why.
 
-CS
 
 /*Plot Line Segments 
(extract)by Corey Saxe ver. 030716*/GraphXSpace=2;Span=Param( 
"Span", 25, 2, 200, 1 ); //Span of lineOffset=Param( "Offset", 45, 2, 250, 1 
); //Periods offset from the end of dataRE=ParamStr("Ray or Segment 
r/s","r");//Duh!?BC=colorBlack; //Screen background color
 
Y=C;  //Data Array, change to 
whatever you want to trackBI=BarIndex();LC=LastValue(BI);
 
L2=LC-Offset+1;//Left end of line 
segmentL1=Min( (LC-(Offset-Span)) , LC );// The dreaded Right end of line 
segment
 
LR=ValueWhen(BI==L2,Y);//value of Y 
at left endLRS=(ValueWhen(BI==L1,Y)-LR)/(Span-1);// Slope
 
Z=-(L2-BI);//Slope multiplication 
counterIVL=BI>L1 OR BI<L2;//Finds the valid interval of the 
line
 
<FONT face=Tahoma color=#0000ff 
size=2>Line=LastValue(LR)+(LastValue(LRS)*Z);Diff=LastValue(ValueWhen(BI==L1, 
Max(HHV(abs(Line-H),Span),HHV(abs(Line-L),Span))));
 
//Line below calculates ATR at L1. 
ATR periods=Span.ATZ=LastValue(ValueWhen(L1==BI,ATR(Span),1));
 
//Graph'em if you 
got'emPlot(IIf(BI!=L2,Null,Line),"",BC,1);//Use background color to block 
line artifact.Plot(IIf(BI!=L2,Null,Line+Diff),"",BC,1);//Use background 
color to block line artifact.Plot(IIf(BI!=L2,Null,Line-Diff),"",BC,1);//Use 
background color to block line artifact.
 
Plot(IIf(IVL,Null,Line+Diff),"Top 
Line",colorYellow,1);// Top linePlot(IIf(IVL,Null,Line),"LinReg 
Line",colorRed,1);// Center linePlot(IIf(IVL,Null,Line-Diff),"Bottom 
Line",colorYellow,1); //Bottom line
 
Plot(C,"Price 
Array",colorBlue,1);Plot(IIf(BI>L1 AND RE=="r" AND BI % 2 
,Line+Diff,Null),"Top RE Line",colorDarkYellow,1); //R extended 
linesPlot(IIf(BI>L1 AND RE=="r" AND BI % 2 ,Line,Null) , "RE Center Line" 
, colorDarkRed, 1);//R extended linesPlot(IIf(BI>L1 AND RE=="r" AND BI % 
2 ,Line-Diff,Null),"Bottom RE Line",colorDarkYellow,1);//R extended 
lines
 
Title="Line Segment 
Test     Start Date "+WriteVal(LastValue(ValueWhen(BI==L2, 
DateTime())), formatDateTime)+"     End Date 
"+WriteVal(LastValue(ValueWhen(BI==L1, DateTime())), 
formatDateTime)+"     Periods 
"+WriteVal(Span,1.0)+"     Offset 
"+WriteVal(Offset,1.0)+//Futures Dudes...Line below requires PointValue (in 
dollars)."     Spacing (top to bottom) 
"+WriteVal((2*Diff)/ATZ,1.2)+" ATRs and 
$"+WriteVal(PointValue*2*Diff,1.2);






Yahoo! Groups Sponsor


  ADVERTISEMENT 









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 the Yahoo! Terms of Service.



Attachment:
Test, Plot Segments.afl

Attachment: Description: "Description: Binary data"