How to make a ATRTrailStopLX


Category:
0
0

Hi Mr Hahn,

I though I could quickly make an ATRTrailStopLX by taking the built-in thinkorswim ARTTrailStopLE and then modifying that.  It didn’t quite work out like I had hoped.  I don’t want that signal to start a short position.  I just wanted to use it to exit long positions using your MACDRSI_2 script.  Can you please help with that?  Here’s what I had…

input trailType = {default modified, unmodified};
input ATRPeriod = 14;
input ATRFactor = 4;
input firstTrade = {default long};
input averageType = AverageType.WILDERS;

def condition = ATRTrailingStop(trailType, ATRPeriod, ATRFactor, firstTrade, averageType).sellSignal;

addOrder(OrderType.SELL_AUTO, condition, tickColor = GetColor(0), arrowColor = GetColor(0));

Marked as spam
Posted by (Questions: 2, Answers: 1)
Asked on May 29, 2020 3:24 pm
202 views
0
Private answer

Probably much simpler than you could have ever imagined. It's a setting. The default order type is set to "Auto". In order to change the behavior so that the same strategy behaves as an exit you simply change the order type from "Auto" to "To Close". See attached.

Once you change the order type the strategy can only function to exit positions. Screenshots below show both the LE as well as the SE versions. When changing the LE version to "To Close" it will function as a short exit. That may take a bit of thought to get that straight in your head. That's why included this last paragraph. Be patient. It's a bit like turning something upside down and inside out.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on May 29, 2020 4:08 pm