Menu

Protect Your Green Day! Stop After a 25% Giveback – 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.

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.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;
$TRADE.TODAY_VOLUME = 0;
$TRADE.TODAY_VOLUME_SHOW = 0;

$TRADE.PL_TODAY_MAX = 0;//+ ADDED THIS LINE
$TRADE.PL_TODAY_MAX_TRIGGER = 20;//+ ADDED THIS LINE
$TRADE.PL_TODAY_MAX_STOP_GIVE_BACK_PERCENT = 25;//+ ADDED THIS LINE


ExecHotkey("OBJECT_INIT_TRACKING");
ExecHotkey("OBJECT_INIT_STOP");

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

//+ ADDED THESE 4 LINES
//If just logging into DAS - make sure PL updated
if ($TRADE.PL_TODAY_MAX == 0 && $ACCOUNT.Realized > 0){
    $TRADE.PL_TODAY_MAX = $ACCOUNT.Realized;
}

//calculate profit or loss on last trade
if ($ACCOUNT.Realized != $TRADE.LAST_PL && $TRADE.LAST_PL != 1234){

    $TRADE.PL_TODAY_MAX = Max($TRADE.PL_TODAY_MAX, $ACCOUNT.Realized);//+ ADDED THIS LINE

	$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);
            }
        PlaySound("loss_error-126627.mp3", $MISC.SOUND_DEVICE, "SHARE STOP");
	} else {
		//GAIN
        PlaySound("sell_bid_cash-register-141427.mp3", $MISC.SOUND_DEVICE, "SHARE STOP");
	}

    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){
		$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");
	}
}

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

}

//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";
}

//+ ADDED THE FOLLOWING 5 LINES
if ($TRADE.PL_TODAY_MAX > 0){
    if ($TRADE.PL_TODAY_MAX >= $TRADE.PL_TODAY_MAX_TRIGGER){
        if (($TRADE.PL_TODAY_MAX * ((100 - $TRADE.PL_TODAY_MAX_STOP_GIVE_BACK_PERCENT) / 100)) > $ACCOUNT.Realized){
            $TRADE.OK_TO_BUY_THIS = 0;
            $TRADE.STICK_TO_PLAN_TEXT = $TRADE.STICK_TO_PLAN_TEXT + ", GAVE BACK " + $TRADE.PL_TODAY_MAX_STOP_GIVE_BACK_PERCENT + " PERCENT";
        }
    }
}

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




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.




More Videos

DISCLAIMER

Episode: Protect Your Green Day! Stop After a 25% Giveback – DAS Trader Pro

The DAS Trader Pro scripts, code examples, tools, and information provided on this website are offered solely for educational and informational purposes. Nothing on this website constitutes financial, investment, legal, tax, or trading advice.

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.

No representation or warranty is made regarding the accuracy, completeness, reliability, profitability, or suitability of any script, strategy, indicator, automation, workflow, or method presented on this website.

Execution behavior may vary based on broker, routing, market data, platform configuration, DAS Trader Pro version, account settings, market conditions, and other factors beyond the control of DayTradeCoder.

Past performance, examples, demonstrations, screenshots, or historical results are not indicative of future results and should not be relied upon as a guarantee of performance.

You are solely responsible for reviewing, understanding, testing, validating, and monitoring all code before use. All scripts should be thoroughly tested in a simulator or paper-trading environment prior to any live trading activity.

Viewing Scripts For Episode: Protect Your Green Day! Stop After a 25% Giveback – DAS Trader Pro

You are requesting access to the script associated with this video. This acknowledgment applies only to this script.

USE AT YOUR OWN RISK.

We value your privacy

We use cookies to enhance your browsing experience, serve personalized ads or content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies.

Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. Detailed information about cookies is available below.

Required for basic site functionality.