Setting prices with your cursor

To place LMT or STP orders quickly is easiest done by moving the horizontal cursor-line over the desired price and making a left mouse click. The demo code below shows how you can lock in prices this way. To Chart-Trade additional code must be added to make the click perform one task of many, and only do so when required. When you Apply the code below to an indicator you will see a dashed line at the cursor price. This dashed line refreshes only once per second with a local database, however, it will speed up when your chart is refreshed more frequently when working with live data.

Suppose you want to place a LMT order at $60.00 on the chart below. To do this you move the dashed line over the $60.00 price and click the Left mouse button. This will place a stationary solid line. You can now move your cursor to another price and click again, the solid line will move to this new location. In actual trading you can follow the price in real time and adjust your Limit prices so that they stay exactly where you want them. The chart produced by this demo code looks like this:

placingline.png

In Chart-Trading the first click that places the solid line would also place your order on the TWS. Each subsequent click would modify the order to the new price. This way you can adjust several prices on your chart, setting and moving around Entries, Targets, Stops, etc.

RequestTimedRefresh);
SetChartOptions2chartHideQuoteMarker );
LButtonDown GetCursorMouseButtons() == 9;
MousePrice GetCursorYPosition();

if ( MousePrice )
{
    StaticVarSet"MousePrice"MousePrice );
    if ( LButtonDown )
        StaticVarSet"ClickedMousePrice"MousePrice );
}

LB BarCount 1;
MousePrice NzStaticVarGet"Mouseprice" ), Null );
ClickedMousePrice StaticVarGet"ClickedMousePrice" );

PlotC""1128 );
PlotMousePrice""colorWhitestyleNoRescale styleDashed styleNoLabel00);
PlotText"CURSOR " NumToStrMousePrice[LB], 1.2 ), LB 5MousePrice[LB], colorBlackcolorWhite );
PlotClickedMousePrice""colorBlackstyleNoLabel styleNoRescale00);
PlotText"ORDER PLACED $" NumToStrClickedMousePrice[LB], 1.2 ), LB 5ClickedMousePrice[LB], colorBlackcolorWhite );

Comments are closed.