Assistance with Input Count

David45

Active member
2019 Donor
Hi Folks,

I'm trying to add code so that I can adjust the Input Count for the bullstop and bearstop. What I came up with is not working. Any assistance would be very much appreciated!

def bullish2 = if signal > 0 and signal[1] <= 0 then barNumber() else 0;
plot upArrow = if !displayBubblesOnly and barNumber() == HighestAll(bullish2) then low * 0.994 else Double.NaN;
upArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
upArrow.SetLineWeight(5);
upArrow.SetDefaultColor(Color.CYAN);

def bearish2 = if signal < 0 and signal[1] >= 0 then barNumber() else 0;
plot downArrow = if !displayBubblesOnly and barNumber() == HighestAll(bearish2) then high * 1.004 else Double.NaN;
downArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
downArrow.SetLineWeight(5);
downArrow.SetDefaultColor(Color.YELLOW);

def bullstop= if barNumber() == HighestAll(bullish2) then low[1] else if barnumber() < HighestAll(bullish2) then double.nan else bullstop[1];
plot bullstopplot = bullstop;
bullstopplot.setdefaultColor(color.dark_green);
AddChartBubble(displayBubblesOnly and barNumber() == HighestAll(bullish2), low[1], "Stop " + astext(low[1]), Color.Dark_Green, no);

def bearstop= if barNumber() == HighestAll(bearish2) then high[1] else if barnumber() < HighestAll(bearish2) then double.nan else bearstop[1];
plot bearstopplot = bearstop;
bearstopplot.setdefaultColor(color.red);
AddChartBubble(displayBubblesOnly and barNumber() == HighestAll(bearish2), high[1], "Stop " + astext(high[1]), Color.red, yes);

Here's what I came up with but I'm getting errors and it does not work:

Input Count = 1;
def cond = bullstop or bearstop;
def dataCount = CompoundValue(1, if (cond) then dataCount[1] + 1 else dataCount[1], 0);
def limitplot = HighestAll(dataCount) - dataCount <= Count - 1;
 
Hi Folks,

I'm trying to add code so that I can adjust the Input Count for the bullstop and bearstop. What I came up with is not working. Any assistance would be very much appreciated!

def bullish2 = if signal > 0 and signal[1] <= 0 then barNumber() else 0;
plot upArrow = if !displayBubblesOnly and barNumber() == HighestAll(bullish2) then low * 0.994 else Double.NaN;
upArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
upArrow.SetLineWeight(5);
upArrow.SetDefaultColor(Color.CYAN);

def bearish2 = if signal < 0 and signal[1] >= 0 then barNumber() else 0;
plot downArrow = if !displayBubblesOnly and barNumber() == HighestAll(bearish2) then high * 1.004 else Double.NaN;
downArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
downArrow.SetLineWeight(5);
downArrow.SetDefaultColor(Color.YELLOW);

def bullstop= if barNumber() == HighestAll(bullish2) then low[1] else if barnumber() < HighestAll(bullish2) then double.nan else bullstop[1];
plot bullstopplot = bullstop;
bullstopplot.setdefaultColor(color.dark_green);
AddChartBubble(displayBubblesOnly and barNumber() == HighestAll(bullish2), low[1], "Stop " + astext(low[1]), Color.Dark_Green, no);

def bearstop= if barNumber() == HighestAll(bearish2) then high[1] else if barnumber() < HighestAll(bearish2) then double.nan else bearstop[1];
plot bearstopplot = bearstop;
bearstopplot.setdefaultColor(color.red);
AddChartBubble(displayBubblesOnly and barNumber() == HighestAll(bearish2), high[1], "Stop " + astext(high[1]), Color.red, yes);

Here's what I came up with but I'm getting errors and it does not work:

Input Count = 1;
def cond = bullstop or bearstop;
def dataCount = CompoundValue(1, if (cond) then dataCount[1] + 1 else dataCount[1], 0);
def limitplot = HighestAll(dataCount) - dataCount <= Count - 1;

near impossible to answer, it is missing 2 vaiables,, displayBubblesOnly and signal.
displayBubblesOnly i can guess and set it to 1.
but i have no idea what signal should be?
i added 2 averages and when one is above the other i set signal = 1.

bullstop seems to always be na ?
the last 3 variables are always na ?



Code:
# countcompare_00

# --- missing vars , displayBubblesOnly  and signal
def displayBubblesOnly = 1;


def ma1 = average(close, 30);
def ma2 = average(close, 50);
def signal = (ma1 > ma2);


def bullish2 = if signal > 0 and signal[1] <= 0 then barNumber() else 0;
plot upArrow = if !displayBubblesOnly and barNumber() == HighestAll(bullish2) then low * 0.994 else Double.NaN;
upArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
upArrow.SetLineWeight(5);
upArrow.SetDefaultColor(Color.CYAN);

def bearish2 = if signal < 0 and signal[1] >= 0 then barNumber() else 0;
plot downArrow = if !displayBubblesOnly and barNumber() == HighestAll(bearish2) then high * 1.004 else Double.NaN;
downArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
downArrow.SetLineWeight(5);
downArrow.SetDefaultColor(Color.YELLOW);

def bullstop= if barNumber() == HighestAll(bullish2) then low[1] else if barnumber() < HighestAll(bullish2) then double.nan else bullstop[1];
plot bullstopplot = bullstop;
bullstopplot.setdefaultColor(color.dark_green);
AddChartBubble(displayBubblesOnly and barNumber() == HighestAll(bullish2), low[1], "Stop " + astext(low[1]), Color.Dark_Green, no);

def bearstop= if barNumber() == HighestAll(bearish2) then high[1] else if barnumber() < HighestAll(bearish2) then double.nan else bearstop[1];
plot bearstopplot = bearstop;
bearstopplot.setdefaultColor(color.red);
AddChartBubble(displayBubblesOnly and barNumber() == HighestAll(bearish2), high[1], "Stop " + astext(high[1]), Color.red, yes);


#Here's what I came up with but I'm getting errors and it does not work:
#
Input Count = 1;
def cond = bullstop or bearstop;
def dataCount = CompoundValue(1, if (cond) then dataCount[1] + 1 else dataCount[1], 0);
def limitplot = HighestAll(dataCount) - dataCount <= Count - 1;

# --------------------------

addchartbubble(1, low, cond + "\n" + datacount + "\n" + limitplot , color.cyan, no);
# all 3 are na

addchartbubble(1, low,  bullish2 + "\n" + bullstop + "\n" + bearish2 + "\n" + bearstop, color.cyan, no);
#  stops are na

addchartbubble(1, low,  barnumber() + "\n" + signal + "\n" + bullish2 + "\n" + HighestAll(bullish2) , (if bullish2 then color.cyan else color.gray), no);
#  stops are na

#
 
near impossible to answer, it is missing 2 vaiables,, displayBubblesOnly and signal.
displayBubblesOnly i can guess and set it to 1.
but i have no idea what signal should be?
i added 2 averages and when one is above the other i set signal = 1.

bullstop seems to always be na ?
the last 3 variables are always na ?



Code:
# countcompare_00

# --- missing vars , displayBubblesOnly  and signal
def displayBubblesOnly = 1;


def ma1 = average(close, 30);
def ma2 = average(close, 50);
def signal = (ma1 > ma2);


def bullish2 = if signal > 0 and signal[1] <= 0 then barNumber() else 0;
plot upArrow = if !displayBubblesOnly and barNumber() == HighestAll(bullish2) then low * 0.994 else Double.NaN;
upArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
upArrow.SetLineWeight(5);
upArrow.SetDefaultColor(Color.CYAN);

def bearish2 = if signal < 0 and signal[1] >= 0 then barNumber() else 0;
plot downArrow = if !displayBubblesOnly and barNumber() == HighestAll(bearish2) then high * 1.004 else Double.NaN;
downArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
downArrow.SetLineWeight(5);
downArrow.SetDefaultColor(Color.YELLOW);

def bullstop= if barNumber() == HighestAll(bullish2) then low[1] else if barnumber() < HighestAll(bullish2) then double.nan else bullstop[1];
plot bullstopplot = bullstop;
bullstopplot.setdefaultColor(color.dark_green);
AddChartBubble(displayBubblesOnly and barNumber() == HighestAll(bullish2), low[1], "Stop " + astext(low[1]), Color.Dark_Green, no);

def bearstop= if barNumber() == HighestAll(bearish2) then high[1] else if barnumber() < HighestAll(bearish2) then double.nan else bearstop[1];
plot bearstopplot = bearstop;
bearstopplot.setdefaultColor(color.red);
AddChartBubble(displayBubblesOnly and barNumber() == HighestAll(bearish2), high[1], "Stop " + astext(high[1]), Color.red, yes);


#Here's what I came up with but I'm getting errors and it does not work:
#
Input Count = 1;
def cond = bullstop or bearstop;
def dataCount = CompoundValue(1, if (cond) then dataCount[1] + 1 else dataCount[1], 0);
def limitplot = HighestAll(dataCount) - dataCount <= Count - 1;

# --------------------------

addchartbubble(1, low, cond + "\n" + datacount + "\n" + limitplot , color.cyan, no);
# all 3 are na

addchartbubble(1, low,  bullish2 + "\n" + bullstop + "\n" + bearish2 + "\n" + bearstop, color.cyan, no);
#  stops are na

addchartbubble(1, low,  barnumber() + "\n" + signal + "\n" + bullish2 + "\n" + HighestAll(bullish2) , (if bullish2 then color.cyan else color.gray), no);
#  stops are na

#
@halcyonguy Thank you so much for taking a stab at this. I sincerely appreciate it! I stupidly forgot to include the def signal portion of the code (please see below). Would you kindly update the code you wrote to reflect the def signal?

def signal = CompoundValue(1, if dir > 0 and pricel > EIL then if signal[1] <= 0 then 1 else signal[1] else if dir < 0 and priceh < EIH then if signal[1] >= 0 then -1 else signal[1] else signal[1], 0);

def bullish2 = if signal > 0 and signal[1] <= 0 then barNumber() else 0;
plot upArrow = if !displayBubblesOnly and barNumber() == HighestAll(bullish2) then low * 0.994 else Double.NaN;
upArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
upArrow.SetLineWeight(5);
upArrow.SetDefaultColor(Color.CYAN);

def bearish2 = if signal < 0 and signal[1] >= 0 then barNumber() else 0;
plot downArrow = if !displayBubblesOnly and barNumber() == HighestAll(bearish2) then high * 1.004 else Double.NaN;
downArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
downArrow.SetLineWeight(5);
downArrow.SetDefaultColor(Color.YELLOW);

def bullstop= if barNumber() == HighestAll(bullish2) then low[1] else if barnumber() < HighestAll(bullish2) then double.nan else bullstop[1];
plot bullstopplot = bullstop;
bullstopplot.setdefaultColor(color.dark_green);
AddChartBubble(displayBubblesOnly and barNumber() == HighestAll(bullish2), low[1], "Stop " + astext(low[1]), Color.Dark_Green, no);

def bearstop= if barNumber() == HighestAll(bearish2) then high[1] else if barnumber() < HighestAll(bearish2) then double.nan else bearstop[1];
plot bearstopplot = bearstop;
bearstopplot.setdefaultColor(color.red);
AddChartBubble(displayBubblesOnly and barNumber() == HighestAll(bearish2), high[1], "Stop " + astext(high[1]), Color.red, yes);
 

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
393 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