GetCursorYPosition() on GuiButton

hi, i have been away a bit from Amibroker and a bit out of touch. I am translating a little tool I had using GFX and now want to use the new GUI buttons. With the tool you can set an entry line, target line etc. For instance in the GIF image below I have activated a "target line at end of bar". Then another Guibutton appears at the right Y-axis and I want to click on this button to activate the line at a certain price.

However, when my mouse is on top of the guibutton I do not get a reading from GetCursorYPosition(). So then I can not set the line accurately. You see when the mouse is on top of the Guibutton it does not move smoothly because it only gets a mouse reading when it is outside of the button.

How do I get mouse readings on top of the Guibutton? Or should I not use GUIbuttons for this?

tst1

1 Like

As Tomasz wrote:

So if mouse is e.g. on button then it is on separate window.


One can hide/disable controls when not needed and show/enable again if needed.
See Gui* function list in AB manual for showing/hiding, enabling/disabling GUI controls.

As you can see in below GIF when I hide/disable control then a "shadow" is still visible at same position and cross-hair still showing if being above of that "shadow". Then I enable/show button again via click.

6

1 Like

ok thanks. To enable again I guess I will need to use GetCursorMouseButton(). I will try it out, thanks

1 Like

you need AFL Function - GUISETCHECK

GuiSetCheck( id, check )
GuiGetCheck( id )

P.S. i have one idea, how to solve the first question but i have to write the code and try first.
After my dinner i be back

1 Like

Wrong. I meant GutEnable().

/// @link https://forum.amibroker.com/t/getcursoryposition-on-guibutton/17138/5
CTRL = GetAsyncKeyState(17) < 0;

gcmb = GetCursorMouseButtons();
LMB = gcmb == 9;
MMB = gcmb == 12;
gcx_px = GetCursorXPosition(1);
gcy_px = GetCursorYPosition(1);
gcy = GetCursorYPosition(0);

x1 = Status("firstvisiblebar");
x2 = Status("lastvisiblebar");
y1 = gcy;

pxcw = Status("pxchartwidth");
xbutt = pxcw-55;

button = GuiButton(""+gcy, id1 = 1, xbutt, gcy_px-10, 60, 21, notifyClicked);

if ( button == guiNew )
	GuiSetColors( id1, id1, 1, -1, colorRed, -1, -1, colorGreen, -1, -1, colorYellow, -1, -1, -1, -1);

if ( IsNull(gcy_px) OR gcx_px < xbutt )
	GuiEnable(id1, 0);
if ( CTRL && lmb AND gcx_px >= xbutt ) 
	GuiEnable(id1, true);

Plot( C, "Price", colorDefault, styleBar );

GfxSetCoordsMode(1);
GfxSetBkMode(1);
GfxSelectPen( colorRed, 1, 1 );	
GfxMoveTo( x1, y1 );
GfxLineTo( x2, y1 );
	
RequestMouseMoveRefresh();

6

2 Likes

thansk guys, I have something working now but will study that code and get back on it tomorrow

i used GetCursorMouseButtons() but looks like you have a better way. Will respond tomorrow

tst6

1 Like

Ok. Edward the story was to check if the mouse in ON the GuiButton or not.

Possible notify flags @empottasch you may need are

  • notifySetFocus - when control gets input focus (via mouse or keyboard)
  • notifyKillFocus - when control loses input focus (via mouse or keyboard)

But as @fxshrat wrote all ready my idea with different way (if you have AB version > 6.30) i donot have to add anything else at this moment.

1 Like

And for GuiTriger button i use this

// this is my_GuiTrigger button 

GuiToggle("My_Triger_button", 3, 10, 120, 180, 24 ,1);
if( GuiGetCheck( 3 ) )
{
	// if button pressed do something
    Say( "hello", 1 );
    GuisetCheck( 3, 0 );  // reset button
}
1 Like

I fear this gets another thread of length of Chinese wall....

I would rather use GFX for cursor line+box and then if level is chosen... only then GUI button is set.

So follow up code...

Usage instructions:

  1. click button "Show cursor line" to enable it
  2. Move mouse up/down to choose a price level
  3. Click CTRL+LMB (left mouse button) to fix price level
  4. To release price level line and button:
    1. -> move mouse away from button
    2. -> next, hold ALT key of keyboard
    3. -> move mouse back to button and wait for release and speech
  5. Choose new price level
  6. see point 3. etc.

Notes:

  • To disable set price button click CTRL+LMB (left mouse button) outside of price button area
  • To re-enable set price button click left mouse button if being on GUI price button with your mouse
  • To disable speech go to line 31 and modify it to FALSE

/// @link https://forum.amibroker.com/t/getcursoryposition-on-guibutton/17138/9
/// by fxshrat@gmail.com
/// Usage:
/// 1. click button "Show cursor line" to enable it
/// 2. Move mouse up/down to choose a price level
/// 3. Click CTRL+LMB to fix price level
/// 4. To release price level line and button:
///     1. -> move mouse away from button
///     2. -> next, hold ALT key of keyboard
///     3. -> move mouse back to button and wait for release and speech
/// 5. Choose new price level
/// 6. see point 3. etc.
/// Notes: 
/// - To disable price button click CTRL+LMB (left mouse button) outside of price button area
/// - To re-enable price button click left mouse button if being on GUI price button with your mouse
/// - To disable speech go to line 31 and modify it to FALSE		
gcmb = GetCursorMouseButtons();
LMB = gcmb == 9;
MMB = gcmb == 12;
CTRL = GetAsyncKeyState(17) < 0;
ALT = GetAsyncKeyState(18) < 0;
gcx_px = GetCursorXPosition(1);
gcy_px = GetCursorYPosition(1);
gcy = GetCursorYPosition(0);
pxcw = Status("pxchartwidth");
x1 = 0; x2 = pxcw+5;
xbutt = pxcw-55;
static_pxy = StaticVarGet( "button_pxy" );
static_y = StaticVarGet( "button_y" );

speech_ON = True;

is_in_button = gcx_px >= xbutt AND gcx_px <= x2 AND 
				gcy_px >= static_pxy-10 and gcy_px <= static_pxy+10;			

id1 = 1;
id = GuiGetEvent(0, 0);
event = GuiGetEvent( 0, 1 );
	
clickevent = event == notifyClicked;

button_is_visible = NOT IsNull(static_y);

printf( "notifyClicked %g\n", notifyClicked);
printf( "notifyMouseLeave %g\n", notifyMouseLeave);
printf( "notifyMouseEnter %g\n", notifyMouseEnter);
printf( "GUI event %g, CTRL: %g, ALT: %g, LMB: %g", event, CTRL, ALT, LMB );

// Remove static price line and button on CTRL + Mouse wheel click
if ( ALT AND event == notifyMouseEnter AND id == id1 ) {
	StaticVarRemove("button_*" );
	if ( speech_ON )	Say( "Gui button has been entered and removed.", 0);
}

// Set price fix level + button via left mouse button click + CTRL	
if ( CTRL AND LMB AND NOT button_is_visible ) {
	StaticVarSet( "button_y", gcy);
	StaticVarSet( "button_pxy", gcy_px);
	if ( speech_ON )	Say( "Gui button has been set.", 0);
}

if ( id == id1 AND event == notifyMouseLeave ) {
	if ( speech_ON )	Say( "Button has been left.", 0);	
}

// GUI trigger line if static GetCursorYPosition exists
if ( button_is_visible ) {
	button = GuiButton(""+static_y, id1, xbutt, static_pxy-10, 60, 20, notifyClicked | notifyMouseLeave | notifyMouseEnter );

	button_clicked = id == id1 AND clickevent;
	
	if ( button == guiNew ) {
		GuiSetColors( id1, id1, 1, -1, colorRed, -1, -1, colorGreen, -1, -1, colorYellow, -1, -1, -1, -1);
		GuiSetFont("ARIAL", 9);	
	}
	
	// Disable button if clicking outside of button area 
	if ( CTRL AND LMB ) {		
		if ( NOT is_in_button ) {
			GuiEnable(id1, 0);
			//
			if ( IsNull(StaticVarGet("button_GuiEnable"))) {
				if ( speech_ON ) 
					Say("Price Button disabled! Re-click that button to re-enable it.");				
				StaticVarSet("button_GuiEnable", 1);
			}
		}			
	}
	
	// Enable button if clicking in area of button	
	if ( LMB AND is_in_button  ) {		
		GuiEnable(id1, 1);
		if ( speech_ON ) 
			Say("Price button enabled! Click that button one more time to trigger!", 1);
		StaticVarRemove("button_GuiEnable");		
	}	
	
	// Do something if button is enabled (not white) and if clicked
	if ( button_clicked ) {
		Say(txt = "Hello world!", 0);
		// Draw some message on chart
		GfxSetBkMode( 1 );
		GfxSetTextColor( colorRed );	
		GfxSelectFont("ARIAL", 40);	
		GfxDrawText(txt, 0, 0, pxcw+5, Status("pxchartheight"), 1+4+32); 
		//etc....
	}
}	

toggle = GuiToggle( "Show Cursor Line", id2 = id1+1, 0, 15, 110, 25, notifyClicked);

SetChartOptions( 1, chartShowDates | chartShowArrows | chartWrapTitle | chartDisableTooltips );
Plot( C, "Price", colorDefault, styleBar );

GfxSetCoordsMode(0);
GfxSetBkMode(1);

// cursor line
if ( ! button_is_visible AND GuiGetCheck(id2) ) {
	GfxSelectPen( colorYellow, 1, 1 );	
	GfxMoveTo( 0, gcy_px );
	GfxLineTo( pxcw, gcy_px ); 

	GfxFillSolidRect( xbutt, gcy_px-10, pxcw+5, gcy_px+10, colorYellow);
	GfxSelectFont("ARIAL", 9, 500, 0, 0, 0);
	GfxSetTextColor( colorBlack );
	GfxDrawText(""+gcy, xbutt, gcy_px-8, pxcw+10, gcy_px+8, 1+4+32); 
}

// static line
if ( button_is_visible ) { 	
	GfxSelectPen( colorRed, 1, 1 );	
	GfxMoveTo( x1, static_pxy );
	GfxLineTo( x2, static_pxy );
}

RequestMouseMoveRefresh();

In action:
6

3 Likes

ok thanks guys. I might not use the GUI for the button at the price line because it needs pixel coordinates and then if you change the scaling of the chart the line stays at the fixed pixel coordinates rather then stay at the correct price. I will just use the GUI fixed buttons and then use GFX for the line and the button at the line. In the GIF I show my old GFX button code and you see that the line remains at the price. With the GUI button this will be difficult. I had not thought about this at first. So for this part I will use GFX only. Thanks again for your help

tst10

2 Likes

oh well I can ofcourse just convert the price value to pixel value .... guess I will do that.

function GfxConvertValueToPixelY( Value )
{
    local Miny, Maxy, pxchartbottom, pxchartheight;

    Miny = Status( "axisminy" );
    Maxy = Status( "axismaxy" );

    pxchartbottom = Status( "pxchartbottom" );
    pxchartheight = Status( "pxchartheight" );

    return pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight / ( Maxy - Miny ) );
}
2 Likes

Here is an update of my upper quick example with better code structure as you should rather set GUI buttons first and then add everything else (GuiGetEvent(), GuiSetVisible()...). It is smoother now.

/// @link https://forum.amibroker.com/t/getcursoryposition-on-guibutton/17138/12
/// by fxshrat@gmail.com
/// Usage:
/// 1. click button "Show cursor line" to enable it
/// 2. Move mouse up/down to choose a price level
/// 3. Click CTRL+LMB to fix price level
/// 4. To release price level line and button:
///     1. -> move mouse away from button
///     2. -> next, hold ALT key of keyboard
///     3. -> move mouse back to button and wait for release and speech
/// 5. Choose new price level
/// 6. see point 3. etc.
/// Notes: 
/// - To disable set price button click CTRL+LMB (left mouse button) outside of price button area
/// - To re-enable set price button click left mouse button if being on GUI price button with your mouse
/// - To disable speech go to line 31 and modify it to FALSE			
gcmb = GetCursorMouseButtons();
LMB = gcmb == 9;
MMB = gcmb == 12;
CTRL = GetAsyncKeyState(17) < 0;
ALT = GetAsyncKeyState(18) < 0;
gcx_px = GetCursorXPosition(1);
gcy_px = GetCursorYPosition(1);
gcy = GetCursorYPosition(0);
pxcw = Status("pxchartwidth");
x1 = 0; x2 = pxcw+5;
xbutt = pxcw-55;
static_pxy = StaticVarGet( "button_pxy" );
static_y = StaticVarGet( "button_y" );

speech_ON = True;

is_in_button = gcx_px >= xbutt AND gcx_px <= x2 AND 
				gcy_px >= static_pxy-10 and gcy_px <= static_pxy+10;			

id1 = 1;
button = GuiButton(""+static_y, id1, xbutt, static_pxy-10, 60, 20, notifyClicked | notifyMouseLeave | notifyMouseEnter );
toggle = GuiToggle( "Show Cursor Line", id2 = id1+1, 0, 15, 110, 25, notifyClicked);

if ( button == guiNew ) {
	GuiSetColors( id1, id1, 1, -1, colorRed, -1, -1, colorGreen, -1, -1, colorYellow, -1, -1, -1, -1);
	GuiSetFont("ARIAL", 9);	
}

id = GuiGetEvent(0, 0);
event = GuiGetEvent( 0, 1 );	
clickevent = event == notifyClicked;

button_is_visible = NOT IsNull(static_y);
button_clicked = id == id1 AND clickevent;

printf( "notifyClicked %g\n", notifyClicked);
printf( "notifyMouseLeave %g\n", notifyMouseLeave);
printf( "notifyMouseEnter %g\n", notifyMouseEnter);
printf( "GUI event %g, CTRL: %g, ALT: %g, LMB: %g", event, CTRL, ALT, LMB );

// Remove static price line and button on ALT + entering button
if ( ALT AND id == id1 AND event == notifyMouseEnter ) {
	GuiSetVisible(id1, 0);
	StaticVarRemove("button_*" );
	if ( speech_ON )	Say( "Gui button has been entered and removed.", 0);
}

// Set price fix level and price button via CTRL + left mouse button click 	
if ( CTRL AND LMB AND NOT button_is_visible ) {
	GuiSetVisible(id1, 1);	
	StaticVarSet( "button_y", gcy);
	StaticVarSet( "button_pxy", gcy_px);
	if ( speech_ON )	Say( "Gui button has been set.", 0);	
}

//if ( id == id1 AND event == notifyMouseLeave ) {
//	if ( speech_ON )	Say( "Button has been left.", 0);	
//}

// GUI trigger line if static GetCursorYPosition exists
if ( button_is_visible ) {		
	// Disable button if clicking outside of button area 
	if ( CTRL AND LMB ) {	// CTRL + Left mouse button	
		if ( NOT is_in_button ) {
			GuiEnable(id1, 0);	
			if ( speech_ON ) Say("Price Button disabled! Re-click that button to re-enable it.");			
		}			
	}	
	// Enable button if clicking in area of button	
	if ( LMB AND is_in_button  ) {	// left mouse button in button area	
		GuiEnable(id1, 1);
		if ( speech_ON ) Say("Price button enabled! Click that button one more time to trigger!", 1);
	}		
	// Do something if button is enabled (not white) and if clicked
	if ( button_clicked ) {
		Say(txt = "Hello world!", 0);
		// Draw some message on chart
		GfxSetBkMode( 1 );
		GfxSetTextColor( colorRed );	
		GfxSelectFont("ARIAL", 40);	
		GfxDrawText(txt, 0, 0, pxcw+5, Status("pxchartheight"), 1+4+32); 
		//etc....
	}
}	

// ######################################## Plot #############################################

SetChartOptions( 1, chartShowDates | chartShowArrows | chartWrapTitle | chartDisableTooltips );
Plot( C, "Price", colorDefault, styleBar );

GfxSetCoordsMode(0);
GfxSetBkMode(1);

// cursor line
if ( ! button_is_visible AND GuiGetCheck(id2) ) {
	GfxSelectPen( colorYellow, 1, 1 );	
	GfxMoveTo( 0, gcy_px );
	GfxLineTo( pxcw, gcy_px ); 

	GfxFillSolidRect( xbutt, gcy_px-10, pxcw+5, gcy_px+10, colorYellow);
	GfxSelectFont("ARIAL", 9, 500, 0, 0, 0);
	GfxSetTextColor( colorBlack );
	GfxDrawText(""+gcy, xbutt, gcy_px-8, pxcw+10, gcy_px+8, 1+4+32); 
}

// static line
if ( button_is_visible ) { 	
	GfxSelectPen( colorRed, 1, 1 );	
	GfxMoveTo( x1, static_pxy );
	GfxLineTo( x2, static_pxy );
}

RequestMouseMoveRefresh();
4 Likes

OK, code needs another update because of pixel issue...

1 Like

thanks I will have a look and see if I can use parts of it. I do not like so much that keys have to be pressed :slight_smile:

I have a working code myself as well where everything can be done by mouse clicks. I could post it but it is still in development because it also contains the trading itself, i mean sending orders to the TWS. So it is quite large (900 lines) and probably not very useful for others.

But for me it was a useful question because of the enabling/disabling of the GUI buttons. So I use this in combination with GetCursorMouseButtons() and works good. Will however look if I could use parts of your code

1 Like

yes I just use the convertValueToPixel code posted above

here is a snipit from my code where I put is to use

if( StaticVarGet( "targetLineOnOffFlag" + cid ) > 0 )
{
    tgtLine = Nz( GetCursorYPosition( 0 ) );
    tgtLinepix = Nz( GetCursorYPosition( 1 ) );

    if( StaticVarGet( "varTGT" + cid ) == 0 )
    {
        StaticVarSet( "tgtLine" + cid, round( tgtLine / TickSize ) * TickSize );
        StaticVarSet( "tgtLinepix" + cid, tgtLinepix );
    }

    GuiButton( "" + StaticVarGet( "tgtLine" + cid ), 91, pxw - ( butwidth ), GfxConvertValueToPixelY( StaticVarGet( "tgtLine" + cid ) ) - ( butheight / 2 ), butwidth, butheight, notifyClicked );

    GuiSetColors( 91, 91, border,
                  ColorRGB( 0, 0, 0 ), StaticVarGet( "targetLineOnOffFlagColor" + cid ), ColorRGB( 50, 50, 50 ), // text/back/border
                  ColorRGB( 0, 0, 0 ), StaticVarGet( "targetLineOnOffFlagColor" + cid ), ColorRGB( 50, 50, 50 ), // selected (text/back/border)
                  ColorRGB( 0, 0, 0 ), StaticVarGet( "targetLineOnOffFlagColor" + cid ), colorYellow, // hover
                  ColorRGB( 0, 0, 0 ), StaticVarGet( "targetLineOnOffFlagColor" + cid ), ColorRGB( 50, 50, 50 ) ); // disabled
2 Likes

You do not need that function. Just use Remap().

Here is version 1.2 fixing pixel issue.

/// @link https://forum.amibroker.com/t/getcursoryposition-on-guibutton/17138/14
/// version 1.2
/// by fxshrat@gmail.com
/// Usage:
/// 1. click button "Show cursor line" to enable it
/// 2. Move mouse up/down to choose a price level
/// 3. Click CTRL+LMB to fix price level
/// 4. To release price level line and button:
///     1. -> move mouse away from button
///     2. -> next, hold ALT key of keyboard
///     3. -> move mouse back to button and wait for release and speech
/// 5. Choose new price level
/// 6. see point 3. etc.
/// Notes: 
/// - To disable set price button click CTRL+LMB (left mouse button) outside of price button area
/// - To re-enable set price button click left mouse button if being on GUI price button with your mouse
/// - To disable speech go to line 37 and modify it to FALSE
Version(6.30);
gcmb = GetCursorMouseButtons();
LMB = gcmb == 9;
MMB = gcmb == 12;
CTRL = GetAsyncKeyState(17) < 0;
ALT = GetAsyncKeyState(18) < 0;
gcx_px = GetCursorXPosition(1);
gcy_px = GetCursorYPosition(1);
gcy = GetCursorYPosition(0);
pxcw = Status("pxchartwidth");
x1 = 0; x2 = pxcw+5;
xbutt = pxcw-55;
static_y = StaticVarGet( "button_y" );
miny = Status( "axisminy" );
maxy = Status( "axismaxy" );
pxct = Status( "pxcharttop" );
pxcb = Status( "pxchartbottom" );
static_pxy = Remap(static_y, miny, maxy, pxcb, pxct); 

speech_ON = True;

is_in_button = gcx_px >= xbutt AND gcx_px <= x2 AND 
				gcy_px >= static_pxy-10 and gcy_px <= static_pxy+10;			

id1 = 1;
button = GuiButton(""+static_y, id1, xbutt, static_pxy-10, 60, 20, notifyClicked | notifyMouseLeave | notifyMouseEnter );
toggle = GuiToggle( "Show Cursor Line", id2 = id1+1, 0, 15, 110, 25, notifyClicked);

if ( button == guiNew ) {
	GuiSetColors( id1, id1, 1, -1, colorRed, -1, -1, colorGreen, -1, -1, colorYellow, -1, -1, -1, -1);
	GuiSetFont("ARIAL", 9);	
}

id = GuiGetEvent(0, 0);
event = GuiGetEvent( 0, 1 );	
clickevent = event == notifyClicked;

button_is_visible = NOT IsNull(static_y);
button_clicked = id == id1 AND clickevent;

printf( "notifyClicked %g\n", notifyClicked);
printf( "notifyMouseLeave %g\n", notifyMouseLeave);
printf( "notifyMouseEnter %g\n", notifyMouseEnter);
printf( "GUI event %g, CTRL: %g, ALT: %g, LMB: %g", event, CTRL, ALT, LMB );

// Remove static price line and button on ALT + entering button
if ( ALT AND id == id1 AND event == notifyMouseEnter ) {
	GuiSetVisible(id1, 0);
	StaticVarRemove("button_*" );
	if ( speech_ON )	Say( "Gui button has been entered and removed.", 0);
}

// Set price fix level and price button via CTRL + left mouse button click 	
if ( CTRL AND LMB AND NOT button_is_visible ) {
	GuiSetVisible(id1, 1);	
	StaticVarSet( "button_y", gcy);
	if ( speech_ON )	Say( "Gui button has been set.", 0);	
}

//if ( id == id1 AND event == notifyMouseLeave ) {
//	if ( speech_ON )	Say( "Button has been left.", 0);	
//}

// GUI trigger line if static GetCursorYPosition exists
if ( button_is_visible ) {		
	// Disable button if clicking outside of button area 
	if ( CTRL AND LMB ) {	// CTRL + Left mouse button	
		if ( NOT is_in_button ) {
			GuiEnable(id1, 0);	
			if ( speech_ON ) Say("Price Button disabled! Re-click that button to re-enable it.");			
		}			
	}	
	// Enable button if clicking in area of button	
	if ( LMB AND is_in_button  ) {	// left mouse button in button area	
		GuiEnable(id1, 1);
		if ( speech_ON ) Say("Price button enabled! Click that button one more time to trigger!", 1);
	}		
	// Do something if button is enabled (not white) and if clicked
	if ( button_clicked ) {
		Say(txt = "Hello world!", 0);
		// Draw some message on chart
		GfxSetBkMode( 1 );
		GfxSetTextColor( colorRed );	
		GfxSelectFont("ARIAL", 40);	
		GfxDrawText(txt, 0, 0, pxcw+5, Status("pxchartheight"), 1+4+32); 
		//etc....
	}
}	

// ######################################## Plot #############################################

SetChartOptions( 1, chartShowDates | chartShowArrows | chartWrapTitle | chartDisableTooltips );
Plot( C, "Price", colorDefault, styleBar );

GfxSetCoordsMode(0);
GfxSetBkMode(1);

// cursor line
if ( ! button_is_visible AND GuiGetCheck(id2) ) {
	GfxSelectPen( colorYellow, 1, 1 );	
	GfxMoveTo( 0, gcy_px );
	GfxLineTo( pxcw, gcy_px ); 

	GfxFillSolidRect( xbutt, gcy_px-10, pxcw+5, gcy_px+10, colorYellow);
	GfxSelectFont("ARIAL", 9, 500, 0, 0, 0);
	GfxSetTextColor( colorBlack );
	GfxDrawText(""+gcy, xbutt, gcy_px-8, pxcw+10, gcy_px+8, 1+4+32); 
}

// static line
if ( button_is_visible ) { 	
	GfxSelectPen( colorRed, 1, 1 );	
	GfxMoveTo( x1, static_pxy );
	GfxLineTo( x2, static_pxy );
}

RequestMouseMoveRefresh();
7 Likes

ok thanks, I didn't know that function yet. Will have a look later, will be out now for a bit.

it is code that should be used with the TWS (trader work station). Also it is not yet fully tested and still work in progress. So if you use it with the TWS maybe use the paper trading account.

code should be put inside the folder C:\Program Files\AmiBroker\Formulas\Custom and then dragged on top of an existing chart. It is however over 900 lines. It does not seem I can attach a file. Not sure if it is allowed to put so many lines of code inside a message

1 Like

i will possibly later. The button part is working great I just had some issues with the trading part which I need to sort out next few days

1 Like

You can post as much as you need but just enclose it in code tags:

Using code button