Value in text box will disappear GFX

value in editing text box will disappear when changing sheet or close AB
how to keep it permeant only change if i change it manually

edit

the code


_SECTION_BEGIN("Moon Calendar Trading System (MCTS)");

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() ); 
procedure SetOrigin(x0, y0) {
	global _x0, _y0;
	_x0 = x0; _y0 = y0;
}

procedure GfxSetColors(fgColor, bgColor) {
	GfxSetTextColor(fgColor); GfxSetBkColor(bgColor); 
	GfxSelectPen(fgColor); GfxSelectSolidBrush(bgColor);
}
procedure GfxFrame(titl,hheight, x, y, width, height, textColor, bgColor) {
	global _x0, _y0;
	x = x+_x0; y = y+_y0;
	GfxSetColors(textColor, bgColor);
    GfxRoundRect(x, y+0.5*hheight, x+width, y+height, 5, 5);
    if (titl != "") {
		w = GfxGetTextWidth(titl)*0.68; m = x+width*0.5;
		// GfxRectangle(m-w, y+1, m+w, y+hheight-1); 
		GfxRoundRect(m-w, y+1, m+w, y+hheight-1, 5, 5); 
		GfxDrawText(titl, x, y, x+width, y+hheight, 1|4|32);
		
    }
}

// Gui* part - Edit control
function SetNumber(idEdit, Value, x, y, width, height, textColor, bgColor) {
    global _x0, _y0;
	local rc;
	
    x = x+_x0; y = y+_y0;
    rc = GuiEdit( idEdit, x, y, width, height, 0); 
    GuiSetValue(idEdit, Value ); 
    GuiSetColors( idEdit, idEdit, 1, textColor, bgColor, textColor);
   
    return Value;
}
/*
Then modify all lines (replace EditNumber by SetNumber) starting from n3:
	n3 = SetNumber(3, (n2+n)/2, 180, 150, 80, 25, colorBlue, colorYellow);
// etc
*/
function EditNumber(idEdit, initialValue, x, y, width, height, textColor, bgColor) {
    global _x0, _y0;
	local rc;
	
    x = x+_x0; y = y+_y0;
    rc = GuiEdit( idEdit, x, y, width, height, 0); 
    if( rc == guiNew ) GuiSetValue(idEdit, initialValue ); 
    GuiSetColors( idEdit, idEdit, 1, textColor, bgColor, textColor);
   
    
    return GuiGetValue(idEdit);
}

 DT_VCENTER = 4 | 32; 
// format: 0 left, 1 center, 2 right
procedure GfxLabel(text, x, y, width, height, format) {
	global _x0, _y0;
	x = x+_x0; y = y+_y0;
	GfxDrawText( text, x, y, x+width, y+height, format | DT_VCENTER ); 
}

procedure GuiDemos(x,y) {
	local n,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,
	      n12,n13,n14,n15,n16,n17,n18,n19,n20
	      ,n21,n22,txt;
	      
	// GfxSelectFont("Arial", 9); GuiSetFont("Arial", 10);
	SetOrigin(x,y);
	GfxFrame("Moon Night Calendar Trading System", 30, 0, 30, 600, 600, colorWhite, colorblack); // 30, 0, 30, 700, 180, colorWhite, colorblack(30, 0, 30, WITDTH, HIGHT, colorWhite, colorblack )
	SetOrigin(x+20,y+30);
		///////////// editting TEXTBOX //////////////
	n = EditNumber(1, 0, 45, 65, 80, 25, colorBlue, colorYellow);
	n2 = EditNumber(2, 0, 400, 65, 80, 25, colorBlue, colorYellow); //2, 0, 200, 65, 80, 25, colorBlue, colorYellow ## SECOUND TEXTBOX, formula , LIFT / RIGHT, HIGHT/LOW, WIDTH OF THE TEXT BOX , HIGHT OF THE TEXT BOX
	
	///////////// restTEXTBOX //////////////
	n3 = SetNumber(3, (n2+n)/2, 180, 150, 80, 25, colorBlue, colorYellow);//textbox # , formula , LIFT / RIGHT , HIGHT/LOW , WIDTH OF THE TEXT BOX , HIGHT OF THE TEXT BOX.
	n4 = SetNumber(4, (n2+n)/2, 280, 150, 80, 25, colorBlue, colorYellow);
	n5 = SetNumber(5, (n2+n)/2, 380, 150, 80, 25, colorBlue, colorYellow);
	n6 = SetNumber(6, (n2+n)/2, 480, 150, 80, 25, colorBlue, colorYellow);
	
	n7 = SetNumber(7,(n2+n)/3 , 180, 240, 80, 25, colorBlue, colorYellow);
	n8 = SetNumber(8, (n2+n)/3, 280, 240, 80, 25, colorBlue, colorYellow);
	n9 = SetNumber(9, (n2+n)/3, 380, 240, 80, 25, colorBlue, colorYellow);
    n10 = SetNumber(10, (n2+n)/3, 480, 240, 80, 25, colorBlue, colorYellow);
	                                                                           // add formula for missing 3 days here
	n11 = SetNumber(11, (n2+n)/4, 180, 330, 80, 25, colorBlue, colorYellow);
	n12 = SetNumber(12, (n2+n)/4, 280, 330, 80, 25, colorBlue, colorYellow);
	n13 = SetNumber(13,(n2+n)/4, 380, 330, 80, 25, colorBlue, colorYellow);
	n14 = SetNumber(14, (n2+n)/4, 480, 330, 80, 25, colorBlue, colorYellow);
	
	n15 = SetNumber(15, (n2+n)/2 , 180, 420, 80, 25, colorBlue, colorYellow);
	n16 = SetNumber(16, (n2+n)/2, 280, 420, 80, 25, colorBlue, colorYellow);
	n17 = SetNumber(17, (n2+n)/2, 380, 420, 80, 25, colorBlue, colorYellow);
	n18 = SetNumber(18, (n2+n)/2, 480, 420, 80, 25, colorBlue, colorYellow);
	
	n19 = SetNumber(19, (n2+n)/2, 180, 510, 80, 25, colorBlue, colorYellow);
	n20 = SetNumber(20, (n2+n)/2, 280, 510, 80, 25, colorBlue, colorYellow);
	n21 = SetNumber(21, (n2+n)/2, 380, 510, 80, 25, colorBlue, colorYellow);
	n22 = SetNumber(22, (n2+n)/2, 480, 510, 80, 25, colorBlue, colorYellow);
	
	
	///////////////////////////////        LABEL        /////////////////////////////////////////
	          //HIGH First (add it manually from the moon trading system application ( desktop pc) ) //
	GfxLabel(" HFFM: "+n, 10, 30, 140, 30, 1);
	         //LOW LAST (add it manually from the moon trading system application ( desktop pc)) // ************************** to remmember  **********( convert the date or find the equivalent date  for the hi point and low point
	GfxLabel(" LLFM: "+n2, 350, 30, 140, 30, 1); // 110, 30, 140, 30, 1) LIFT / RIGHT, HIGHT/LOW, 140, 30, 1
	         //Waning(gibbous + quarter) 6 DAYS//
 	GfxLabel("WAN GQ: ", 0, 150, 140, 30, 1);
 	         //  Waning( quarter + crescent) 6 DAYS //
    GfxLabel("WAN QC: ", 0, 240, 140, 30, 1);
             // Dark Moon) 3 DAYS+ MISSING 3 DAYS //
    GfxLabel(" DM: ", 0, 330, 140, 30, 1);
             // waxing (crescent+ quarter) 6 DAYS //
     GfxLabel(" WAX CQ: ", 0, 420, 140, 30, 1);
             //  waxing ( quarter + gibbous) 6 DAYS //
       GfxLabel(" WAX QG: ", 0, 510, 140, 30, 1);
}




x = Param("x_origin", 20, 0, 1980, 20);
y = Param("y_origin", 20, 0, 1024, 20);
demo = ParamToggle("Show Demo", "No|Yes", 1);

if (demo) {
	
	GuiDemos(x+80, y+80);
	
}

i try to use this link

https://www.amibroker.com/guide/afl/staticvarset.html

and other post it topic but does not work .

thank you

i use PanoS code but i missed up.


_SECTION_BEGIN("Moon Calendar Trading System (MCTS)");

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() ); 
procedure SetOrigin(x0, y0) {
	global _x0, _y0;
	_x0 = x0; _y0 = y0;
}

procedure GfxSetColors(fgColor, bgColor) {
	GfxSetTextColor(fgColor); GfxSetBkColor(bgColor); 
	GfxSelectPen(fgColor); GfxSelectSolidBrush(bgColor);
}
procedure GfxFrame(titl,hheight, x, y, width, height, textColor, bgColor) {
	global _x0, _y0;
	x = x+_x0; y = y+_y0;
	GfxSetColors(textColor, bgColor);
    GfxRoundRect(x, y+0.5*hheight, x+width, y+height, 5, 5);
    if (titl != "") {
		w = GfxGetTextWidth(titl)*0.68; m = x+width*0.5;
		// GfxRectangle(m-w, y+1, m+w, y+hheight-1); 
		GfxRoundRect(m-w, y+1, m+w, y+hheight-1, 5, 5); 
		GfxDrawText(titl, x, y, x+width, y+hheight, 1|4|32);
		
    }
}

// Gui* part - Edit control
/*
Then modify all lines (replace EditNumber by SetNumber) starting from n3:
	n3 = SetNumber(3, (n2+n)/2, 180, 150, 80, 25, colorBlue, colorYellow);
// etc
*/
function SetNumber(idEdit, Value, x, y, width, height, textColor, bgColor) {
    global _x0, _y0;
	local rc;
	
    x = x+_x0; y = y+_y0;
    rc = GuiEdit( idEdit, x, y, width, height, 0); 
    GuiSetValue(idEdit, Value ); 
    GuiSetColors( idEdit, idEdit, 1, textColor, bgColor, textColor);
   
    return Value;
}


function EditNumber(idEdit, initialValue, x, y, width, height, textColor, bgColor) {
    global _x0, _y0;
	local rc;
	
    x = x+_x0; y = y+_y0;
    rc = GuiEdit( idEdit, x, y, width, height, 0); 
    if( rc == guiNew ) StaticVarGettext(idEdit, initialValue ); 
    GuiSetColors( idEdit, idEdit, 1, textColor, bgColor, textColor);
   
    
    return GuiGetValue(idEdit);
}


 DT_VCENTER = 4 | 32; 
// format: 0 left, 1 center, 2 right
procedure GfxLabel(text, x, y, width, height, format) {
	global _x0, _y0;
	x = x+_x0; y = y+_y0;
	GfxDrawText( text, x, y, x+width, y+height, format | DT_VCENTER ); 
}


procedure GuiDemos(x,y) {
	local  n,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,
	      n12,n13,n14,n15,n16,n17,n18,n19,n20
	      ,n21,n22,txt2,Prefix,Xpx,Flags;
	      
	    

	
	// GfxSelectFont("Arial", 9); GuiSetFont("Arial", 10);
	SetOrigin(x,y);
	GfxFrame("Moon Night Calendar Trading System", 30, 0, 30, 600, 600, colorWhite, colorblack); // 30, 0, 30, 700, 180, colorWhite, colorblack(30, 0, 30, WITDTH, HIGHT, colorWhite, colorblack )
	SetOrigin(x+20,y+30);
	
	
	
	
	 Prefix = Name()+"GuiIdVal";
  Xpx=Status( "pxchartwidth");

  Flags = notifyHitReturn ;
  // Note : After you type a text in the Gui edit button you need to hit the ENTER button of your keyboard
  GuiEdit( 25, Xpx-1000, 180, 50, 20, Flags );
  GuiEdit( 26, Xpx-1110, 150, 50, 20, Flags );
  id = GuiGetEvent( 0, 0 ); 	event = GuiGetEvent( 0, 1 );

 // here is the staticVar that store the value in the hard-drive (read the AB documentation) 
 //if( id == 21 ) StaticVarSettext( Prefix + 21, GuiGetText( 21 ),1 );
// if( id == 22 ) StaticVarSettext( Prefix + 22, GuiGetText( 22 ),1 );

 // Place the "LAST" StaticVar text back to the Guiedit box
 GuiButton( "Load sV", 99, Xpx - 1050, 200, 80, 20, 1);
 if( id == 99 && event == 1 )
 {
    sVal21 = StaticVarGettext( Prefix + 25 );
    sVal22 = StaticVarGettext( Prefix + 26 );
    GuiSetText( sVal21, 25 );
    GuiSetText( sVal22, 26 );
 }
 
		///////////// TEXTBOX //////////////
		
	n = EditNumber(1, StaticVarSettext( Prefix + 25, GuiGetText( 25 ),1 ), 45, 65, 80, 25, colorBlue, colorYellow);
	n2 = EditNumber(2, StaticVarSettext( Prefix + 26, GuiGetText( 26 ),1 ), 400, 65, 80, 25, colorBlue, colorYellow); //2, 0, 200, 65, 80, 25, colorBlue, colorYellow ## SECOUND TEXTBOX, formula , LIFT / RIGHT, HIGHT/LOW, WIDTH OF THE TEXT BOX , HIGHT OF THE TEXT BOX
	
	
 
	
	
	
	
	
	n3 = SetNumber(3, (n2+n)/2, 180, 150, 80, 25, colorBlue, colorYellow);//textbox # , formula , LIFT / RIGHT , HIGHT/LOW , WIDTH OF THE TEXT BOX , HIGHT OF THE TEXT BOX.
	n4 = SetNumber(4, (n2+n)/2, 280, 150, 80, 25, colorBlue, colorYellow);
	n5 = SetNumber(5, (n2+n)/2, 380, 150, 80, 25, colorBlue, colorYellow);
	n6 = SetNumber(6, (n2+n)/2, 480, 150, 80, 25, colorBlue, colorYellow);
	
	n7 = SetNumber(7,(n2+n)/3 , 180, 240, 80, 25, colorBlue, colorYellow);
	n8 = SetNumber(8, (n2+n)/3, 280, 240, 80, 25, colorBlue, colorYellow);
	n9 = SetNumber(9, (n2+n)/3, 380, 240, 80, 25, colorBlue, colorYellow);
    n10 = SetNumber(10, (n2+n)/3, 480, 240, 80, 25, colorBlue, colorYellow);
	                                                                           // add formula for missing 3 days here
	n11 = SetNumber(11, (n2+n)/4, 180, 330, 80, 25, colorBlue, colorYellow);
	n12 = SetNumber(12, (n2+n)/4, 280, 330, 80, 25, colorBlue, colorYellow);
	n13 = SetNumber(13,(n2+n)/4, 380, 330, 80, 25, colorBlue, colorYellow);
	n14 = SetNumber(14, (n2+n)/4, 480, 330, 80, 25, colorBlue, colorYellow);
	
	n15 = SetNumber(15, (n2+n)/2 , 180, 420, 80, 25, colorBlue, colorYellow);
	n16 = SetNumber(16, (n2+n)/2, 280, 420, 80, 25, colorBlue, colorYellow);
	n17 = SetNumber(17, (n2+n)/2, 380, 420, 80, 25, colorBlue, colorYellow);
	n18 = SetNumber(18, (n2+n)/2, 480, 420, 80, 25, colorBlue, colorYellow);
	
	n19 = SetNumber(19, (n2+n)/2, 180, 510, 80, 25, colorBlue, colorYellow);
	n20 = SetNumber(20, (n2+n)/2, 280, 510, 80, 25, colorBlue, colorYellow);
	n21 = SetNumber(21, (n2+n)/2, 380, 510, 80, 25, colorBlue, colorYellow);
	n22 = SetNumber(22, (n2+n)/2, 480, 510, 80, 25, colorBlue, colorYellow);
	
	
	///////////////////////////////        LABEL        /////////////////////////////////////////
	          //HIGH First (add it manually from the moon trading system application ( desktop pc) ) //
	GfxLabel(" HFFM: "+n, 10, 30, 140, 30, 1);
	         //LOW LAST (add it manually from the moon trading system application ( desktop pc)) // ************************** to remmember  **********( convert the date or find the equivalent date  for the hi point and low point
	GfxLabel(" LLFM: "+n2, 350, 30, 140, 30, 1); // 110, 30, 140, 30, 1) LIFT / RIGHT, HIGHT/LOW, 140, 30, 1
	         //Waning(gibbous + quarter) 6 DAYS//
 	GfxLabel("WAN GQ: ", 0, 150, 140, 30, 1);
 	         //  Waning( quarter + crescent) 6 DAYS //
    GfxLabel("WAN QC: ", 0, 240, 140, 30, 1);
             // Dark Moon) 3 DAYS+ MISSING 3 DAYS //
    GfxLabel(" DM: ", 0, 330, 140, 30, 1);
             // waxing (crescent+ quarter) 6 DAYS //
     GfxLabel(" WAX CQ: ", 0, 420, 140, 30, 1);
             //  waxing ( quarter + gibbous) 6 DAYS //
       GfxLabel(" WAX QG: ", 0, 510, 140, 30, 1);
}

x = Param("x_origin", 20, 0, 1980, 20);
y = Param("y_origin", 20, 0, 1024, 20);
demo = ParamToggle("Show Demo", "No|Yes", 1);

if (demo) {
	
	GuiDemos(x+80, y+80);
	
}

@needhelp, creating new (essentially duplicated) threads continuing the same topic you previously opened in another thread is not a good idea...

Please, avoid it in the future.

I suggest reviewing these forum guidelines.

1 Like

i try to delete it but i can't

https://forum.amibroker.com/t/hid-show-and-save-in-gfx/31288/9

solved by PanoS

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.