Stoch DMI

GaMoneyDr

New member
VIP
I am new to ThinkorSwim. I have created a few scans that I really like. I have created a few simple strategies.

I am having difficulty with creating a strategy that has multiple studies, I can't seem to code ThinkScript correctly to accept 2 conditions.

I can create a scan that is pretty complicated and shows me what I want as a "right now" snapshot. But I can't seem to incorporate the same logic into a strategy for a backtest. I have alot to learn, and I will keep reading these forums.

Here is the strategy I have tried to create for the past 3 days.

Thanks for any help, and any advice on putting more than 1 study into a strategy.


1. Full Stochastic: %K is less than 30, and %K crosses above %D
2. DMI: DI+ is above DI-
3. Nice to have Bonus --- ZigZag is sloping upward at the time of the buy point.
 
Solution
I am new to ThinkorSwim. I have created a few scans that I really like. I have created a few simple strategies.

I am having difficulty with creating a strategy that has multiple studies, I can't seem to code ThinkScript correctly to accept 2 conditions.

I can create a scan that is pretty complicated and shows me what I want as a "right now" snapshot. But I can't seem to incorporate the same logic into a strategy for a backtest. I have alot to learn, and I will keep reading these forums.

Here is the strategy I have tried to create for the past 3 days.

Thanks for any help, and any advice on putting more than 1 study into a strategy.


1. Full Stochastic: %K is less than 30, and %K crosses above %D
2. DMI...
I am new to ThinkorSwim. I have created a few scans that I really like. I have created a few simple strategies.

I am having difficulty with creating a strategy that has multiple studies, I can't seem to code ThinkScript correctly to accept 2 conditions.

I can create a scan that is pretty complicated and shows me what I want as a "right now" snapshot. But I can't seem to incorporate the same logic into a strategy for a backtest. I have alot to learn, and I will keep reading these forums.

Here is the strategy I have tried to create for the past 3 days.

Thanks for any help, and any advice on putting more than 1 study into a strategy.


1. Full Stochastic: %K is less than 30, and %K crosses above %D
2. DMI: DI+ is above DI-
3. Nice to have Bonus --- ZigZag is sloping upward at the time of the buy point.

GaMoneyDr,

You may have already figured this one out, but if not then this may get you going on the idea.

The script plots an arrow when StochasticFull K is < 30 and K crosses above D while DI+ is above DI-. Signals were extremely rare when the TOS StochasticFull was set at its default 10, 10, 3 values. When I switched it to the more commonly used 14, 3, 3 values some more signals appeared. The StochasticFull and DMI parameters can be changed in the inputs. No ZigZag slope requirement coded yet...

BBlgbJg.png


Code:
# StochasticAndDMI_Buy
# Question from GaMoneyDr; plots arrow when DI+ > DI- and StochasticFull is oversold and FullK crosses above FullD; Note that then StochasticFull default parameters are 14, 3, 3; these are more common than 10, 10, 3 values found in TOS.

input length = 14;
input averageType = AverageType.WILDERS;

input over_bought = 80;
input over_sold = 30;
input KPeriod = 14;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input slowing_period = 3;
input averageType2 = AverageType.SIMPLE;

def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
def "DI+" = 100 * MovingAverage(averageType, plusDM, length) / ATR;
def "DI-" = 100 * MovingAverage(averageType, minusDM, length) / ATR;

def lowest_k = Lowest(priceL, KPeriod);
def c1 = priceC - lowest_k;
def c2 = Highest(priceH, KPeriod) - lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;

def FullK = MovingAverage(averageType2, FastK, slowing_period);
def FullD = MovingAverage(averageType2, FullK, DPeriod);

def DMIcond = "DI+" > "DI-";
def StochOversold = FullK < over_sold;
def StochCross = FullK crosses above FullD;

plot BuySignal = DMIcond and StochOversold and StochCross;

BuySignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BuySignal.SetDefaultColor(Color.BLUE);
BuySignal.SetLineWeight(3);
 
Last edited by a moderator:
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
219 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top