DAS Trader Pro Advanced Hotkeys part 61
Take an action when the trade is in X profit
This has been asked over and over again from You in different ways and shapes.
Enter a trade, take partial at 1R and set my stop loss to break-even.
Move my stop to break even once my trade is at 1R in profit.
Take a partial at 2R then set my stop to 1R
Take a partial at 1R then trail my stop from break-even
Let me take the example of the first one.

Enter a trade, take partial at 1R and set my stop loss to break-even.
To enter a trade not much changes are needed to Your existing entry (with attached OCO order) hotkeys. What is needed is to keep the track of the stop and the calculated target as well as the division of the partials.
Entry hotkey
An universal entry hotkey for both long and short (based on where You click for the stop) can look like this
// name your MONTAGE window MONTAGE1
$MONTAGE=getwindowobj("MONTAGE1");
// set your desired route for entry
$ROUTE="LIMIT";
// set your desired constant risk
$RISK=20;
$MONTAGE.CXL ALLSYMB;
$MYSTOP=$MONTAGE.Price;
// go LONG
if($MYTOP<$MONTAGE.LAST)
{
$buyprice=$MONTAGE.Ask;
$mystop=$MONTAGE.price;
$pricetostop=$buyprice-$mystop;
$amount=$risk/$pricetostop;
// set the target to 2R
$target=2*$pricetostop+$MONTAGE.Ask;
// place the order
$MONTAGE.share=$amount;
$MONTAGE.ROUTE=$ROUTE;
$MONTAGE.Price=Round($buyprice*1.003,2);
$MONTAGE.TIF="DAY+";
// calculate the partial price
$1RPARTIAL=$buyprice+$pricetostop;
// calculate the target price and save it with the symbol
setvar ("target_"+$montage.symb,$target);
// round to 4 decimals if price below $1
if($MONTAGE.LAST<1)
{
$MONTAGE.Price=ROUND($MONTAGE.Ask*1.003,4);
}
// send the order
$MONTAGE.BUY;
// set the range order for stop and full target
$MONTAGE.TriggerOrder=RT:STOP STOPTYPE:RANGEMKT LowPrice:$mystop HighPrice:$target ACT:SELL QTY:POS TIF:DAY+;
}
else
// go SHORT
{
$sellprice=$MONTAGE.bid;
$mystop=$MONTAGE.price;
$pricetostop=$mystop-$sellprice;
// set the target to 2R
$target=$MONTAGE.Bid-$pricetostop-$pricetostop;
$amount=$risk/$pricetostop;
$MONTAGE.share=$amount;
$MONTAGE.Price=Round($sellprice*0.997,2);
$MONTAGE.TIF="DAY+";
// calculate the partial price
$1RPARTIAL=$sellprice-$pricetostop;
// calculate the target price and save it with the symbol
setvar ("target_"+$montage.symb,$target);
// round to 4 decimals if price below $1
if($MONTAGE.LAST<1)
{
$MONTAGE.Price=ROUND($MONTAGE.Ask*1.003,4);
}
// send the order
$MONTAGE.Sell;
// set the range order for stop and full target
$MONTAGE.TriggerOrder=RT:STOP STOPTYPE:RANGEMKT LowPrice:$target HighPrice:$mystop ACT:BUY QTY:POS TIF:DAY+;
}what we would need to add is the position monitoring on what to do when the desired 1R profit is reached. We need to wait for the fill for the original entry order then we call for the hotkey that will place the alert with the desired parameters for us
// Wait for the fill
wait (2000);
// place the partial alert
$montage.exechotkey("Alert_Partial");Just add this code to the above entry hotkey and you are good to go. It can be a hotkey or a hot button or a window button.
The alert creation hotkey is saved as a hotkey named ALERT_PARTIAL in this case and It is a re-use of the previously used clicked alert.
$CLICKEDSTOP=$1Rpartial;
$MYSYMB=$montage.symb;
$MYPOS=GetAccountObj($MONTAGE.account).getposition($MONTAGE.symb).share;
if($MYPOS==0)
{return;}
else
{
$TODELALERT=GetAlertObj("1R Partial "+$MONTAGE.SYMB);
if (IsObj($TODELALERT))
{
$TODELALERT.delete();
}
$MYALERT=NewAlertObj();
$MYALERT.name="1R Partial "+$MONTAGE.SYMB;
if($MYPOS<0)
{
$MYALERT.AddItem("Last Sale","<",$CLICKEDSTOP);
}
if($MYPOS>0)
{
$MYALERT.AddItem("Last Sale",">",$CLICKEDSTOP);
}
// call the partial hotkey
$MYALERT.Script="$montage.symbol="+$MYSYMB+";$montage.exechotkey\(\"Partial_1R\"\);";
$MYALERT.Speak=0;
$MYALERT.SYMB=$MYSYMB;
$MYALERT.PlaySound=0;
$MYALERT.Autodelete=1;
$MYALERT.Loop=0;
$MYALERT.PopupWindow=0;
$MYALERT.save();
}Which will create us an alert like this
The script above took the $1RPartial variable saved from the entry hotkey and placed an alert to that price. Automatically deciding if it is a long or short placing the condition to be greater than or lower than the calculated 1R distance price.
As You can see there is a script that will be called when the alert gets triggered
For an example trade like this
At the price of 210.56 it will call the Patial_1R hotkey and delete the alert object ($MYALERT.Autodelete=1;)
Now the stop loss price is set to the average cost of 211.42 and the target is still kept.
The magic happens in the action hotkey Partial_1R which I wrote as universal for both short and long for simplicity
Keep reading with a 7-day free trial
Subscribe to Peter’s Substack to keep reading this post and get 7 days of free access to the full post archives.





