Don’t Trade That Stock! Build a Block List in DAS Trader Pro
The script(s) featured in this episode are provided below for educational and reference purposes. Trading stocks, options, futures, and other financial instruments involves substantial risk of loss and is not suitable for all investors. You may lose some or all of your invested capital. Always review and thoroughly test any code in a simulator before using it in a live trading environment.
This video is provided by YouTube. It is blocked until you accept functional cookies.
Important!
Some of these scripts may also rely on scripts created in previous episodes.
Any
updates to scripts will be shown below, but any scripts left unchanged would
need to
be sourced from the episode they were featured in. It is recommended to watch
all
videos in this series in order, that way you can piece together a working system
with a good understanding of all the connected parts.
OBJECT_INIT_TRADE
This script is from a previous episode. Changes have been marked in the file so you can follow what was adjusted in this episode.
//OBJECT_INIT_TRADE
if (GetVar("$TRADE")==0) $TRADE=0;
if (!IsObj($TRADE)) $TRADE = newUserObj();
$TRADE.DAILYEMA200 = 0;
$TRADE.DAILYEMA200_LAST = 0;
$TRADE.DAILYSMA200 = 0;
$TRADE.DAILYSMA200_LAST = 0;
$TRADE.TIME_ON_TICKER = 0;
$TRADE.CHART_LAST_SYMB = "";
$TRADE.LAST_PL = 1234;
$TRADE.LAST_SHARES = 0;
$TRADE.LAST_GAIN_LOSS = 0;
$TRADE.LAST_AVERAGE = 0;
$TRADE.LAST_PER_SHARE = 0;
$TRADE.BUY_AT_TARGET = 0;
$TRADE.BUY_SPREAD = 0.10;
$TRADE.ALLOW_AVERAGE_DOWN = 0;
$TRADE.MAX_LOSS_PER_TICKER = -50;
$TRADE.TIMER_RUNNNING = 1;
$TRADE.TRAILING_PROFIT_PRICE = 0;
$TRADE.TRAILING_PROFIT_SPREAD = 0.10;
$TRADE.TRAILING_AUTO_AMOUNT = 0.10;
$TRADE.TRAILING_AUTO_ON_OFF = 0;
$TRADE.ALLOWED_SPREAD = 0.20;
$TRADE.OVERRIDE_REPLAY = 0;//BUG
$TRADE.OVERRIDE_REGHOURS = 0;//BUG
$TRADE.PILLARS_PRICE_MIN = 2;
$TRADE.PILLARS_PRICE_MAX = 20;
$TRADE.PILLARS_RVOL_MIN = 5;
$TRADE.PILLARS_UP_DAILY_PERCENT_MIN = 30;
$TRADE.PILLARS_FLOAT_MAX = 5000000;
$TRADE.RATING_VALUE = 0;
$TRADE.RATING_TEXT_DESC = "F";
//---SUB OBJECT - CALCS
$TRADE.CALCS = newUserObj();
$TRADE.CALCS.TOTAL15MIN = 0;
$TRADE.CALCS.TOTAL30 = 0;
$TRADE.CALCS.TOTAL50 = 0;
$TRADE.CALCS.TOTAL50_AVG = 0;
$TRADE.CALCS.BAR_60_BARNUM = 0;
$TRADE.CALCS.TOTAL60 = 0;
$TRADE.CALCS.BAR_60_THIS_DATE = "";
$TRADE.CALCS.TOTAL60MIN = 0;
$TRADE.CALCS.VOLUME_FETCH = 0;
$TRADE.CALCS.BAR_60_EXIT = 0;
$TRADE.CALCS.BAR_60_DAILYBAR = 0;
$TRADE.CALCS.BAR_60_START_DATE = "";
$TRADE.CALCS.TOTAL90 = 0;
$TRADE.CALCS.RVOLBAR = -91;
$TRADE.CALCS.MINUTES_BARNUM = -61;
$TRADE.BLOCK_THIS_STOCK = 0;//+ ADDED THIS LINE
ExecHotkey("OBJECT_INIT_TRACKING");
ExecHotkey("OBJECT_INIT_STOP");
BLOCKED_STOCK_ADD (NEW) (This script was introduced in this episode)
//BLOCKED_STOCK_ADD
LoadVarFromFile("C:\\dtc\\temp\\blocked_stocks.txt");
if (GetVar("$BLOCKED_STOCKS")==0) $BLOCKED_STOCKS="";
$TMP_BLOCKED_STOCKS_CHECK = $BLOCKED_STOCKS;
$TMP_BLOCKED_STOCKS = "";
while (strlen($TMP_BLOCKED_STOCKS_CHECK) > 2){
$this_comma = StrFind($TMP_BLOCKED_STOCKS_CHECK, ",");
if ($this_comma > 0){
$this_item = SubString($TMP_BLOCKED_STOCKS_CHECK, 0, $this_comma);
$TMP_BLOCKED_STOCKS_CHECK = SubString($TMP_BLOCKED_STOCKS_CHECK, $this_comma + 1, strlen($TMP_BLOCKED_STOCKS_CHECK));
} else {
$this_item = $TMP_BLOCKED_STOCKS_CHECK;
$TMP_BLOCKED_STOCKS_CHECK = "";
}
if ($this_item != $montage_window.SYMBOL){
if ($TMP_BLOCKED_STOCKS == ""){
$TMP_BLOCKED_STOCKS = $this_item;
} else {
$TMP_BLOCKED_STOCKS = $TMP_BLOCKED_STOCKS + "," + $this_item;
}
}
}
$BLOCKED_STOCKS = $TMP_BLOCKED_STOCKS;
if ($BLOCKED_STOCKS == ""){
$BLOCKED_STOCKS = $montage_window.SYMBOL;
} else {
$BLOCKED_STOCKS = $BLOCKED_STOCKS + "," + $montage_window.SYMBOL;
}
$MISC.SPEAK_TEXT = $MISC.SPEAK_TEXT + ", BLOCKED " + $montage_window.SYMBOL;//+ ADDED THIS LINE
MsgLog("ADD:" + $montage_window.SYMBOL);
$VARIABLE_NAME = "BLOCKED_STOCKS";
$FILE_NAME = "blocked_stocks";
//+ UPDATED THE FOLLOWING TO BE ON 1 LINE
ShellExec("powershell.exe", "-ExecutionPolicy Bypass -File C:\\dtc\\das_save_setting.ps1 \"" + $BLOCKED_STOCKS + "\" \"" + $VARIABLE_NAME + "\" \"" + $FILE_NAME + "\"", "C:\\dtc\\temp\\");
$TRADE.BLOCK_THIS_STOCK = 1;
BLOCKED_STOCK_REMOVE (NEW) (This script was introduced in this episode)
//BLOCKED_STOCK_REMOVE
LoadVarFromFile("C:\\dtc\\temp\\blocked_stocks.txt");
if (GetVar("$BLOCKED_STOCKS")==0) $BLOCKED_STOCKS="";
$TMP_BLOCKED_STOCKS_CHECK = $BLOCKED_STOCKS;
$TMP_BLOCKED_STOCKS = "";
while (strlen($TMP_BLOCKED_STOCKS_CHECK) > 2){
$this_comma = StrFind($TMP_BLOCKED_STOCKS_CHECK, ",");
if ($this_comma > 0){
$this_item = SubString($TMP_BLOCKED_STOCKS_CHECK, 0, $this_comma);
$TMP_BLOCKED_STOCKS_CHECK = SubString($TMP_BLOCKED_STOCKS_CHECK, $this_comma + 1, strlen($TMP_BLOCKED_STOCKS_CHECK));
} else {
$this_item = $TMP_BLOCKED_STOCKS_CHECK;
$TMP_BLOCKED_STOCKS_CHECK = "";
}
if ($this_item != $montage_window.SYMBOL){
if ($TMP_BLOCKED_STOCKS == ""){
$TMP_BLOCKED_STOCKS = $this_item;
} else {
$TMP_BLOCKED_STOCKS = $TMP_BLOCKED_STOCKS + "," + $this_item;
}
}
}
$TRADE.BLOCK_THIS_STOCK = 0;
$BLOCKED_STOCKS = $TMP_BLOCKED_STOCKS;
$MISC.SPEAK_TEXT = $MISC.SPEAK_TEXT + ", BLOCK " + $montage_window.SYMBOL + " REMOVED";//+ ADDED THIS LINE
MsgLog("REMOVED:" + $montage_window.SYMBOL );//+ UPDATED THIS LINE
$VARIABLE_NAME = "BLOCKED_STOCKS";
$FILE_NAME = "blocked_stocks";
//+ UPDATED THE FOLLOWING TO BE ON 1 LINE
ShellExec("powershell.exe", "-ExecutionPolicy Bypass -File C:\\dtc\\das_save_setting.ps1 \"" + $BLOCKED_STOCKS + "\" \"" + $VARIABLE_NAME + "\" \"" + $FILE_NAME + "\"", "C:\\dtc\\temp\\");
BLOCKED_STOCK_CHECK (NEW) (This script was introduced in this episode)
//BLOCKED_STOCK_CHECK
LoadVarFromFile("C:\\dtc\\temp\\blocked_stocks.txt");
if (GetVar("$BLOCKED_STOCKS")==0) $BLOCKED_STOCKS="";
$TMP_BLOCKED_STOCKS_CHECK = $BLOCKED_STOCKS;
$TRADE.BLOCK_THIS_STOCK = 0;
while (strlen($TMP_BLOCKED_STOCKS_CHECK) > 2){
$this_comma = StrFind($TMP_BLOCKED_STOCKS_CHECK, ",");
if ($this_comma > 0){
$this_item = SubString($TMP_BLOCKED_STOCKS_CHECK, 0, $this_comma);
$TMP_BLOCKED_STOCKS_CHECK = SubString($TMP_BLOCKED_STOCKS_CHECK, $this_comma + 1, strlen($TMP_BLOCKED_STOCKS_CHECK));
} else {
$this_item = $TMP_BLOCKED_STOCKS_CHECK;
$TMP_BLOCKED_STOCKS_CHECK = "";
}
if ($this_item == $montage_window.SYMBOL){
$TRADE.BLOCK_THIS_STOCK = 1;
}
}
MsgLog("CHECK:" + $BLOCKED_STOCKS + ":" + $TRADE.BLOCK_THIS_STOCK);
BUTTON_BLOCK_ON_OFF (NEW) (This script was introduced in this episode)
//BUTTON_BLOCK_ON_OFF
if ($TRADE.BLOCK_THIS_STOCK == 1){
ExecHotkey("BLOCKED_STOCK_REMOVE");
} else {
ExecHotkey("BLOCKED_STOCK_ADD");
}
BUY_BY_RULES
This script is from a previous episode. Changes have been marked in the file so you can follow what was adjusted in this episode.
//BUY_BY_RULES
$TRADE.OK_TO_BUY_THIS = 1;
$TRADE.STICK_TO_PLAN_TEXT = "";
//3 losses check
$tmp_var_name = "$loss" + $chart_1m.SYMBOL;
if (GetVar($tmp_var_name)==0) SetVar($tmp_var_name, 0);
$this_symbol_loss = GetVar($tmp_var_name);
if ($this_symbol_loss >= 3){
$TRADE.OK_TO_BUY_THIS = 0;
$TRADE.STICK_TO_PLAN_TEXT = $TRADE.STICK_TO_PLAN_TEXT + "," + $chart_1m.SYMBOL + " Losses 3";
}
//dont average down
if ($TRADE.ALLOW_AVERAGE_DOWN == 0){
if ($montage_window.POS > 0){
if ($montage_window.AVGCost > $montage_window.ASK){
$TRADE.OK_TO_BUY_THIS = 0;
$TRADE.STICK_TO_PLAN_TEXT = $TRADE.STICK_TO_PLAN_TEXT + "," + " No Average Down";
}
}
}
//limit number of trades
if ($TRADE.TRACKING.TRADES_TODAY >= 14){
$TRADE.OK_TO_BUY_THIS = 0;
$TRADE.STICK_TO_PLAN_TEXT = $TRADE.STICK_TO_PLAN_TEXT + "," + " Max Trades For Today";
}
//limit failed ticker max loss
if ($TRADE.MAX_LOSS_PER_TICKER >= GetAccountObj($ACCOUNT_NUMBER).GetPosition($chart_1m.SYMBOL).Realized){
$TRADE.OK_TO_BUY_THIS = 0;
$TRADE.STICK_TO_PLAN_TEXT = $TRADE.STICK_TO_PLAN_TEXT + "," + " Ticker " + $chart_1m.SYMBOL + " Max Loss " + GetAccountObj($ACCOUNT_NUMBER).GetPosition($chart_1m.SYMBOL).Realized + " / " + $TRADE.MAX_LOSS_PER_TICKER;
}
if ($TRADE.ALLOWED_SPREAD < ($montage_window.ASK - $montage_window.BID)){
$TRADE.OK_TO_BUY_THIS = 0;
$TRADE.STICK_TO_PLAN_TEXT = $TRADE.STICK_TO_PLAN_TEXT + ", SPREAD RISK";
}
//+ ADDED THE FOLLOWING 5 LINES
//BLOCK STOCK FROM BEING TRADED
if ($TRADE.BLOCK_THIS_STOCK == 1){
$TRADE.OK_TO_BUY_THIS = 0;
$TRADE.STICK_TO_PLAN_TEXT = $TRADE.STICK_TO_PLAN_TEXT + ", STOCK BLOCKED";
}
if ($TRADE.OK_TO_BUY_THIS == 1){
//your buy script here
ExecHotkey("BUY_ASK");
} else {
Speak($TRADE.STICK_TO_PLAN_TEXT);
}
if ($TRADE.STICK_TO_PLAN_TEXT != ""){
MsgLog($TRADE.STICK_TO_PLAN_TEXT);
}
CHART_UPDATE
This script is from a previous episode. Changes have been marked in the file so you can follow what was adjusted in this episode.
//CHART_UPDATE (runs every time chart object updates data)
if ($TRADE.CHART_LAST_SYMB != $chart_1m.SYMBOL){
$TRADE.CHART_LAST_SYMB = $chart_1m.SYMBOL;
$TRADE.TIME_ON_TICKER = 0;
$TRADE.DAILYSMA200 = 0;
$TRADE.DAILYEMA200 = 0;
MsgLog("Changed Ticker: " + $chart_1m.SYMBOL);
ExecHotkey("DETECT_STOCK_COUNTRY");
$TRADE.BUY_AT_TARGET = 0;
$TRADE.TRAILING_AUTO_ON_OFF = 0;
ExecHotkey("OBJECT_INIT_STOP");
ExecHotkey("OBJECT_LOAD_TICKER");
ExecHotkey("STOCK_RESET");
ExecHotkey("BLOCKED_STOCK_CHECK");//+ ADDED THIS LINE
}
$TRADE.TIME_ON_TICKER = $TRADE.TIME_ON_TICKER + 1;
TIMER_PL_UPDATE
This script is from a previous episode. Changes have been marked in the file so you can follow what was adjusted in this episode.
//TIMER_PL_UPDATE
$ACCOUNT=GetAccountObj($ACCOUNT_NUMBER);
ExecHotkey("CHART_TIMER_DRAW_STOP");
ExecHotkey("TRACK_TRADES_ACTIVE");
if ($TRADE.STOP.TRIGGER > 0 && $montage_window.POS > 0){
//wait 2 seconds to trigger stop
if ($TRADE.STOP.TRIGGER > 2){
ExecHotkey("SELL_STOP");
}
$TRADE.STOP.TRIGGER = $TRADE.STOP.TRIGGER + 1;
}
//calculate profit or loss on last trade
if ($ACCOUNT.Realized != $TRADE.LAST_PL && $TRADE.LAST_PL != 1234){
$TRADE.LAST_GAIN_LOSS = $ACCOUNT.Realized - $TRADE.LAST_PL;
$TRADE.LAST_PER_SHARE = 0;
if ($TRADE.LAST_SHARES > 0){
$TRADE.LAST_PER_SHARE = Round(($TRADE.LAST_GAIN_LOSS / $TRADE.LAST_SHARES), 2);
MsgLog("Per Share: " + $TRADE.LAST_PER_SHARE);
}
if ($ACCOUNT.Realized < $TRADE.LAST_PL){
//LOSS
$tmp_var_name = "$loss" + $chart_1m.SYMBOL;
if (GetVar($tmp_var_name)==0) SetVar($tmp_var_name, 0);
$this_symbol_loss = GetVar($tmp_var_name);
$this_symbol_loss = $this_symbol_loss + 1;
SetVar($tmp_var_name, $this_symbol_loss);
if ($this_symbol_loss > 2){
Speak($this_symbol_loss + " Losses " + $chart_1m.SYMBOL);
}
} else {
//GAIN
}
ExecHotkey("TRACK_TRADES_LAST");
}
//Update PL
$TRADE.LAST_PL = $ACCOUNT.Realized;
if (IsObj($montage_window)){
$TRADE.LAST_AVERAGE = $montage_window.AVGCost;
$TRADE.LAST_SHARES = $montage_window.POS;
}
//detect current stock losses and block if 3
$tmp_var_name = "$loss" + $chart_1m.SYMBOL;
if (GetVar($tmp_var_name)==0) SetVar($tmp_var_name, 0);
$this_symbol_loss = GetVar($tmp_var_name);
if (IsObj($DASHBOARD.getCustButObj("STOCK_BLOCKED"))){
if ($this_symbol_loss > 2 || $TRADE.BLOCK_THIS_STOCK == 1){//+ UPDATED THIS LINE
$DASHBOARD.getCustButObj("STOCK_BLOCKED").Text = "BLOCKED";
$DASHBOARD.getCustButObj("STOCK_BLOCKED").BkColor = Color("Red");
} else {
$DASHBOARD.getCustButObj("STOCK_BLOCKED").Text = "";
$DASHBOARD.getCustButObj("STOCK_BLOCKED").BkColor = Color("Gray");
}
}
C:\dtc\das_save_setting.ps1 (NEW) (This script was introduced in this episode)
THIS IS NOT A DAS SCRIPT - IT IS A WINDOWS POWERSHELL SCRIPT.
param(
[string]$string,
[string]$variableName,
[string]$fileName
)
$file = "C:\dtc\temp\$fileName.txt"
try {
$content = '$' + $variableName + '="' + $string + '";'
Set-Content -Path $file -Value $content -Encoding ASCII
}
catch {
# silent fail
}
Disclaimer:
This is an independent project and is not affiliated with or endorsed by DASTrader.com.
The tool is currently under development and intended for educational and experimental purposes only,
including improving the experience of working with DAS hotkey scripting (e.g., code validation,
highlighting, and structure).
It does not execute trades, provide trading signals, or offer financial advice. Any scripts created or used
with DAS Trader remain the sole responsibility of the user.
Trading involves significant risk. You are fully responsible for verifying all scripts, commands, and
behavior before using them in a live trading environment.
This tool is provided “as-is” with no guarantees of accuracy, completeness, or reliability. Use at your own
risk. Always test thoroughly in a simulator before live trading.