DAS Trader advanced hotkeys part 3
How to draw ATR lines to your charts with a single click
See the other posts about DASTrader hotkeys here.
How to draw ATR lines to your charts with a single click
Step by step
Follow this 4-step process:
Install and configure DAS Trader
DAS Trader 5.7.9.0 or newer is installed and Hotkey Advanced Script Enabled in Settings - as described here
add the ATR to a chart
For this, you need to display the ATR on a chart. For my purposes I use the daily chart. You need to add the ATR study to the chart and give it a name
for our purpose we name the study “myatr” as displayed on the above picture.
Make sure to change the Study Name field.
Read the ATR values into a variable
Right-click the chart window and select Configure. Scroll to the very bottom of the window and put the following into the Update Script field.
$MYATR=GetStudyVal("myatr");
Name the chart window of the daily chart
This is needed so that when you press the hotkey, the lines are drawn in the specific chart window so you do not have to take care on which window you are focused on.
In this case the name of the chart windows is MYDAILY
create the hot button
Now the calculations happen all in the hotkey where it adds and subtracts the ATR value from the today’s low - LO and today’s high - HI
Draw ATR lines to the daily chart
$HOD=HI;
$LOD=LO;
$HITGT=Round($LOD+$MYATR,2);
$LOTGT=Round($HOD-$MYATR,2);
FocusWindow MYDAILY;
DrawHorzLineWithPrice($HITGT,color(190,254,152));
DrawHorzLineWithPrice($LOTGT,color(190,254,152));
This will draw you automatically the yellow horizontal lines to the ATR calculated from bottom to the top and from top to the bottom.
create the hotkey
For a hotkey, we need a bit of different syntax to read the HI and LO values from the montage. We could do the same from a daily chart window. We need to add
Focuswindow MONTAGE1;
at the start of the script. We need to name our montage window as MONTAGE1 first.
We can also populate the variables with
$HOD=GetWindowObj("MONTAGE1").HI;
$LOD=GetWindowObj("MONTAGE1").Lo;
so the final hotkey script will be
$HOD=GetWindowObj("MONTAGE1").HI;
$LOD=GetWindowObj("MONTAGE1").Lo;
$HITGT=Round($LOD+$MYATR,2);
$LOTGT=Round($HOD-$MYATR,2);
FocusWindow MYDAILY;
DrawHorzLineWithPrice($HITGT,color(190,254,152));
DrawHorzLineWithPrice($LOTGT,color(190,254,152));
Other useful considerations
If you want to display the same values as a message with some additional data like how much is it to the ATR and display the RVOL (in case you don’t see it on your montage) you can do that with the following hotkey.
Show message box with the ATR values
$HOD=HI;
$LOD=LO;
$MYRVOL=RVOL;
$HITGT=Round($LOD+$MYATR,2);
$LOTGT=Round($HOD-$MYATR,2);
$TOHATR=$HITGT-LAST;
$TOLATR=LAST-$LOTGT;
MsgBox($HITGT +" to Hi ATR: "+$TOHATR +"\n" +$LOTGT +" to Lo ATR: "+$TOLATR +"\n RVOL:" +$MYRVOL +"%" );
This will show you the following message box
Feel free to add any text you like.
There is a limit of trend lines your DAS Trader can remember (which is a setting) and it has a CPU penalty so the more lines you have the slower your DAS gets theoretically so it is useful to have the following hotkeys ready for the cleanups
Setup delete all trend lines hotkey
RemoveAllTrendlines;
I personally keep it on ALT+SPACE combination.
Setup delete all trend lines for all tickers hotkey
RemoveALLLines AllSymbols;
I personally keep it on CTRL+ALT+SPACE combination.
As you probably understand, we can draw other lines like targets and partial zones calculated based on your opened position too. I will be covering more of these features in the next posts. If you have any specific needs please feel free to consult it with me.
Would it be possible to draw a line 10% from the open?
Hi Peter,
If I understand well the definition of the ATR ("The true range indicator is taken as the greatest of the following: current high less the current low; the absolute value of the current high less the previous close; and the absolute value of the current low less the previous close"), it's a comparison between 3 values and the highest is used.
Your script just takes in account one of these 3 values, which makes it unprecise for stocks that are gaping.
Do you think it could be possible to go closer to the real definition of the ATR ?
Thank you