DAS Script Chart Reference Lines and Annotations
Draw price and study snapshots, inspect pointer prices, and clean up deliberately.
Turn a price into a visible reference
The previous lesson read quotes, studies and bars. Now put a chosen value on a chart. A reference line records a price; it is neither a trading signal nor a working order or stop.
DrawHorzLineWithPrice(price, color) draws a horizontal line on a Chart. The first argument supplies the price and Color(...) supplies its color. Use a practice desktop, verify the symbol, interval and price scale, and run the hotkey with the intended Chart active. A global variable holding a price does not select a drawing target.
Draw a fixed-price line
Advanced Script · Changes chart drawings. Run on a dedicated practice Chart. The fictional 12.50 can be replaced with a value inside its visible price range. This example reads no market data and changes no order.
$feLinePrice = 12.50;
DrawHorzLineWithPrice($feLinePrice, Color(100, 100, 100));
The assignment only stores a global value; the second statement draws. The color uses RGB components. The guide also documents named colors such as Color("RED"). DAS chart colors are independent of this website's theme; check visibility against your own chart background.
Check the line against the price axis. If it is invisible, inspect the scale, window and contrast before repeating the command. Repeating it may add duplicate lines. This example neither finds an existing line nor updates it in place.
Draw a snapshot of a study value
Advanced Script · Reads a study and changes the active Chart. Name the Chart feChart and its VWAP study feVwap. Keep that same Chart active and ensure its study has loaded. The validation below does not handle missing windows or studies.
$feChart = GetWindowObj("feChart");
$feLinePrice = $feChart.GetStudyVal("feVwap");
if ($feLinePrice <= 0) {
MsgBox("Check the study value before drawing");
return;
}
DrawHorzLineWithPrice($feLinePrice, Color(100, 100, 100));
The receiver of GetStudyVal chooses the data source. The bare drawing call depends on the active Chart context. Those must identify the same chart; naming a variable $feChart does not redirect later commands automatically.
The line represents the value at execution time. As VWAP changes, do not present the old line as live VWAP. Before moving this into Chart Update Script or Timer Event, establish how to identify, update and clean up existing lines without repeated creation.
Read the price under the mouse
The documented GetMousePtPrice() reads the chart price at the pointer. Bind it to a hotkey and trigger while the pointer is over the chart. Clicking an editor's run control changes that input condition.
Advanced Script · Reads and displays the pointer price. Trigger on the Chart. Inspect the value before using it as a drawing input.
$feMousePrice = GetMousePtPrice();
MsgBox($feMousePrice);
The return behavior over a title bar, outside the plot or in another window has not been client-tested here. Do not treat an unknown result as a valid price or pass it directly into an order.
Clean up without losing existing annotations
The guide documents RemoveAllTrendLines; for clearing trend lines. All is broader than undoing the single line created by this lesson. Save the layout first and check effects on global lines and linked charts using a Chart containing only practice drawings.
Traditional Chart command · Removes drawings. Run separately on a practice chart you have confirmed can be cleared. Keep this out of the drawing hotkey.
RemoveAllTrendLines;
Lab: explain each line
Draw a fixed value, record a study snapshot, then inspect a pointer price. Record symbol, interval, value source, execution time and target Chart for each action. Change the interval and observe whether the old line stays at its price. Label it as a snapshot until automatic updating is verified. Clean up only the dedicated practice chart.
Own and clean up your drawings
Use a dedicated Chart and record each line's input price and purpose. Fixed, pointer and study-snapshot lines are drawings; they do not establish order linkage. If repeated execution adds multiple lines, stop the repeating entry point before cleanup instead of repeatedly clearing all trend lines from a Timer.
This course does not invent horizontal-line handles, update methods or deletion by name. A requirement to maintain only one owned line needs a confirmed client contract; deleting every line and redrawing is not equivalent because it affects other user drawings.
Worked answer and extension
If VWAP changes after drawing its current value but the line stays put, that is expected snapshot behavior. Trigger pointer-price reads inside the plotting area and compare with the axis. Record existing drawings before cleanup and inspect linked-chart/global-line scope.
Use Chart data lab to verify the source before choosing what to draw. Color can classify a reference, but cannot replace its price and time labels.