martes, 18 de febrero de 2020

Los colores en Amibroker

Hoy vamos a ver un código que nos ahorrará mucho tiempo cuando estamos programando y no sabemos cómo se llama cada color. Podemos tenerlo cargado en una pestaña y probar cómo se ven los precios (botón derecho "parameters...") y cuál es el nombre que tiene cada color. El aspecto es el siguiente:





Y el código que lo pinta es (he mantenido la referencia del autor):

CÓDIGO AMIBROKER (TABLA DE COLORES)

// Downloaded From https://www.WiseStockTrader.com

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

xCoorX0 = 100;
xCoorY0 = 50;
xSpaceV = 250;
xSpaceH = 200;
xBoxH = 40;
xBoxW = 100;
Title="";

function fnDrawColorChart(i,j,Color,text) {
GfxSelectPen( colorBlack, 1, 0);
GfxSelectSolidBrush(Color);

X0 = xCoorX0+(xBoxW+xSpaceH)*j;
Y0 = xCoorY0+(xBoxH+xSpaceV)*i;
GfxRectangle( x0+1, y0+1, x0+xBoxW-1, y0+xBoxH-1);

GfxSelectFont("Tahoma", 10, 700 );
GfxSetBkMode(1);
GfxSetTextAlign(6|0);
GfxSetTextColor(colorBlack);
GfxTextOut(text+" ("+NumToStr(color,1.0)+")", X0+xBoxW/2, Y0+xBoxH+1);
}

i=0; j=0; fnDrawColorChart(i,j, colorBlack, "Black");
i=0; j=1; fnDrawColorChart(i,j, colorBrown, "Brown");
i=0; j=2; fnDrawColorChart(i,j, colorDarkOliveGreen,"DarkOliveGreen");
i=0; j=3; fnDrawColorChart(i,j, colorDarkGreen, "DarkGreen");
i=0; j=4; fnDrawColorChart(i,j, colorDarkTeal, "DarkTeal");
i=0; j=5; fnDrawColorChart(i,j, colorDarkBlue, "DarkBlue");
i=0; j=6; fnDrawColorChart(i,j, colorIndigo, "Indigo");
i=0; j=7; fnDrawColorChart(i,j, colorDarkGrey, "DarkGrey");

i=1; j=0; fnDrawColorChart(i,j, colorDarkRed, "DarkRed");
i=1; j=1; fnDrawColorChart(i,j, colorOrange, "Orange");
i=1; j=2; fnDrawColorChart(i,j, colorDarkYellow, "DarkYellow");
i=1; j=3; fnDrawColorChart(i,j, colorGreen, "Green");
i=1; j=4; fnDrawColorChart(i,j, colorTeal, "Teal");
i=1; j=5; fnDrawColorChart(i,j, colorBlue, "Blue");
i=1; j=6; fnDrawColorChart(i,j, colorBlueGrey, "BlueGrey");
i=1; j=7; fnDrawColorChart(i,j, colorGrey40, "Grey40");

i=2; j=0; fnDrawColorChart(i,j, colorRed, "Red");
i=2; j=1; fnDrawColorChart(i,j, colorLightOrange, "LightOrange");
i=2; j=2; fnDrawColorChart(i,j, colorLime, "Lime");
i=2; j=3; fnDrawColorChart(i,j, colorSeaGreen, "SeaGreen");
i=2; j=4; fnDrawColorChart(i,j, colorAqua, "Aqua");
i=2; j=5; fnDrawColorChart(i,j, colorLightBlue, "LightBlue");
i=2; j=6; fnDrawColorChart(i,j, colorViolet, "Violet");
i=2; j=7; fnDrawColorChart(i,j, colorGrey50, "Grey50");

i=3; j=0; fnDrawColorChart(i,j, colorPink, "Pink");
i=3; j=1; fnDrawColorChart(i,j, colorGold, "Gold");
i=3; j=2; fnDrawColorChart(i,j, colorYellow, "Yellow");
i=3; j=3; fnDrawColorChart(i,j, colorBrightGreen, "BrightGreen");
i=3; j=4; fnDrawColorChart(i,j, colorTurquoise, "Turquoise");
i=3; j=5; fnDrawColorChart(i,j, colorSkyblue, "Skyblue");
i=3; j=6; fnDrawColorChart(i,j, colorPlum, "Plum");
i=3; j=7; fnDrawColorChart(i,j, colorLightGrey, "LightGrey");

i=4; j=0; fnDrawColorChart(i,j, colorRose, "Rose");
i=4; j=1; fnDrawColorChart(i,j, colorTan, "Tan");
i=4; j=2; fnDrawColorChart(i,j, colorLightYellow, "LightYellow");
i=4; j=3; fnDrawColorChart(i,j, colorPaleGreen, "PaleGreen");
i=4; j=4; fnDrawColorChart(i,j, colorPaleTurquoise, "PaleTurquoise");
i=4; j=5; fnDrawColorChart(i,j, colorPaleBlue, "PaleBlue");
i=4; j=6; fnDrawColorChart(i,j, colorLavender, "Lavender");
i=4; j=7; fnDrawColorChart(i,j, colorWhite, "White");


//Visit Mar ketlogy.com for strategy and unique AFL codes



1 comentario:

ENTRADAS POPULARES