due to Body is limited to 50000 characters so The code has been shortened .
the code is working ok but the performance is very slow .
the idea is multi indicators with multiple time frames in one screen.
references of the code
the code below for one indicator and one time frame .
i know the reason not AB . it is the way the code is written .
GFX_ALLX = Param("x_origin", 20, 0, 1000, 20);
GFX_ALLY = Param("y_origin", 20, 0, 1024, 20);
GFX_ALL = ParamToggle("Show CLC", "No|Yes", 1);
// Origin
_GFX_ALLx0 = _GFX_ALLy0 = 0;
TA_CENTER = 6; TA_LEFT = 0; TA_RIGHT = 2; TA_BASELINE = 24; TA_TOP = 0; TA_BOTTOM = 8;
DT_CENTER = 1; DT_VCENTER = 4 | 32; DT_WORDBREAK = 16 ;
_GFX_ALL_cursorMouseButtons = GetCursorMouseButtons();
procedure GFX_ALL_SetOriginMAQ(GFX_ALLx0, GFX_ALLy0) {
global _GFX_ALLx0, _GFX_ALLy0;
_GFX_ALLx0 = GFX_ALLx0; _GFX_ALLy0 = GFX_ALLy0;
}
procedure GFX_ALL_Origin(x0, y0) {
global _x0, _y0;
_x0 = x0; _y0 = y0;
}
procedure GFX_ALL_SetColors(fgColor, bgColor) {
GfxSetTextColor(fgColor); GfxSetBkColor(bgColor);
GfxSelectPen(fgColor); GfxSelectSolidBrush(bgColor);
}
function GFX_ALL_BOX( Text, x1, y1, x2, y2, BorderColor, BackColor , textcolor , fnt, fntsize, fntweight )
{
GfxSetOverlayMode( 0 );
// GfxSelectFont( "Tahoma", 9, 800 );
GfxSelectFont( "fnt", fntsize, fntweight, 0, 0, 0 );
GfxSelectPen( BorderColor ,3);
GfxSetBkMode( 1 );
GfxSelectSolidBrush( BackColor );
GfxSetBkColor( BackColor );
GfxSetTextColor( textcolor );
GfxRectangle( x1, y1, x2, y2 );
GfxDrawText( Text, x1, y1, x2, y2, 32 | 1 | 4 );
}
function GFX_ALL_BOX2( Text, x1, y1, x2, y2, BorderColor, BackColor , textcolor , fnt, fntsize, fntweight )
{
GfxSetOverlayMode( 0 );
// GfxSelectFont( "Tahoma", 9, 800 );
GfxSelectFont( "fnt", fntsize, fntweight, 0, 0, 0 );
GfxSelectPen( BorderColor ,3);
GfxSetBkMode( 1 );
GfxSelectSolidBrush( BackColor );
GfxSetBkColor( BackColor );
GfxSetTextColor( textcolor );
GfxRectangle( x1, y1, x2, y2 );
GfxDrawText( Text, x1, y1, x2, y2, 16 | 1 | 4 );
}
procedure GFX_ALL_Label(Text, x1, y1, x2, y2, textcolor , fnt, fntsize, fntweight)
{
GfxSelectFont( "fnt", fntsize, fntweight, 0, 0, 0 );
GfxSetTextColor( textcolor );
GfxDrawText( Text, x1, y1, x2, y2, 32 | 1 | 4);
}
procedure GFX_ALL_Frame( x1, y1, x2, y2 ) {
GfxSelectSolidBrush( colorBlack);
GfxSetBkColor( colorBlack );
GfxRectangle(x1, y1, x2, y2);
}
function GFX_ALL_SetNumber(idEdit, Value, GFX_ALLX, GFX_ALLy, width, height, BorderColor, BackColor , textcolor , fnt, fntsize, fntweight ) {
global _x0, _y0;
local rc;
GFX_ALLX = GFX_ALLX+_x0; GFX_ALLY = GFX_ALLY+_y0;
rc = GuiEdit( idEdit, GFX_ALLX, RSI_MAQy, width, height, 0);
GuiSetValue(idEdit, Value );
return Value;
}
function GFX_ALL_EditNumber( idEdit, initialValue, GFX_ALLX, GFX_ALLY, width, height, textColor, bgColor )
{ // this function hold the text for the next restart of Amibroker
global _x0, _y0;
local rc ;
GFX_ALLX = GFX_ALLX + _x0 ; GFX_ALLY = GFX_ALLY + _y0 ;
rc = GuiEdit( idEdit, GFX_ALLX, GFX_ALLY, width, height, notifyHitReturn ); //
ID = GuiGetEvent( 0, 0 ); event = GuiGetEvent( 0, 1 );
if( ID == idEdit ) StaticVarSetText( "sV" + Name() + idEdit, GuiGetText( idEdit ), 1 );
if( rc == guiNew )
{ // after restart Amibroker read FIRST these Static Line
txt = StaticVarGettext( "sV" + Name() + idEdit );
GuiSetText( txt, idEdit );
}
GuiSetColors( idEdit, idEdit, 5, colorWhite, colorYellow, colorLightGrey );
return GuiGetValue( idEdit );
}
function GFX_ALL_PointInsideMAQ(GFX_ALLx0, GFX_ALLy0, GFX_ALLx, GFX_ALLy, width, height) {
global _GFX_ALLx0, _GFX_ALLy0;
GFX_ALLx = GFX_ALLx+_GFX_ALLx0; GFX_ALLy = GFX_ALLy+_GFX_ALLy0;
GFX_ALLx0 = GFX_ALLx0+_GFX_ALLx0; GFX_ALLy0 = GFX_ALLy0+_GFX_ALLy0;
return ((GFX_ALLx0 >= GFX_ALLx) && (GFX_ALLy0 >= GFX_ALLy) && (GFX_ALLx0 <= (GFX_ALLx+width)) && (GFX_ALLy0 <= (GFX_ALLy+height)));
}
function GFX_ALL_LeftClickInsideMAQ(GFX_ALLx, GFX_ALLy, width, height) {
global _GFX_ALL_cursorMouseButtons, _GFX_ALLx0, _GFX_ALLy0;
local px, py, res;
// x = x+_x0; y = y+_y0;
res = False;
if (_GFX_ALL_cursorMouseButtons & 8) { // click
px = GetCursorXPosition(1);
py = GetCursorYPosition(1);
res = GFX_ALL_PointInsideMAQ(px, py, GFX_ALLx, GFX_ALLy, width, height);
}
return res;
}
function GFX_ALL_GetState(id) {
return Nz(StaticVarGet("GfxState"+id+GetChartID()), 0);
}
procedure GFX_ALL_SetState(id, val) {
StaticVarSet("GfxState"+id+GetChartID(), val);
}
function GFX_ALL_HTabs(id, headers, headheight, GFX_ALLx, GFX_ALLy, width, height, colorfg, colorbg) {
global _GFX_ALLx0, _GFX_ALLy0;
local px,choice,na,i,n,header,w, wi, prevwi;
GFX_ALLx = GFX_ALLx+_GFX_ALLx0; GFX_ALLy = GFX_ALLy+_GFX_ALLy0; choice = GFX_ALL_GetState(id);
GFX_ALL_SetColors(colorfg, colorbg);
for(n = 0; (header = StrExtract(headers,n)) != ""; ++n) {};
w = width/n; wi = GFX_ALLx; prevwi = GFX_ALLx;
if (GFX_ALL_LeftClickInsideMAQ(GFX_ALLx,GFX_ALLy,width,headheight)) {
px = GetCursorXPosition( 1 );
// choice = floor((px - x)/w);
// wi = x; prevwi = x;
for(i = 0; (header = StrExtract(headers,i)) != ""; ++i) {
wi = wi + 1.32*GfxGetTextWidth(header);
if ((px > prevwi) && (px < wi)) { choice = i; break; }
}
GFX_ALL_SetState(id, choice); // StaticVarSet(na, choice);
}
GfxSetBkMode(1);
// Draw Zone & Tabs
wi = GFX_ALLx; prevwi = GFX_ALLx;
for(i = 0; (header = StrExtract(headers,i)) != ""; ++i) {
wi = wi + 1.32*GfxGetTextWidth(header);
GfxSelectSolidBrush(colorBlue);
GfxRoundRect(prevwi,GFX_ALLy,wi,GFX_ALLy+headheight+5,5,5);
if (i != choice) {
GfxSelectHatchBrush(colorBlack,3);
GfxRoundRect(prevwi,GFX_ALLy,wi,GFX_ALLy+headheight+5,5,5);
GfxSelectSolidBrush( colorBlack );
} else {
GfxSelectSolidBrush( colorBlack ) ;
wic = wi; prevwic = prevwi;
}
GfxDrawText(header, prevwi, GFX_ALLy, wi, GFX_ALLy+headheight+5, 1|4|32);
// GfxTextOut(header,0.5*(prevwi+wi),y);//+headheight); //*0.75);
prevwi = wi ;
}
GfxRectangle(GFX_ALLx,GFX_ALLy+headheight,GFX_ALLx+width+1200,GFX_ALLy+height+300);
GfxSelectPen(colorbg,1); GfxMoveTo(prevwic, GFX_ALLy+headheight); GfxLineTo(wic, GFX_ALLy+headheight);
return choice;
}
procedure GFX_ALL_CLC( GFX_ALLX, GFX_ALLY) {
local txt,textColor , bgColor , n,n2,n3,n4,n5,n6,n7,n8,Prefix,Xpx,Flags;;
GFX_ALL_Frame( GFX_ALLX + 140, GFX_ALLY + 165 , GFX_ALLX + 445 , GFX_ALLY + 420); // 30, 0, 30, 700, 180, colorWhite, colorblack(30, 0, 30, WITDTH, HIGHT, colorWhite, colorblack )
G = GFX_ALL_HTabs("HTab1", "Stocks,Currencies,Bonds,News", 30, GFX_ALLX + 0, GFX_ALLY + 0 , GFX_ALLX + 300, GFX_ALLY +585, colorWhite, colorBlack);
GFX_ALL_Origin( GFX_ALLX, GFX_ALLY);
// GFX_ALL_Frame( GFX_ALLX + 10 , GFX_ALLY + 180 , GFX_ALLX + 300 , GFX_ALLY + 330) ; // 30, 0, 30, 700, 180, colorWhite, colorblack(30, 0, 30, WITDTH, HIGHT, colorWhite, colorblack )
MACD_MAQ_DAY2= GFX_ALL_EditNumber(26, 0, GFX_ALLX + 275, GFX_ALLY + 248 , GFX_ALLX + 50, GFX_ALLY + 30, colorBlue, colorYellow) ; //////////////// TEXT BOX FOR THE SAME PERIOD
/////////////////// MACD
mx = Matrix(8,1);
rownum = MxGetSize(mx,0);
mx[0][0] = in5Minute;
mx[1][0] = in15Minute;
mx[2][0] = 2*in15Minute;
mx[3][0] = inHourly;
mx[4][0] = 4*inHourly;
mx[5][0] = inDaily;
mx[6][0] = inWeekly;
mx[7][0] = inMonthly;
/////////////////////// MACD parameters
M_FAST = 12 ; M_FAST_B = 12 ;
M_SLOW = 26 ; M_SLOW_B = 26 ;
M_SIG = 9 ; M_SIG_B = 9 ;
for ( i = 0; i < rownum; i++ )
{
TimeFrameSet( mx[i][0] );
inter_val = Interval(2);
MACD_FAST_A = Optimize ( "MACD Fast", M_FAST, 2, 200, 1 ); MACD_FAST_B = Optimize ( "MACD Fast", M_FAST_B, 2, 200, 1 );
MACD_SLOW_A = Optimize ("MACD Slow", M_SLOW , 2, 200, 1 ); MACD_SLOW_B = Optimize ("MACD Slow", M_SLOW_B , 2, 200, 1 );
MACD_SIG_A = Optimize ( "Signal average", M_SIG , 2, 200, 1 ); MACD_SIG_B = Optimize ( "Signal average", M_SIG_B , 2, 200, 1 );
////////////// MACD A
MACD_FAST_MultiMA_A = EMA (C ,MACD_FAST_A ) ;
MACD_SLOW_MultiMA_A = EMA (C ,MACD_SLOW_A ) ;
MACD_line_A = MACD_FAST_MultiMA_A - MACD_SLOW_MultiMA_A ;
MACD_signal_line_A = EMA ( MACD_line_A ,MACD_SIG_A) ;
MACD_zero_line_A = MACD_line_A - MACD_signal_line_A ; // Histogram
TimeFrameRestore();
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////// CALCULATION MACD ///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
// All CALCULATION AND conditions signal goes here
switch(G) {
case 0:
if ( i == 5 ) {
// DAILY
// GFX /GII
}
if ( i == 6 ) {
// weekly
// GFX /GII
}
if ( i == 7 ) {
// monthly
// GFX /GII
}
break;
case 1:
break;
case 2:
break;
case 3:
break;
}
}
}
if ( GFX_ALL) {
GFX_ALL_CLC( GFX_ALLX-23, GFX_ALLy - 23);
}
Filter = 1 ;
the performance report .
thank you