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 );

Introduction to Real-Time Chart-Trading

IMPORTANT NOTE: DO NOT USE ANY OF THE PROGRAMS PRESENTED HERE TO TRADE REAL MONEY. Most of the programs presented will only work with live data, execution reports, and market conditions. They will NOT work using the AmiBroker Bar Replay or the IB eDemo account.

Traditional Day-Trading by looking at TWS prices may still work for experienced traders who, probably over a period of many years, developed rapid interpretation skills. However, for less experienced traders graphical representations are much easier to interpret than spreadsheets or tables. Setting prices by clicking on your chart is much faster than entering prices in little windows. Trailing the price with your cursor is much faster than entering and modifying parameters in a GUI. All this is especially true when you are trading in real-time, where every second counts.

Posts in this category will introduce techniques that you can use to create your own custom designed Chart-Trading GUI. If you Google Chart-Trading you will find many examples of the many ways you can layout your personal interface. If you aim for maximum simplicity and automation you will end up with the most efficient GUI. Tentative topics that will be covered are:

1) Laying out buttons and controls (Param() Or Button())
2) House keeping functions (AutoTrading, CancelAll, CloseAll, etc.)
3) Automating setup for different trading methodologies (minimizing setup procedure)
4) Auto placement of orders
5) Auto Modification of Orders
6) Displaying order and system status
7) Performance reporting (Profits, Wins, etc.)