Calling ATR and A Stop Loss Macro In TraderXL Pro

Yeah, I still use TraderXL Pro for a bunch of my data manipulation and technical analysis stuff. I use it to download data and run macros through it, macros that I design and then use in my trading screen. After my fucked up 2009 trading year, I had to revamp my entire arsenal of macros and screens for a brighter and more profitable future, I hope.
 
Anyway, below is one of the many macros I use in TraderXL Pro for generating an automatic stop loss using and Average True Range (ATR) function. I then suck this data into my trading screen, and through the use of other magical macros. I then determine if I have to move my stop or sit on my hands.
 
Since I love you guys, here’s the macro call for the ATR function and the stop loss. First name your spreadsheet Current_Stock_Holdings.xls (you can change this later) then copy this into the AutoRun Macro box in BulksquoteXL.
 
AverageTrueRange(“G1″,”X);Current_Stock_Holdings.xls!Module1.Stop_loss_ATR;StockChart(“OHLC”,“J1″)
 
 
I use a 20 day time period for my ATR function, as the image above shows. You’ll have substitute X” in the callout function above for the time period you want. It can be 5, 10, 15, or 50, whatever floats your boat and your needs.
 
Once you’ve done this, then you need to copy and paste in the macro for the stop loss function below. Make sure you save it to your spreadsheet locally. As with the ATR function, you’ll have to edit the X.X that I highlight below to a multiple that you like. It can be 1.5 or 5.5 times the ATR. This will generate wider or tighter stops based on your individual preferences. The smaller the number you input, the tighter the stop you generate. Conversely the larger the number you input, the looser the stop.
 
You can use the Macro Viewer function in TraderXL to import the macro below if you don’t know how to do it manually. Copy and paste the function between the ——++’s into a TXT file and then import it.
 
<div><span style="font-size:10.0pt;">Sub Stop_loss_ATR()</span></div>
<div><span style="font-size:10.0pt;">&#39;</span></div>
<div><span style="font-size:10.0pt;">&#39; Stop_loss_ATR Macro</span></div>
<div><span style="font-size:10.0pt;">&#39; Macro recorded 12/15/2009 by neuralmarkettrends</span></div>
<div><span style="font-size:10.0pt;">&#39;</span></div>
<div>&nbsp;</div>
<div><span style="font-size:10.0pt;">&#39;</span></div>
<div><span style="font-size:10.0pt;">&nbsp;&nbsp;&nbsp; Range(&quot;H1&quot;).Select</span></div>
<div><span style="font-size:10.0pt;">&nbsp;&nbsp;&nbsp; ActiveCell.FormulaR1C1 = &quot;Stop Loss&quot;</span></div>
<div><span style="font-size:10.0pt;">&nbsp;&nbsp;&nbsp; Range(&quot;H21&quot;).Select</span></div>
<div><span style="font-size:10.0pt;">&nbsp;&nbsp;&nbsp; ActiveCell.FormulaR1C1 = &quot;=(RC[-3]-(RC[-1]*<span style="background:yellow;">X.X</span>))&quot;</span></div>
<div><span style="font-size:10.0pt;">&nbsp;&nbsp;&nbsp; Range(&quot;H21&quot;).Select</span></div>
<div><span style="font-size:10.0pt;">&nbsp;&nbsp;&nbsp; Selection.NumberFormat = &quot;0.0000&quot;</span></div>
<div><span style="font-size:10.0pt;">&nbsp;&nbsp;&nbsp; Selection.NumberFormat = &quot;0.000&quot;</span></div>
<div><span style="font-size:10.0pt;">&nbsp;&nbsp;&nbsp; Selection.NumberFormat = &quot;0.00&quot;</span></div>
<div><span style="font-size:10.0pt;">&nbsp;&nbsp;&nbsp; Selection.Copy</span></div>
<div><span style="font-size:10.0pt;">&nbsp;&nbsp;&nbsp; Range(&quot;H22:H253&quot;).Select</span></div>
<div><span style="font-size:10.0pt;">&nbsp;&nbsp;&nbsp; ActiveSheet.Paste</span></div>
<div><span style="font-size:10.0pt;">&nbsp;&nbsp;&nbsp; Application.CutCopyMode = False</span></div>
<div><span style="font-size:10.0pt;">End Sub</span></div>
<div>&nbsp;</div>
Just a side note, you might be wondering why I call the stockchart function StockChart(“OHLC”,“J1″).” I do that so I can create a nice candlestick chart next to the downloaded data as eye candy.
 
That’s it, there you have it. Now go cause mischief!


Date
December 29, 2009