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

[amibroker] Help needed for Precentage change over time in lowlevel gfx



PureBytes Links

Trading Reference Links

I am trying to use the following exploration (posted earlier by
another person) to draw the results in a table using the lowlevel gfx
functions.

Can anyone suggest how the table can be colored as in the exploration ?

Also, can you suggest how I can get the previous trading day's date in
row 2 column 1 ? 

Also, does anyone know how to draw a matrix for a watch list with the
same results as using an exploration on a watch list, in low level gfx
functions ?

//Use to see percentage change over time

Dy1     = C / Ref(C, -1) * 100 - 100;
Dy2     = C / Ref(C, -2) * 100 - 100;
Dy3     = C / Ref(C, -3) * 100 - 100;
Dy4     = C / Ref(C, -4) * 100 - 100;
Dy5     = C / Ref(C, -5) * 100 - 100;
Dy6     = C / Ref(C, -10) * 100 - 100;
Dy7     = C / Ref(C, -20) * 100 - 100;
Dy8     = C / Ref(C, -30) * 100 - 100;
Qtr       = C / Ref(C, -90) * 100 - 100;
Qtr2     = C / Ref(C, -180) * 100 - 100;
Year1   = C / Ref(C, -252) * 100 - 100;

UpDy1    =IIf(Dy1>0,colorBlack,colorWhite);
DnDy1    =IIf(Dy1<0,colorRed,colorLime);
UpDy2    =IIf(Dy2>0,colorBlack,colorWhite);
DnDy2    =IIf(Dy2<0,colorRed,colorLime);
UpDy3    =IIf(Dy3>0,colorBlack,colorWhite);
DnDy3    =IIf(Dy3<0,colorRed,colorLime);
UpDy4    =IIf(Dy4>0,colorBlack,colorWhite);
DnDy4    =IIf(Dy4<0,colorRed,colorLime);
UpDy5    =IIf(Dy5>0,colorBlack,colorWhite);
DnDy5    =IIf(Dy5<0,colorRed,colorLime);
UpDy6    =IIf(Dy6>0,colorBlack,colorWhite);
DnDy6    =IIf(Dy6<0,colorRed,colorLime);
UpDy7    =IIf(Dy7>0,colorBlack,colorWhite);
DnDy7    =IIf(Dy7<0,colorRed,colorLime);
UpDy8    =IIf(Dy8>0,colorBlack,colorWhite);
DnDy8    =IIf(Dy8<0,colorRed,colorLime);
UpQtr      =IIf(Qtr>0,colorBlack,colorWhite);
DnQtr      =IIf(Qtr<0,colorRed,colorLime);
UpQtr2    =IIf(Qtr2>0,colorBlack,colorWhite);
DnQtr2    =IIf(Qtr2<0,colorRed,colorLime);
UpYear1  =IIf(Year1>0,colorBlack,colorWhite);
DnYear1  =IIf(Year1<0,colorRed,colorLime);



AddTextColumn( FullName(), "FullName" );
AddTextColumn(IndustryID(1) ," Industry Sector ", 25.0, colorWhite,
colorBlue);
AddColumn(Dy1,    "1Dy%",  1.2, UpDy1, DnDy1);
AddColumn(Dy2,    "2Dy%",  1.2, UpDy2, DnDy2);
AddColumn(Dy3,    "3Dy%",  1.2, UpDy3, DnDy3);
AddColumn(Dy4,    "4Dy%",  1.2, UpDy4, DnDy4);
AddColumn(Dy5,    "5Dy%",  1.2, UpDy5, DnDy5);
AddColumn(Dy6,    "10Dy%",  1.2, UpDy6, DnDy6);
AddColumn(Dy7,    "20Dy%",  1.2, UpDy7, DnDy7);
AddColumn(Dy8,    "30Dy%",  1.2, UpDy8, DnDy8);
AddColumn(Qtr,      "1 Qtr%",   1.2,  UpQtr, DnQtr);
AddColumn(Qtr2,    "2 Qtr%",   1.2,  UpQtr2,DnQtr2 );
AddColumn(Year1,  "1 Year%", 1.2,  UpYear1,DnYear1);

Filter=1;

SetSortColumns(-21,-20,-19,-18,-17,-16,-15,-14,-13,-12);


GfxSetOverlayMode(2);
// formatted text output sample via low-level gfx functions 


CellHeight = 20; 
CellWidth = 100; 
GfxSelectFont( "Tahoma",CellHeight/2);


function PrintInCell( string, row, Col ) 
{ 
GfxDrawText( string, Col * CellWidth, row * CellHeight, (Col + 1 ) *
CellWidth, (row + 1 ) * CellHeight, 0 );
 
} 

PrintInCell( " Date", 0, 0 );
PrintInCell( " 1Dy%", 0, 1 ); 
PrintInCell( " 2Dy%", 0, 2 ); 
PrintInCell( " 3Dy%", 0, 3 ); 
PrintInCell( " 4Dy%", 0, 4 ); 
PrintInCell( " 5Dy%", 0, 5 );
PrintInCell( " 10Dy%", 0, 6 );
PrintInCell( " 20Dy%", 0, 7 );
PrintInCell( " 30Dy%", 0, 8 );
PrintInCell( " Qtr%", 0, 9 );
PrintInCell( " Qtr2%", 0, 10 );
PrintInCell( " Year%", 0, 11 );
PrintInCell( Date(), 1, 0 );
PrintInCell( WriteVal(Dy1), 1, 1 );
PrintInCell( WriteVal(Dy2), 1, 2 );
PrintInCell( WriteVal(Dy3), 1, 3 );
PrintInCell( WriteVal(Dy4), 1, 4 );
PrintInCell( WriteVal(Dy5), 1, 5 );
PrintInCell( WriteVal(Dy6), 1, 6 );
PrintInCell( WriteVal(Dy7), 1, 7 );
PrintInCell( WriteVal(Dy8), 1, 8 );
PrintInCell( WriteVal(Qtr), 1, 9 );
PrintInCell( WriteVal(Qtr2), 1, 10 );
PrintInCell( WriteVal(Year1), 1, 11 );

PrintInCell( Date(), 2, 0 );
PrintInCell( WriteVal(Ref(Dy1,-1)), 2, 1 );
PrintInCell( WriteVal(Ref(Dy2,-1)), 2, 2 );
PrintInCell( WriteVal(Ref(Dy3,-1)), 2, 3 );
PrintInCell( WriteVal(Ref(Dy4,-1)), 2, 4 );
PrintInCell( WriteVal(Ref(Dy5,-1)), 2, 5 );
PrintInCell( WriteVal(Ref(Dy6,-1)), 2, 6 );
PrintInCell( WriteVal(Ref(Dy7,-1)), 2, 7 );
PrintInCell( WriteVal(Ref(Dy8,-1)), 2, 8 );
PrintInCell( WriteVal(Ref(Qtr,-1)), 2, 9 );
PrintInCell( WriteVal(Ref(Qtr2,-1)), 2, 10 );
PrintInCell( WriteVal(Ref(Year1,-1)), 2, 11 );
 

GfxSelectPen( colorLightGrey ); 
for( i = 1; i < 3 && i < BarCount; i++ ) 
{ 
//PrintInCell( StrFormat("%g", Dy1[ i ] ), 1, i ); 
//PrintInCell( StrFormat("%g", Dy2[ i ] ), i, i ); 
//PrintInCell( StrFormat("%g", Dy3[ i ] ), 3, i ); 
//PrintInCell( StrFormat("%g", Dy4[ i ] ), 4, i ); 
//PrintInCell( StrFormat("%g", Dy5[ i ] ), 5, i ); 
GfxMoveTo( 0, i * CellHeight ); 
GfxLineTo( 12 * CellWidth, i * CellHeight );
} 
GfxMoveTo( 0, i * CellHeight ); 
GfxLineTo( 12 * CellWidth, i * CellHeight ); 
for( Col = 1; Col < 13; Col++ ) 
{ 
GfxMoveTo( Col * CellWidth, 0); 
GfxLineTo( Col * CellWidth, 3 * CellHeight ); 
} 

Title=""; 



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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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