If you happen to have multiple accounts in your DAS and want to utilize them for the same trade, there is a way to do so, with a bit of scripting. Let’s take a look at it.

For easier calculations and visibility, our example accounts have equity of
- $40000
- $50000
- $65000
Use case 1 – the constant risk split across accounts
// multi account entry with static total risk across accounts
$numberofaccounts=3;
$acc1=”TRPETERB”;
$acc2=”TRPETERB2″;
$acc3=”TRPETERB3″;
$acc4=”TRPETERB4″;
// total risk of all positions combined across the accounts
$totalrisk=50;
// account percentages split make sure the total makes 100
$acc1perc=10;
$acc2perc=55;
$acc3perc=35;
// calculations of risk per account
$riskacc1=$totalrisk*$acc1perc/100;
$riskacc2=$totalrisk*$acc2perc/100;
$riskacc3=$totalrisk*$acc3perc/100;
$riskacc4=$totalrisk*$acc4perc/100;
// cancel all previous orders and set the stop loss from the montage (doubleckick on chart)
$Montage.CXL ALLSYMB;
$mystop=$Montage.Price;
// save the stop loss for later
setvar(“STOP_”+$montage.symbol,$mystop);
// Rounding of stop
if($mystop<1)
{
$mystop=Round($mystop,4);
}
else
{
$mystop=Round($mystop,2);
}
// Determine long or short
if($mystop<$Montage.LAST)
{
$EntryPrice=Round($Montage.Ask,2);
$Offset=$mystop*0.98;
}
else
{
$EntryPrice=Round($Montage.Bid,2);
$Offset=$mystop*1.02;
}
// Rounding of Offset Price
if($Offset<1)
{
$Offset=Round($Offset,4);
}
else
{
$Offset=Round($Offset,2);
}
// Rounding of entry Price
if($EntryPrice<1)
{
$EntryPrice=Round($EntryPrice,4);
}
else
{
$EntryPrice=Round($EntryPrice,2);
}
// Calculate shares and fill in the montage with order data
$Pricetostop=ABS($EntryPrice-$mystop);
// start loop through accounts
$loop=1;
while ($loop<=$numberofaccounts)
{
$Amount=getvar(“RISKACC”+$loop)/$Pricetostop;
$Montage.account=getvar(“ACC”+$loop);
$Montage.share=$Amount;
$Montage.ROUTE=”LIMIT”;
$Montage.TIF=”DAY+”;
$Montage.Price=$EntryPrice;
// Use LimitP stop in 4:00 AM – 9:30 AM and 4:00 PM-8:00 PM
$STOPTYPE=”LimitP”;
if(getsecond()>34200)
{
if(getsecond()<57600)
{
// Standard stop type during normal hours. Change as route necessary
$STOPTYPE=”MARKET”;
}
}
// Finally, place the order
if($mystop<$Montage.LAST)
{
$Montage.Buy;
}
else
{
$Montage.Sell;
}
$loop=$loop+1;
// end of loop 1
}
// wait for the fill of orders before placing stop loss orders 1000 means 1 second 2000 is 2 seconds…
wait(1000);
// stop loss loop
$loop=1;
while ($loop<=$numberofaccounts)
{
$MONTAGE.ROUTE=”STOP”;
$MONTAGE.ACCOUNT=getvar(“ACC”+$loop);
$MONTAGE.STOPTYPE=$STOPTYPE;
$MONTAGE.StopPrice=$mystop;
$MONTAGE.Price=$Offset;
$MONTAGE.Share=$montage.POS;
$MONTAGE.TIF=”DAY+”;
$MONTAGE.SEND=REVERSE;
$loop=$loop+1;
}
Use case 2 – the constant % of account equity or constant risk for each individual account
This is practical if the risk is desired to be based on the account size or certain static risk per account. For this use case just the top of the script needs to be adapted.
For this use case we want to risk 0.1 % of account equity of each account.
$40 for account 1
$50 for account 2
$65 for account 3
// multi account entry with static total risk across accounts
$numberofaccounts=3;
$acc1=”TRPETERB”;
$acc2=”TRPETERB2″;
$acc3=”TRPETERB3″;
$acc4=”TRPETERB4″;
// account percentages split make sure the total makes 100
$acc1perc=0.1;
$acc2perc=0.1;
$acc3perc=0.1;
$acc4perc=0.1;
// calculations of risk per account equity
$loop=1;
while($loop<=$numberofaccounts)
{
setvar(“RISKACC”+$loop,GetAccountObj(getvar(“ACC”+$loop)).EQUITY*getvar(“ACC”+$loop+”PERC”)/100);
$loop=$loop+1;
}
// cancel all previous orders and set the stop loss from the montage (doubleckick on chart)
$Montage.CXL ALLSYMB;
$mystop=$Montage.Price;
// save the stop loss for later
setvar(“STOP_”+$montage.symbol,$mystop);
// Rounding of stop
if($mystop<1)
{
$mystop=Round($mystop,4);
}
else
{
$mystop=Round($mystop,2);
}
// Determine long or short
if($mystop<$Montage.LAST)
{
$EntryPrice=Round($Montage.Ask,2);
$Offset=$mystop*0.98;
}
else
{
$EntryPrice=Round($Montage.Bid,2);
$Offset=$mystop*1.02;
}
// Rounding of Offset Price
if($Offset<1)
{
$Offset=Round($Offset,4);
}
else
{
$Offset=Round($Offset,2);
}
// Rounding of entry Price
if($EntryPrice<1)
{
$EntryPrice=Round($EntryPrice,4);
}
else
{
$EntryPrice=Round($EntryPrice,2);
}
// Calculate shares and fill in the montage with order data
$Pricetostop=ABS($EntryPrice-$mystop);
// start loop through accounts
$loop=1;
while ($loop<=$numberofaccounts)
{
$Amount=getvar(“RISKACC”+$loop)/$Pricetostop;
$Montage.account=getvar(“ACC”+$loop);
$Montage.share=$Amount;
$Montage.ROUTE=”LIMIT”;
$Montage.TIF=”DAY+”;
$Montage.Price=$EntryPrice;
// Use LimitP stop in 4:00 AM – 9:30 AM and 4:00 PM-8:00 PM
$STOPTYPE=”LimitP”;
if(getsecond()>34200)
{
if(getsecond()<57600)
{
// Standard stop type during normal hours. Change as route necessary
$STOPTYPE=”MARKET”;
}
}
// Finally, place the order
if($mystop<$Montage.LAST)
{
$Montage.Buy;
}
else
{
$Montage.Sell;
}
$loop=$loop+1;
// end of loop 1
}
// wait for the fill of orders before placing stop loss orders 1000 means 1 second 2000 is 2 seconds…
wait(1000);
// stop loss loop
$loop=1;
while ($loop<=$numberofaccounts)
{
$MONTAGE.ROUTE=”STOP”;
$MONTAGE.ACCOUNT=getvar(“ACC”+$loop);
$MONTAGE.STOPTYPE=$STOPTYPE;
$MONTAGE.StopPrice=$mystop;
$MONTAGE.Price=$Offset;
$MONTAGE.Share=$montage.POS;
$MONTAGE.TIF=”DAY+”;
$MONTAGE.SEND=REVERSE;
$loop=$loop+1;
}
Multi-account exit hotkey
Once we start trading multiple accounts at once, it is crucial to be able to exit manually quickly. That we can achieve by using a hotkey like this
We set the number of accounts and the account names at the top of the script, watching for typos.
$montage=getwindowobj("Montage1");
$numberofaccounts=3;
$acc1="TRPETERB";
$acc2="TRPETERB2";
$acc3="TRPETERB3";
$loop=1;
while($loop<=$numberofaccounts)
{
$montage.account=getvar("ACC"+$loop);
$MYPOS=GetAccountObj($montage.account).getposition($MONTAGE.Symbol).share;
if ($MYPOS==0)
{
MsgLog("No position to close");
}
else
{
$MONTAGE.CXL ALLSYMB;
if ($MYPOS>0)
{
$Montage.price=$montage.last*0.98;
}
else
{
$Montage.price=$montage.last*1.02;
}
if ($MONTAGE.price>=1)
{
$MONTAGE.Price=Round($Montage.price,2);
}
else
{
$MONTAGE.Price=Round($Montage.price,4);
}
//set your exit route
$MONTAGE.ROUTE="LIMIT";
$MONTAGE.Share=$MONTAGE.POS;
$MONTAGE.Send=Reverse;
}
$loop=$loop+1;
}
VIDEO
After the exit each of the accounts has distributed profit in the same



