19. change all the charts time frame at the same time
This can be done in multiple ways. Your chart windows need to be named and numbered. Let’s say you have 20 chart windows named chart1-chart20. With this code below you can change the time frame with one click
$row=1;
while($row<21)
{
$Chart=GetWindowObj("chart"+$row);
$chart.minutechart 15;
$row=$row+1;
}
or you can load a saved preset on one click like this
$row=1;
while($row<21)
{
$Chart=GetWindowObj("chart"+$row);
$chart.loadsetting 15chart.cst;
$row=$row+1;
}
Where 15chart.cst is a chart preset saved in your DAS Trader Pro installation folder.
Here is a video showing how chart preset loading works with many charts, the timeframe can be a variable on a button so it can be very easy to switch between time frames.
20. show price alerts line on chart (same as Think or Swim)
It is pretty easy to draw any text or line to a chart. The challenge is to manage the lines afterward.
// draw the price box
$PNLTIME=GetWindowObj("MY1MIN").getbar(-11).time;
$PNLTIME1=GetWindowObj("MY1MIN").getbar(-10).time;
$ALERTPRICE=$montage.price;
$MYALERT=$my1minchart.CreateTrendline("Text");
$MYALERT.name="PRICEALERT"+$MYSYMB;
$MYALERT.text=$ALERTPRICE;
$MYALERT.time=$PNLTIME1;
$MYALERT.time1=$PNLTIME;
$MYALERT.price=$ALERTPRICE;
$MYALERT.price1=$ALERTPRICE;
$MYALERT.save();
// draw the line
GetWindowObj("MY1MIN").DrawHorzLineWithPrice($ALERTPRICE,color(190,254,152));
// create the alert
$montage=GetWindowObj("MONTAGE1");
$MYSYMB=GetWindowObj("MY1MIN").SYMBOL;
$MYALERT=NewAlertObj();
$MYALERT.name="Price Reached";
if($montage.PRICE<$montage.LAST)
{
$MYALERT.AddItem("Last Sale","<",$montage.PRICE);
}
else
{
$MYALERT.AddItem("Last Sale",">",$montage.PRICE);
}
$MYALERT.Speak=1;
$MYALERT.SYMB=$MYSYMB;
$MYALERT.PlaySound=0;
$MYALERT.Autodelete=1;
$MYALERT.PopupWindow=1;
$MYALERT.Loop=0;
$MYALERT.save();
to make the line object draggable to update the alert is the same as this
21. on charts below area, candle info to be by default last one (same as Think or Swim) and not where you had your cursor last
sorry this one would need more explanation
22. if manual entry order, hotkey to set stop loss (R) and 4 OCO 25% each at 1R, 2R, 3R and 4R
This one is answered in point 14.
Here an example for 2 OCO orders
// set your desired risk
// $DRISK=GetAccountObj(getwindowobj(”MONTAGE1”).account).equity/80;
$DRISK=20;
$standardrisk=-1;
$standardpartial=2;
$standardreward=5;
$MONTAGE=getwindowobj(”MONTAGE1”);
$MYPOS=GetAccountObj($MONTAGE.account).getposition($MONTAGE.symb).share;
if($MYPOS==0)
{return;}
$MONTAGE.cxl allsymb;
$1R=ABS(ROUND($DRISK/$MONTAGE.POS,2));
// partial
$STARGET=$standardpartial*$1R;
$SRISK=$STANDARDRISK*$1R;
$montage.route=”STOP”;
$montage.Stoptype=”RangeMkt”;
$montage.share=ROUND(ABS($MYPOS/2),0);
// set preferred exit route
$montage.pref=”FLSH”;
if($MYPOS<0)
{
$montage.highprice=$montage.avgcost-$SRISK;
$montage.lowprice=$montage.avgcost-$STARGET;
$montage.buy=send;
}
else
{
$montage.highprice=$montage.avgcost+$STARGET;
$montage.lowprice=$montage.avgcost+$SRISK;
$montage.sell=send;
}
// the rest
$STARGET=$STANDARDREWARD*$1R;
$SRISK=$STANDARDRISK*$1R;
$montage.route=”STOP”;
$montage.Stoptype=”RangeMkt”;
$montage.share=ABS($MYPOS)-ABS($MYPOS/2);
// set preferred exit route
$montage.pref=”FLSH”;
if($MYPOS<0)
{
$montage.highprice=$montage.avgcost-$SRISK;
$montage.lowprice=$montage.avgcost-$STARGET;
$montage.buy=send;
}
else
{
$montage.highprice=$montage.avgcost+$STARGET;
$montage.lowprice=$montage.avgcost+$SRISK;
$montage.sell=send;
}
23. assign wl (watch list) stocks to window with multiple charts
This is shown in the previous post
$row=1;
$a=GetWindowObj("MYMKTVIEWER");
$b=GetWindowObj("MONTAGE1");
while($row<44)
{
$C=GetWindowObj("chart"+$row);
$a.selectedrow=$row;
$b.symbol=$a.selectedsymbol;
$c.symb=$b.symbol;
$row=$row+1;
}
As in the previous point 19, you have to name your charts chart1-chart30, name your watch list “MYMKTVIEWER” and name your montage “MONTAGE1” then use the above code to populate the charts with the symbols from your watch list. If you have empty rows in the watch list you can add a symbol check in between, to skip the empty rows.
24. link montage to external window/program to show data (ie tracker historical success on selected stock)
The direct link is not possible, but there are ways on how to call an external program on a symbol change as shown in these posts
$params="Trade#"+$tradecounter +"-" +$MYSYMB +"-"+$DIRECTION;
ShellExec("powershell.exe","-file C:\\temp\\your_script.ps1 -Tradeparams " +$params+"","c:\\temp\\");
You can also save the variables into a file as shown here
You can combine then operating system scripting or other programs to monitor the variables file for specific variables and call an external program. I will cover this in one of my next posts so subscribe to get notified about the solution.