Combine obv mfi kdj cci adl wpr sqz stoch momo roc rvol dma rsi vol

hazmat8039

New member
Breakout, breakdown script

Code:
input rsiLength = 14;

def obv = OnBalanceVolume();

def mfi = MoneyFlowIndex();

def kdj = StochasticKDJ();

def cci = CommodityChannelIndex();

def adl = AccumulationDistributionLine();

def wwv = WilliamsPercentR();

def ttmSqueeze = TtmSqueeze();

def st = Stochastic();

def mom = Momentum();

def roc = RateOfChange();

def rvol = RelativeVolume();

def dma = DirectionalMovementAverage();



def rsi = reference RSI(length = rsiLength);



plot upArrow = if (volume > 2 * volume [1] and obv > obv[1] and mfi > 50 and kdj > 20 and cci > 100 and adl > adl[1] and wwv < -80 and ttmSqueeze.Squeeze[1] == 0 and st.D > st.K and mom > 0 and roc > 0 and rvol > rvol[1] and dma > dma[1] and rsi > 50) then high else Double.NaN;



plot downArrow = if (volume > 2 * volume [1] and rsi > 70 and mfi < 20 and kdj < 80 and cci < -100 and adl < adl[1] and ttmSqueeze.Squeeze[1] == 1 and mom < 0 and (roc < 0 or rvol < rvol[1]) and dma < dma[1]) then low else Double.NaN;



upArrow.SetColor(CreateColor(0, 255, 0)); # green color

downArrow.SetColor(CreateColor(255, 0, 0)); # red color



upArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

downArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);



add_study(upArrow);

add_study(downArrow);

Trying to create a custom indicator. The code defines two plots, "upArrow" and "downArrow", that display an arrow on the chart when certain conditions are met based on the values of various technical indicators. The conditions for an up arrow to appear include a volume increase, bullish signals from indicators such as On Balance Volume (OBV), Money Flow Index (MFI), Stochastic KDJ, Commodity Channel Index (CCI), Accumulation Distribution Line (ADL), Williams Percent R (WWV), TtmSqueeze, Stochastic, Momentum, Rate of Change (ROC), Relative Volume, and Directional Movement Average (DMA). The conditions for a down arrow to appear include a volume increase and bearish signals from MFI, KDJ, CCI, ADL, TtmSqueeze, Momentum, ROC, Relative Volume, and DMA. The color of the arrows is set to green for up arrows and red for down arrows, and the plotting strategy is set to display an arrow shape.

I can’t get this to work, anyone got a fix for it?
 
Solution
Breakout, breakdown script

Code:
input rsiLength = 14;

def obv = OnBalanceVolume();

def mfi = MoneyFlowIndex();

def kdj = StochasticKDJ();

def cci = CommodityChannelIndex();

def adl = AccumulationDistributionLine();

def wwv = WilliamsPercentR();

def ttmSqueeze = TtmSqueeze();

def st = Stochastic();

def mom = Momentum();

def roc = RateOfChange();

def rvol = RelativeVolume();

def dma = DirectionalMovementAverage();



def rsi = reference RSI(length = rsiLength);



plot upArrow = if (volume > 2 * volume [1] and obv > obv[1] and mfi > 50 and kdj > 20 and cci > 100 and adl > adl[1] and wwv < -80 and ttmSqueeze.Squeeze[1] == 0 and st.D > st.K and mom > 0 and roc > 0 and rvol > rvol[1] and dma > dma[1] and rsi > 50) then high...
Breakout, breakdown script

Code:
input rsiLength = 14;

def obv = OnBalanceVolume();

def mfi = MoneyFlowIndex();

def kdj = StochasticKDJ();

def cci = CommodityChannelIndex();

def adl = AccumulationDistributionLine();

def wwv = WilliamsPercentR();

def ttmSqueeze = TtmSqueeze();

def st = Stochastic();

def mom = Momentum();

def roc = RateOfChange();

def rvol = RelativeVolume();

def dma = DirectionalMovementAverage();



def rsi = reference RSI(length = rsiLength);



plot upArrow = if (volume > 2 * volume [1] and obv > obv[1] and mfi > 50 and kdj > 20 and cci > 100 and adl > adl[1] and wwv < -80 and ttmSqueeze.Squeeze[1] == 0 and st.D > st.K and mom > 0 and roc > 0 and rvol > rvol[1] and dma > dma[1] and rsi > 50) then high else Double.NaN;



plot downArrow = if (volume > 2 * volume [1] and rsi > 70 and mfi < 20 and kdj < 80 and cci < -100 and adl < adl[1] and ttmSqueeze.Squeeze[1] == 1 and mom < 0 and (roc < 0 or rvol < rvol[1]) and dma < dma[1]) then low else Double.NaN;



upArrow.SetColor(CreateColor(0, 255, 0)); # green color

downArrow.SetColor(CreateColor(255, 0, 0)); # red color



upArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

downArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);



add_study(upArrow);

add_study(downArrow);

Trying to create a custom indicator. The code defines two plots, "upArrow" and "downArrow", that display an arrow on the chart when certain conditions are met based on the values of various technical indicators. The conditions for an up arrow to appear include a volume increase, bullish signals from indicators such as On Balance Volume (OBV), Money Flow Index (MFI), Stochastic KDJ, Commodity Channel Index (CCI), Accumulation Distribution Line (ADL), Williams Percent R (WWV), TtmSqueeze, Stochastic, Momentum, Rate of Change (ROC), Relative Volume, and Directional Movement Average (DMA). The conditions for a down arrow to appear include a volume increase and bearish signals from MFI, KDJ, CCI, ADL, TtmSqueeze, Momentum, ROC, Relative Volume, and DMA. The color of the arrows is set to green for up arrows and red for down arrows, and the plotting strategy is set to display an arrow shape.

I can’t get this to work, anyone got a fix for it?

See if this helps get you started.

There were some def statements that needed to be fixed.
When defining indicators make sure that you look for the inspector to appear with the indicator you want and the correct plot.
I only did the 'uparrow' with the revised defs.
I was able to test some of the uparrow conditions one after another until the arrow plot would disappear after about half through your conditions.
I will it to you to try to get it to work how you work for the uparrow and make the appropriate adjustments to the downarrow thereafter.

Code:
input rsiLength = 14;

def obv = OnBalanceVolume();

def mfi = MoneyFlowIndex();

def kdj = Stochasticfull().fullk; #StochasticKDJ();

def cci = CCI(); #CommodityChannelIndex();

def adl = AccumulationDistribution().rangeratio; #AccumulationDistributionLine();

def wwv = WilliamsPercentR();

def ttmSqueeze = TTM_Squeeze().squeezealert; #TtmSqueeze();

#def st = StochasticFull(); #Stochastic();

def mom = Momentum();

def roc = RateOfChange();

def rvol = RelativeVolumeStDev().relvol;

def dma = DMA();

def rsi = reference RSI(length = rsiLength);



plot upArrow = if (volume > 2 * volume [1] and
                  obv > obv[1] and         
                  mfi > 50 and
                  kdj > 20 and
                  cci > 100 and
                  adl > adl[1] and
                  wwv < -80 and
                  TTMsqueeze == 0 and
                  stochasticfull().fulld > stochasticfull().fullk and
                  mom > 0 and
                  roc > 0 and
                  rvol > rvol[1] and
                  dma > dma[1] and
                  rsi > 50)

                  then high else Double.NaN;


#plot downArrow = if (volume > 2 * volume [1] and rsi > 70 and mfi < 20 and kdj < 80 and cci < -100 and adl < adl[1] and reference ttm_Squeeze().Squeezealert[1] == 1 and mom < 0 and (roc < 0 or rvol < rvol[1]) and dma < dma[1]) then low else Double.NaN;



 # green color

 # red color



upArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

#downArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);



#add_study(upArrow);

#add_study(downArrow);
 
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
375 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