FennEdge Learn · Programming

DAS Trader Advanced Hotkey Script Course

Understand the code. Inspect the state. Verify the outcome. A detailed path through Advanced Script: language, data structures, order objects, event workflows and complete practice projects.

Plan about 1046 minutes including reading, worked examples, and each lesson exercise; actual time varies.

36Lessons≈1046Est. minutes—Sign in to save progress
24
Lesson 24 of 36 · About 26 min

DAS Alerts and Trigger Scripts

Create a condition, save it, observe its callback and clean up the practice alert.

An Alert is a condition object

MsgBox(...) displays a message when execution reaches that statement. An Alert stores conditions and triggers configured notifications or a script when they are met. Timer Event runs periodically; Chart Update Script runs with chart updates. Their entry conditions, lifetimes and contexts differ.

First create a practice Alert with a price condition. Then configure a message-only callback separately. Complete the preceding script-reuse lesson so that storing code and executing it are distinct concepts.

Create and save a price Alert

Advanced Script · Creates and saves Alert configuration. Use a separate practice desktop with MSFT quotes loaded. Inspect Alert defaults first and ensure no order or external action is attached. The fictional threshold of 50 may already be satisfied; it is a syntax example, not a suggested market level.

$feAlertLevel = 50;
$fePracticeAlert = NewAlertObj();
$fePracticeAlert.name = "FE_Practice_Bid";
$fePracticeAlert.Symb = "MSFT";
$fePracticeAlert.AddItem("L1 BID", ">", $feAlertLevel);
$fePracticeAlert.Save();
Code Effect Inspect in the UI
NewAlertObj() Creates a new object This is not an existing-alert lookup
.name Labels the alert Distinguishable practice name
.Symb Sets the condition's symbol Expected quote symbol
.AddItem(...) Adds field, operator and threshold L1 BID, strictly greater than, 50
.Save() Saves configuration Correct condition appears in the Alert list

"L1 BID" is an Alert field identifier. ">" is a string argument, not a comparison evaluated by the outer script. Equality does not satisfy this strictly-greater-than condition.

Passing a numeric variable to AddItem does not establish a live link to future changes in that variable. To monitor a global variable, configure a variable condition through the documented Alerts & Triggers UI and verify updates and triggering separately.

Add the code that runs when triggered

Find this practice alert's Script field in Alerts & Triggers settings and enter the following body. Advanced Script · Displays a message on triggering. This is a separate callback body, not an extra line appended to the creation script.

MsgBox("FE practice alert triggered");

Placing that message immediately after .Save() only proves the creation script reached the line. It does not prove a condition triggered. Observe configuration creation, condition satisfaction and callback execution separately.

After completing the reuse lesson, you can instead call the inspected FE_PracticeMessage helper from the callback. Alert scripts can have the same effects as hotkey scripts. When a callback needs window data, reacquire the named window rather than relying on whichever window has focus when the alert fires.

Modify, disable and clean up

Check for FE_Practice_Bid before creation. Repeating NewAlertObj() does not mean updating by name. Same-name behavior needs build-specific verification; a label is not a deduplication guarantee.

On p. 34 the guide demonstrates removing an alert from the list with Reset() followed by Save(). Advanced Script · Cleans up this practice Alert. Run separately only while $fePracticeAlert still points to the object just created and has not been overwritten. After a restart or lost reference, manage the alert through the UI.

$fePracticeAlert.Reset();
$fePracticeAlert.Save();

The guide's section heading mentions GetAlertObj(), but its body does not provide the lookup arguments or missing-result contract needed for a reliable example. This course therefore does not invent a GetAlertObj("name") call. Check current-build object help and Script Builder before depending on lookup or modification behavior.

Lab: record the trigger sequence

Choose an observable threshold in the practice environment. Record results below, equal to and above it. Compare remaining above it with leaving and returning. Record repeated notifications. Finally disable or clean up the practice alert and confirm it no longer triggers. Keep the symbol, threshold, quote time, build and repeat/auto-delete configuration with your observations.

Separate three meanings of trigger

An Alert Script callback, a Chart update callback and a Trigger Order relationship are different mechanisms: a notification entry point, a chart event and an order lifecycle relationship. Saving an Alert does not establish any order linkage.

Define condition, symbol identity, enable/disable procedure, repetition policy and cleanup for each alert. Do not assume consecutive AddItem calls imply AND. Alert composition computes an explicit condition state before connecting a notification entry point.

Worked answer and acceptance record

Record existing alerts before creation; check name and condition in the list afterward; count actual triggers; confirm removal after Reset/Save. Whether rerunning creation replaces or adds an alert needs observed list evidence, not an inference from an identical Name.

A once-on-entry notification needs previous state, not merely a current-condition test on every callback. See State machines for reset, hysteresis and disconnect handling.