hazmat8039
New member
Breakout, breakdown script
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?
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?