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

Re: [amibroker] Color code



PureBytes Links

Trading Reference Links

Anthony:
 
Thanks very much.  A fine effort that I suspect pushes AFL as far as possible.  I will study the code and see if I can figure out how to use it with my charting studies (e.g., Fibonacci patterns) that I draw with charting tools (e.g., trendline, zig-zag, etc.), as opposed to your approach of using AFL functions to establish coordinates.  This might not be possible because I don't see in the Users Manual how to get the coordinates used by the charting tools (but I've overlooked lots of good stuff in the manual before), although they are available in the Property dialog box.  Maybe SelectedValue() can be made to make this information available to the program.  Obviously AB knows all and the "mission impossible" task is to get it to get it to give up the information. 
 
I also wish (after using your code for a short time) that we had more control over the transparency of the color field, as is available with other "color filling" programs so that underlying features (i.e., trendlines, text, grid lines, etc.) are always visible without being sure to choose a color for them that will "shine" through.  Along these lines, as your screen shot shows, setting the area under the colored area to the background color erases the grid lines.  Do you know how this might be avoided without a built-in "fill area with color" option?
 
Bill
 
----- Original Message -----
Sent: Saturday, April 09, 2005 5:53 AM
Subject: Re: [amibroker] Color code

here is the formula.
 

//Pattern Recognition graph

//with shading

/*TRENDLINES BREAKOUT*/

 

 

x = Cum(1);

per = Param("Percent",3,1,5,1);

s1=L;

s11=H;

pS = TroughBars( s1, per, 1 ) == 0;

endt= LastValue(ValueWhen( pS, x, 1 ));

startt=LastValue(ValueWhen( pS, x, 2 ));

endS = LastValue(ValueWhen( pS, s1, 1 ) );

startS = LastValue( ValueWhen( pS, s1, 2 ));

dtS =endt-startt;

aS = (endS-startS)/dtS;

bS = endS;

trendlineS = aS * ( x -endt ) + bS;

 

pR = PeakBars( s11, per, 1 ) == 0;

endt1= LastValue(ValueWhen( pR, x, 1 ));

startt1=LastValue(ValueWhen( pR, x, 2 ));

endR = LastValue(ValueWhen( pR, s11, 1 ) );

startR = LastValue( ValueWhen( pR, s11, 2 ));

DTR=ENDT1-STARTT1;

aR = (endR-startR)/dtR;

bR = endR;

trendlineR = aR * ( x -endt1 ) + bR;

BEGIN=Min(STARTT,STARTT1);

TRS = IIf(x>BEGIN-10,trendlineS,-1e10);

TRR = IIf(x>BEGIN-10,trendlineR,-1e10);

 

Condcolor=(Cross(C,trendlineR) AND X>ENDT1) OR (Cross(trendlineS,C) AND

X>ENDT);

BarColor=IIf(Condcolor,7,1);

Plot(C,"Close",BarColor,styleCandle);

Plot(TRS,"Support",colorYellow,styleLine);

Plot(TRR,"Resist",colorYellow,styleLine);

/////////////////////////////////////

// Shading //

////////////////////////////////////

fill=Param("style",2,1,2,1);

>IIf(fill==1,styleHistogram,IIf(fill==2,styleArea,Null));

x=IIf(trs > trr,trr,trs);

Plot(x,"",colorLightGrey,style);

Plot(trr,"",colorPink,style);

////////////////////////////////////////////

// Pattern Recognition in title bar //

///////////////////////////////////////////

Lowline=Ends-starts;

Highline=endr-startr;

Wedge=IIf(Highline <0 AND Lowline > 0,1,0);

DecendingTriangle=IIf(Highline < 0 AND Lowline==0,1,0);

AscendingTriangle=IIf(Highline==0 AND Lowline > 0,1,0);

DownChannel=IIf(Highline<0 AND Lowline<0,1,0);

UpChannel=IIf(Highline>0 AND Lowline>0,1,0);

BroadeningWedge=IIf(Highline > 0 AND Lowline < 0,1,0);

///////////////////////////////////

// Bullish or Bearish breakout //

//////////////////////////////////

BullishBreakout=Cross(C,trendlineR);

BearishBreakout=Cross(trendlineS,C);

 

Title=Name()+ WriteIf(wedge==1," Wedge","")+WriteIf(DecendingTriangle==1," Decending Triangle","")+WriteIf(AscendingTriangle==1,"Ascending Triangle","")/*+WriteVal(Lowline)*/+WriteIf(DownChannel==1," Downward Sloping Channel","")+WriteIf(UpChannel==1," Upward Sloping Channel","")+WriteIf(broadeningWedge==1," Broadening Wedge","")+"\n"+EncodeColor(colorGreen)+WriteIf(bullishbreakout,"Bullish Breakout",EncodeColor(colorRed)+WriteIf(bearishbreakout,"Bearish Breakout",""))/*+WriteVal(highline)*/;

/////////////////////////////////////

// Automatic Analysis //

////////////////////////////////////

Filter=AscendingTriangle OR DecendingTriangle OR Wedge OR DownChannel OR UpChannel OR BroadeningWedge OR Bullishbreakout OR bearishbreakout;

AddTextColumn(WriteIf(bullishbreakout,"bullish Breakout",""),"BullBreak");

AddTextColumn(WriteIf(bearishBreakout,"Bearish Breakout",""),"BearBreak");

AddTextColumn(WriteIf(ascendingtriangle,"Ascending Triangle",WriteIf(decendingtriangle,"Decending Triangle",WriteIf(Wedge,"Wedge",WriteIf(DownChannel,"Down Channel",WriteIf(UpChannel,"Up Channel",WriteIf(BroadeningWedge,"Broadening Wedge","")))))),"Pattern");

----- Original Message -----
Sent: Friday, April 08, 2005 11:20 PM
Subject: Re: [amibroker] Color code

Yes, how did you do that?
----- Original Message -----
Sent: Friday, April 08, 2005 10:30 PM
Subject: Re: [amibroker] Color code

Bill,
 
Do you mean something like the attached image ?
 
Anthony
----- Original Message -----
Sent: Friday, April 08, 2005 8:06 PM
Subject: [amibroker] Color code

Has anyone successfully developed (or tried to develop) a generalized code for coloring an area defined by 3 or more lines?  For example, a triangle created with the zig-zag charting tool and a baseline.  Or a rectangle defined by two dates and two price levels.  Not unlike the "fill with color" option in Microsoft's Paint.  And along the same lines, is it possible to change the transparency of such coloring so that the underlying price bars, etc. are still visible?
 
Sounds like "mission impossible" with the AFL tools at our disposal but thought I would ask and maybe get "lucky."
 
Bill


Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.5 - Release Date: 4/7/2005


Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





Yahoo! Groups Links