# Need Help: Hull Di+ Di- Strategy

#### rihboi3087

##### New member
Hello there, I was watching this video on backtesting a strategy and the results look promising. So I was wondering if someone can help writing the strategy on TOS.
See Video here for context.

A simplified version would work perfectly too
TF 1MN
Long: price closes above HULL 88 and Di+ crosses above Di-
R/R 1:1.5
Short: price closes below hull 88 and Di- crosses above Di+

Solution
Hello there, I was watching this video on backtesting a strategy and the results look promising. So I was wondering if someone can help writing the strategy on TOS.
See Video here for context.

A simplified version would work perfectly too
TF 1MN
Long: price closes above HULL 88 and Di+ crosses above Di-
R/R 1:1.5
Short: price closes below hull 88 and Di- crosses above Di+

See if this helps you get started. Put the script in create Strategy rather than Study

Ruby:
#A simplified version would work perfectly too
#TF 1MN
#Long: price closes above HULL 88 and Di+ crosses above Di-
#R/R 1:1.5
#Short: price closes below hull 88 and Di- crosses above Di+...

#### SleepyZ

##### Well-known member
VIP
Hello there, I was watching this video on backtesting a strategy and the results look promising. So I was wondering if someone can help writing the strategy on TOS.
See Video here for context.

A simplified version would work perfectly too
TF 1MN
Long: price closes above HULL 88 and Di+ crosses above Di-
R/R 1:1.5
Short: price closes below hull 88 and Di- crosses above Di+

See if this helps you get started. Put the script in create Strategy rather than Study

Ruby:
#A simplified version would work perfectly too
#TF 1MN
#Long: price closes above HULL 88 and Di+ crosses above Di-
#R/R 1:1.5
#Short: price closes below hull 88 and Di- crosses above Di+

input length  = 88;
input avgtype = AverageType.HULL;

def ATR_      = reference ATR();
def "DI+"     = reference DIPlus();
def "DI-"     = reference DIMinus();

plot ma       = MovingAverage(avgtype, close, length);
ma.AssignValueColor(if ma >= ma[1] then Color.GREEN else Color.RED);

#Conditions
plot Long       = if close > ma and "DI+" crosses above "DI-" then close else Double.NaN;
Long.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
def Longtarget = Long + ATR_ * 1.5;
def LongStop   = Long - ATR_;

plot Short       = close < ma and "DI-" crosses above "DI+";
Short.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
def Shorttarget = Short - ATR_ * 1.5;
def ShortStop   = Short + ATR_;

#Orders
AddOrder(type = OrderType.BUY_TO_OPEN, condition = Long, tickColor = Color.GREEN, arrowColor = Color.GREEN);
AddOrder(type = OrderType.SELL_TO_CLOSE, condition = Longtarget or LongStop or Short, tickColor = Color.WHITE, arrowColor = Color.WHITE);

AddOrder(type = OrderType.SELL_TO_OPEN, condition = Short, tickColor = Color.RED, arrowColor = Color.RED);
AddOrder(type = OrderType.BUY_TO_CLOSE, condition = Shorttarget or ShortStop or Long, tickColor = Color.YELLOW, arrowColor = Color.YELLOW);

#Test
input test = no;
AddChartBubble(test and Long, low, "T " + Longtarget + "\nE " + Long + "\nS " + LongStop, Color.GREEN, no);
AddChartBubble(test and Short, high, "S " + ShortStop + "\nE  " + Short + "\nT " + Shorttarget, Color.RED, yes);
;

#### rihboi3087

##### New member
See if this helps you get started. Put the script in create Strategy rather than Study
Wow Awesome! Thank you, i think I can work with that.

#### kyuts

##### New member
See if this helps you get started. Put the script in create Strategy rather than Study
Hello SleeyZ,

May I ask why the LONG and SHORT plots are written out differently? One has IF and the other doesn't.

Thanks.

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?