Help with three candle code

SJP07

Member
I'm looking to build a code that captures:

A) Bullish move:
• Three candles
  • First candle is red
  • Second is green and at least twice the size of the first candle
  • Third candle low that is at least a penny greater than the high of the first candle

This code should plot a horizontal line at the high of the first candle that extends all the way to the left of the chart until it's crossed.

B) Bearish move
• Three candles
  • First candle is green
  • Second candle is red and at least twice the size of the first green candle.
  • Third candle high is at least a penny less than the low of the first candle.

This code should plot a horizontal line at the low of the first candle that extends all the way to the left of the chart until it's crossed.


Thanks in advance!!!!!
 
Solution
Still trying to figure out how to get this to only show for the current trading day (pre-market included). Any help?

I included the label code at the bottom of this script. Whatever is currently the make up of the lines for Day are what appears in the labels as far as I can see.

Capture.jpg
Ruby:
###############WEEK###############
def open_week;
def high_week;
def low_week;
def close_week;
def Volume_week;

if GetAggregationPeriod() <= AggregationPeriod.WEEK {
    open_week = open(period = AggregationPeriod.WEEK);
    high_week = high(period = AggregationPeriod.WEEK);
    low_week = low(period = AggregationPeriod.WEEK);
    close_week = close(period = AggregationPeriod.WEEK);
    Volume_week = volume(period =...
Thanks again for all the help coding. I do have another [hopefully simple] request. I'm looking for a label to show only if the bear or bull condition is true for the current trading day. Ideally, I'd like the label to also show the price when the condition is met. Thanks in advance...

AddLabel(Showlabels, "Bulls: " + Concat (cond4, 0), color.uptick);
AddLabel(Showlabels, "Bears: " + Concat (cond4a, 0), color.downtick);
Still trying to figure out how to get this to only show for the current trading day (pre-market included). Any help?
 

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

Still trying to figure out how to get this to only show for the current trading day (pre-market included). Any help?

I included the label code at the bottom of this script. Whatever is currently the make up of the lines for Day are what appears in the labels as far as I can see.

Capture.jpg
Ruby:
###############WEEK###############
def open_week;
def high_week;
def low_week;
def close_week;
def Volume_week;

if GetAggregationPeriod() <= AggregationPeriod.WEEK {
    open_week = open(period = AggregationPeriod.WEEK);
    high_week = high(period = AggregationPeriod.WEEK);
    low_week = low(period = AggregationPeriod.WEEK);
    close_week = close(period = AggregationPeriod.WEEK);
    Volume_week = volume(period = AggregationPeriod.WEEK);
} else {
    open_week = Double.NaN;
    high_week = Double.NaN;
    low_week = Double.NaN;
    close_week = Double.NaN;
    Volume_week = Double.NaN;
}

###############DAY###############

def open_day;
def high_day;
def low_day;
def close_day;
def Volume_day;

if GetAggregationPeriod() <= AggregationPeriod.DAY {
    open_day = open(period = AggregationPeriod.DAY);
    high_day = high(period = AggregationPeriod.DAY);
    low_day = low(period = AggregationPeriod.DAY);
    close_day = close(period = AggregationPeriod.DAY);
    Volume_day = volume(period = AggregationPeriod.DAY);
} else {
    open_day = Double.NaN;
    high_day = Double.NaN;
    low_day = Double.NaN;
    close_day = Double.NaN;
    Volume_day = Double.NaN;
}


###############4HR###############

def open_four_hours;
def high_four_hours;
def low_four_hours;
def close_four_hours;
def Volume_four_hours;

if GetAggregationPeriod() <= AggregationPeriod.FOUR_HOURS {
    open_four_hours = open(period = AggregationPeriod.FOUR_HOURS);
    high_four_hours = high(period = AggregationPeriod.FOUR_HOURS);
    low_four_hours = low(period = AggregationPeriod.FOUR_HOURS);
    close_four_hours = close(period = AggregationPeriod.FOUR_HOURS);
    Volume_four_hours = volume(period = AggregationPeriod.FOUR_HOURS);
} else {
    open_four_hours = Double.NaN;
    high_four_hours = Double.NaN;
    low_four_hours = Double.NaN;
    close_four_hours = Double.NaN;
    Volume_four_hours = Double.NaN;
}

###############2HR###############

def open_two_hours;
def high_two_hours;
def low_two_hours;
def close_two_hours;
def Volume_two_hours;

if GetAggregationPeriod() <= AggregationPeriod.TWO_HOURS {
    open_two_hours = open(period = AggregationPeriod.TWO_HOURS);
    high_two_hours = high(period = AggregationPeriod.TWO_HOURS);
    low_two_hours = low(period = AggregationPeriod.TWO_HOURS);
    close_two_hours = close(period = AggregationPeriod.TWO_HOURS);
    Volume_two_hours = volume(period = AggregationPeriod.TWO_HOURS);
} else {
    open_two_hours = Double.NaN;
    high_two_hours = Double.NaN;
    low_two_hours = Double.NaN;
    close_two_hours = Double.NaN;
    Volume_two_hours = Double.NaN;
}
###############1HR###############

def open_hour;
def high_hour;
def low_hour;
def close_hour;
def Volume_hour;

if GetAggregationPeriod() <= AggregationPeriod.HOUR {
    open_hour = open(period = AggregationPeriod.HOUR);
    high_hour = high(period = AggregationPeriod.HOUR);
    low_hour = low(period = AggregationPeriod.HOUR);
    close_hour = close(period = AggregationPeriod.HOUR);
    Volume_hour = volume(period = AggregationPeriod.HOUR);
} else {
    open_hour = Double.NaN;
    high_hour = Double.NaN;
    low_hour = Double.NaN;
    close_hour = Double.NaN;
    Volume_hour = Double.NaN;
}
###############30Min###############

def open_thirty_min;
def high_thirty_min;
def low_thirty_min;
def close_thirty_min;
def Volume_thirty_min;

if GetAggregationPeriod() <= AggregationPeriod.THIRTY_MIN {
    open_thirty_min = open(period = AggregationPeriod.THIRTY_MIN);
    high_thirty_min = high(period = AggregationPeriod.THIRTY_MIN);
    low_thirty_min = low(period = AggregationPeriod.THIRTY_MIN);
    close_thirty_min = close(period = AggregationPeriod.THIRTY_MIN);
    Volume_thirty_min = volume(period = AggregationPeriod.THIRTY_MIN);
} else {
    open_thirty_min = Double.NaN;
    high_thirty_min = Double.NaN;
    low_thirty_min = Double.NaN;
    close_thirty_min = Double.NaN;
    Volume_thirty_min = Double.NaN;
}

###############15Min###############

def open_fifteen_min;
def high_fifteen_min;
def low_fifteen_min;
def close_fifteen_min;
def Volume_fifteen_min;
if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN {
    open_fifteen_min = open(period = AggregationPeriod.FIFTEEN_MIN);
    high_fifteen_min = high(period = AggregationPeriod.FIFTEEN_MIN);
    low_fifteen_min = low(period = AggregationPeriod.FIFTEEN_MIN);
    close_fifteen_min = close(period = AggregationPeriod.FIFTEEN_MIN);
    Volume_fifteen_min = volume(period = AggregationPeriod.FIFTEEN_MIN);
} else {
    open_fifteen_min = Double.NaN;
    high_fifteen_min = Double.NaN;
    low_fifteen_min = Double.NaN;
    close_fifteen_min = Double.NaN;
    Volume_fifteen_min = Double.NaN;
}

########################WEEK CODE###########################

def cond1W = close_week[2] < open_week[2];
def cond2W = close_week[1] > open_week[1] and (high_week[1] - low_week[1]) > (high_week[2] - low_week[2]) * 2;
def cond3W = low_week > high_week[2] + .01;
def cond4W = if IsNaN(close_week)
then cond4W[1]
else if cond1W && cond2W && cond3W
then high_week[2]
else cond4W[1];
plot Week_bull = cond4W;
Week_bull.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Week_bull.SetDefaultColor(Color.LIGHT_GREEN);

def cond1Wa = close_week[2] > open_week[2];
def cond2Wa = close_week[1] < open_week[1] and (high_week[1] - low_week[1]) > (high_week[2] - low_week[2]) * 2;
def cond3Wa = high_week < low_week[2] - .01;
def cond4Wa = if IsNaN(close_week)
then cond4W[1]
else if cond1Wa && cond2Wa && cond3Wa
then low_week[2]
else cond4Wa[1];

plot Week_bear = cond4Wa;
Week_bear.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Week_bear.SetDefaultColor(Color.PINK);

AddChartBubble(Week_bull <> Week_bull[1], Week_bull, Concat("W= $", Week_bull), Color.ORANGE);

AddChartBubble(Week_bear <> Week_bear[1], Week_bear, Concat("W = $", Week_bear), Color.ORANGE);

########################DAY CODE###########################
def cond1D = close_day[2] < open_day[2];
def cond2D = close_day[1] > open_day[1] and (high_day[1] - low_day[1]) > (high_day[2] - low_day[2]) * 2;
def cond3D = low_day > high_day[2] + .01;
def cond4D = if IsNaN(close_day)
then cond4D[1]
else if cond1D && cond2D && cond3D
then high_day[2]
else cond4D[1];
plot Day_bull = cond4D;
Day_bull.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Day_bull.SetDefaultColor(Color.LIGHT_GREEN);

def cond1Da = close_day[2] > open_day[2];
def cond2Da = close_day[1] < open_day[1] and (high_day[1] - low_day[1]) > (high_day[2] - low_day[2]) * 2;
def cond3Da = high_day < low_day[2] - .01;
def cond4Da = if IsNaN(close_day)
then cond4D[1]
else if cond1Da && cond2Da && cond3Da
then low_day[2]
else cond4Da[1];

plot Day_bear = cond4Da;
Day_bear.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Day_bear.SetDefaultColor(Color.PINK);


AddChartBubble(Day_bull <> Day_bull[1], Day_bull, Concat("D= $", Day_bull), Color.ORANGE);
AddChartBubble(Day_bear <> Day_bear[1], Day_bear, Concat("D = $", Day_bear), Color.ORANGE);

#######################FOUR HOUR CODE###########################
def cond1_4H = close_four_hours[2] < open_four_hours[2];
def cond2_4H = close_four_hours[1] > open_four_hours[1] and (high_four_hours[1] - low_four_hours[1]) > (high_four_hours[2] - low_four_hours[2]) * 2;
def cond3_4H = low_four_hours > high_four_hours[2] + .01;
def cond4_4H = if IsNaN(close_four_hours)
then cond4_4H[1]
else if cond1_4H && cond2_4H && cond3_4H
then high_four_hours[2]
else cond4_4H[1];
plot Four_hours_bull = cond4_4H;
Four_hours_bull.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Four_hours_bull.SetDefaultColor(Color.LIGHT_GREEN);

def cond1_4Ha = close_four_hours[2] > open_four_hours[2];
def cond2_4Ha = close_four_hours[1] < open_four_hours[1] and (high_four_hours[1] - low_four_hours[1]) > (high_four_hours[2] - low_four_hours[2]) * 2;
def cond3_4Ha = high_four_hours < low_four_hours[2] - .01;
def cond4_4Ha = if IsNaN(close_four_hours)
then cond4_4H[1]
else if cond1_4Ha && cond2_4Ha && cond3_4Ha
then low_four_hours[2]
else cond4_4Ha[1];

plot Four_hours_bear = cond4_4Ha;
Four_hours_bear.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Four_hours_bear.SetDefaultColor(Color.PINK);


AddChartBubble(Four_hours_bull <> Four_hours_bull[1], Four_hours_bull, Concat("4H= $", Four_hours_bull), Color.ORANGE);
AddChartBubble(Four_hours_bear <> Four_hours_bear[1], Four_hours_bear, Concat("4H = $", Four_hours_bear), Color.ORANGE);

#######################TWO HOUR CODE###########################
def cond1_2_2H = close_two_hours[2] < open_two_hours[2];
def cond2_2H = close_two_hours[1] > open_two_hours[1] and (high_two_hours[1] - low_two_hours[1]) > (high_two_hours[2] - low_two_hours[2]) * 2;
def cond3_2H = low_two_hours > high_two_hours[2] + .01;
def cond4_2H = if IsNaN(close_two_hours)
then cond4_2H[1]
else if cond1_2_2H && cond2_2H && cond3_2H
then high_two_hours[2]
else cond4_2H[1];
plot Two_Hours_bull = cond4_2H;
Two_Hours_bull.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Two_Hours_bull.SetDefaultColor(Color.LIGHT_GREEN);

def cond1_2_2Ha = close_two_hours[2] > open_two_hours[2];
def cond2_2Ha = close_two_hours[1] < open_two_hours[1] and (high_two_hours[1] - low_two_hours[1]) > (high_two_hours[2] - low_two_hours[2]) * 2;
def cond3_2Ha = high_two_hours < low_two_hours[2] - .01;
def cond4_2Ha = if IsNaN(close_two_hours)
then cond4_2Ha[1]
else if cond1_2_2Ha && cond2_2Ha && cond3_2Ha
then low_two_hours[2]
else cond4_2Ha[1];

plot Two_Hours_bear = cond4_2Ha;
Two_Hours_bear.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Two_Hours_bear.SetDefaultColor(Color.PINK);

AddChartBubble(Two_Hours_bull <> Two_Hours_bull[1], Two_Hours_bull, Concat("2H= $", Two_Hours_bull), Color.ORANGE);
AddChartBubble(Two_Hours_bear <> Two_Hours_bear[1], Two_Hours_bear, Concat("2H = $", Two_Hours_bear), Color.ORANGE);


#######################HOUR CODE###########################

def cond1H = close_hour[2] < open_hour[2];
def cond2H = close_hour[1] > open_hour[1] and (high_hour[1] - low_hour[1]) > (high_hour[2] - low_hour[2]) * 2;
def cond3H = low_hour > high_hour[2] + .01;
def cond4H = if IsNaN(close_hour)
then cond4H[1]
else if cond1H && cond2H && cond3H
then high_hour[2]
else cond4H[1];
plot Hour_bull = cond4H;
Hour_bull.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Hour_bull.SetDefaultColor(Color.LIGHT_GREEN);

def cond1Ha = close_hour[2] > open_hour[2];
def cond2Ha = close_hour[1] < open_hour[1] and (high_hour[1] - low_hour[1]) > (high_hour[2] - low_hour[2]) * 2;
def cond3Ha = high_hour < low_hour[2] - .01;
def cond4Ha = if IsNaN(close_hour)
then cond4Ha[1]
else if cond1Ha && cond2Ha && cond3Ha
then low_hour[2]
else cond4Ha[1];

plot Hour_bear = cond4Ha;
Hour_bear.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Hour_bear.SetDefaultColor(Color.PINK);

AddChartBubble(Hour_bull <> Hour_bull[1], Hour_bull, Concat("H= $", Hour_bull), Color.ORANGE);
AddChartBubble(Hour_bear <> Hour_bear[1], Hour_bear, Concat("H = $", Hour_bear), Color.ORANGE);

#######################30 MIN CODE###########################
def cond1_30M = close_thirty_min[2] < open_thirty_min[2];
def cond2_30M = close_thirty_min[1] > open_thirty_min[1] and (high_thirty_min[1] - low_thirty_min[1]) > (high_thirty_min[2] - low_thirty_min[2]) * 2;
def cond3_30M = low_thirty_min > high_thirty_min[2] + .01;
def cond4_30M = if IsNaN(close_thirty_min)
then cond4_30M[1]
else if cond1_30M && cond2_30M && cond3_30M
then high_thirty_min[2]
else cond4_30M[1];
plot Thirty_min_bull = cond4_30M;
Thirty_min_bull.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#Thirty_min_bull.SetDefaultColor(Color.Light_green);

def cond1_30Ma = close_thirty_min[2] > open_thirty_min[2];
def cond2_30Ma = close_thirty_min[1] < open_thirty_min[1] and (high_thirty_min[1] - low_thirty_min[1]) > (high_thirty_min[2] - low_thirty_min[2]) * 2;
def cond3_30Ma = high_thirty_min < low_thirty_min[2] - .01;
def cond4_30Ma = if IsNaN(close_thirty_min)
then cond4_30M[1]
else if cond1_30Ma && cond2_30Ma && cond3_30Ma
then low_thirty_min[2]
else cond4_30Ma[1];

plot Thirty_min_bear = cond4_30Ma;
Thirty_min_bear.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#Thirty_min_bear.SetDefaultColor(Color.Pink);

AddChartBubble(Thirty_min_bull <> Thirty_min_bull[1], Thirty_min_bull, Concat("30M= $", Thirty_min_bull), Color.ORANGE);
AddChartBubble(Thirty_min_bear <> Thirty_min_bear[1], Thirty_min_bear, Concat("30M = $", Thirty_min_bear), Color.ORANGE);

#######################15 MIN CODE###########################

def cond1_15M = close_fifteen_min[2] < open_fifteen_min[2];
def cond2_15M = close_fifteen_min[1] > open_fifteen_min[1] and (high_fifteen_min[1] - low_fifteen_min[1]) > (high_fifteen_min[2] - low_fifteen_min[2]) * 2;
def cond3_15M = low_fifteen_min > high_fifteen_min[2] + .01;
def cond4_15M = if IsNaN(close_fifteen_min)
then cond4_15M[1]
else if cond1_15M && cond2_15M && cond3_15M
then high_fifteen_min[2]
else cond4_15M[1];
plot Fifteen_min_bull = cond4_15M;
Fifteen_min_bull.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#Fifteen_min_bull.SetDefaultColor(Color.Light_green);

def cond1_15Ma = close_fifteen_min[2] > open_fifteen_min[2];
def cond2_15Ma = close_fifteen_min[1] < open_fifteen_min[1] and (high_fifteen_min[1] - low_fifteen_min[1]) > (high_fifteen_min[2] - low_fifteen_min[2]) * 2;
def cond3_15Ma = high_fifteen_min < low_fifteen_min[2] - .01;
def cond4_15Ma = if IsNaN(close_fifteen_min)
then cond4_15M[1]
else if cond1_15Ma && cond2_15Ma && cond3_15Ma
then low_fifteen_min[2]
else cond4_15Ma[1];

plot Fifteen_min_bear = cond4_15Ma;
Fifteen_min_bear.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#Fifteen_min_bear.SetDefaultColor(Color.Pink);

AddChartBubble(Fifteen_min_bull <> Fifteen_min_bull[1], Fifteen_min_bull, Concat("15M= $", Fifteen_min_bull), Color.ORANGE);
AddChartBubble(Fifteen_min_bear <> Fifteen_min_bear[1], Fifteen_min_bear, Concat("15M = $", Fifteen_min_bear), Color.ORANGE);

input labels = yes;
AddLabel(labels, "Bulls: " + Round(cond4D), Color.UPTICK);
AddLabel(labels, "Bears: " + Round(cond4Da), Color.DOWNTICK);
 
Solution
Help writing a scan code
I need help writing a scan script for this code.

I would like to be able to receive an alert when close is equal to or between the high and the low of the candles with arrows. Thank you so much in advance!

Here's a image for context:

OAMkpRX.png


CODE BELOW

Code:
input ShowArrows = yes;
################################################################################
################################################################################

def cond1 = close[2] < open[2];
#def cond2 = close[1] > open[1] and (high[1] - low[1]) > (high[2] - low[2]) * 2;
def cond2 = close[1] > open[1] and (high[1] - low[1]) > (high[2] - low[2]);
def cond3 = low > high[2] + .01;
def cond4 = if isnan(close)
            then cond4[1]
            else if cond1 && cond2 && cond3
            then high[2]
            else cond4[1];
def bull = cond4;

################################################################################
################################################################################

def cond1a = close[2] > open[2];
#def cond2a = close[1] < open[1] and (high[1] - low[1]) > (high[2] - low[2]) * 2;
def cond2a = close[1] < open[1] and (high[1] - low[1]) > (high[2] - low[2]);
def cond3a = high < low[2] - .01;
def cond4a = if isnan(close)
            then cond4a[1]
            else if cond1a && cond2a && cond3a
            then low[2]
            else cond4a[1];

def bear = cond4a;

################################################################################
################################################################################

def bullish_imbalance = cond1 && cond2 && cond3;
Plot Demand_Created = ShowArrows && bullish_imbalance[-2];
Demand_Created.SetLineWeight(2);
Demand_Created.SetDefaultColor(Color.Cyan);
Demand_Created.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Demand_Created.Hide();

def bearish_imbalance = cond1a && cond2a && cond3a;
Plot Supply_Created = ShowArrows && bearish_imbalance[-2];
Supply_Created.SetLineWeight(2);
Supply_Created.SetDefaultColor(Color.Cyan);
Supply_Created.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#Supply_Created.Hide();


###############################################################################
 
Last edited by a moderator:
Help writing a scan code
I need help writing a scan script for this code.

I would like to be able to receive an alert when close is equal to or between the high and the low of the candles with arrows. Thank you so much in advance!

Here's a image for context:
CODE BELOW

input ShowArrows = yes;
################################################################################
################################################################################

def cond1 = close[2] < open[2];
#def cond2 = close[1] > open[1] and (high[1] - low[1]) > (high[2] - low[2]) * 2;
def cond2 = close[1] > open[1] and (high[1] - low[1]) > (high[2] - low[2]);
def cond3 = low > high[2] + .01;
def cond4 = if isnan(close)
then cond4[1]
else if cond1 && cond2 && cond3
then high[2]
else cond4[1];
def bull = cond4;

################################################################################
################################################################################

def cond1a = close[2] > open[2];
#def cond2a = close[1] < open[1] and (high[1] - low[1]) > (high[2] - low[2]) * 2;
def cond2a = close[1] < open[1] and (high[1] - low[1]) > (high[2] - low[2]);
def cond3a = high < low[2] - .01;
def cond4a = if isnan(close)
then cond4a[1]
else if cond1a && cond2a && cond3a
then low[2]
else cond4a[1];

def bear = cond4a;

################################################################################
################################################################################

def bullish_imbalance = cond1 && cond2 && cond3;
Plot Demand_Created = ShowArrows && bullish_imbalance[-2];
Demand_Created.SetLineWeight(2);
Demand_Created.SetDefaultColor(Color.Cyan);
Demand_Created.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Demand_Created.Hide();

def bearish_imbalance = cond1a && cond2a && cond3a;
Plot Supply_Created = ShowArrows && bearish_imbalance[-2];
Supply_Created.SetLineWeight(2);
Supply_Created.SetDefaultColor(Color.Cyan);
Supply_Created.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#Supply_Created.Hide();


###############################################################################
Does this repaint?
 
Found this code asking for a plot don't know what it is:
Ruby:
input ShowArrows = yes;
################################################################################
################################################################################

def cond1 = close[2] < open[2];
#def cond2 = close[1] > open[1] and (high[1] - low[1]) > (high[2] - low[2]) * 2;
def cond2 = close[1] > open[1] and (high[1] - low[1]) > (high[2] - low[2]);
def cond3 = low > high[2] + .01;
def cond4 = if isnan(close)
            then cond4[1]
            else if cond1 && cond2 && cond3
            then high[2]
            else cond4[1];
def bull = cond4;

################################################################################
################################################################################

def cond1a = close[2] > open[2];
#def cond2a = close[1] < open[1] and (high[1] - low[1]) > (high[2] - low[2]) * 2;
def cond2a = close[1] < open[1] and (high[1] - low[1]) > (high[2] - low[2]);
def cond3a = high < low[2] - .01;
def cond4a = if isnan(close)
            then cond4a[1]
            else if cond1a && cond2a && cond3a
            then low[2]
            else cond4a[1];

def bear = cond4a;

################################################################################
################################################################################

def bullish_imbalance = cond1 && cond2 && cond3;
Plot Demand_Created = ShowArrows && bullish_imbalance[-2];
Demand_Created.SetLineWeight(2);
Demand_Created.SetDefaultColor(Color.Cyan);
Demand_Created.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Demand_Created.Hide();

def bearish_imbalance = cond1a && cond2a && cond3a;
Plot Supply_Created = ShowArrows && bearish_imbalance[-2];
Supply_Created.SetLineWeight(2);
Supply_Created.SetDefaultColor(Color.Cyan);
Supply_Created.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#Supply_Created.Hide();


###############################################################################
 
Found this code asking for a plot don't know what it is:
Ruby:
input ShowArrows = yes;
################################################################################
################################################################################

def cond1 = close[2] < open[2];
#def cond2 = close[1] > open[1] and (high[1] - low[1]) > (high[2] - low[2]) * 2;
def cond2 = close[1] > open[1] and (high[1] - low[1]) > (high[2] - low[2]);
def cond3 = low > high[2] + .01;
def cond4 = if isnan(close)
            then cond4[1]
            else if cond1 && cond2 && cond3
            then high[2]
            else cond4[1];
def bull = cond4;

################################################################################
################################################################################

def cond1a = close[2] > open[2];
#def cond2a = close[1] < open[1] and (high[1] - low[1]) > (high[2] - low[2]) * 2;
def cond2a = close[1] < open[1] and (high[1] - low[1]) > (high[2] - low[2]);
def cond3a = high < low[2] - .01;
def cond4a = if isnan(close)
            then cond4a[1]
            else if cond1a && cond2a && cond3a
            then low[2]
            else cond4a[1];

def bear = cond4a;

################################################################################
################################################################################

def bullish_imbalance = cond1 && cond2 && cond3;
Plot Demand_Created = ShowArrows && bullish_imbalance[-2];
Demand_Created.SetLineWeight(2);
Demand_Created.SetDefaultColor(Color.Cyan);
Demand_Created.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Demand_Created.Hide();

def bearish_imbalance = cond1a && cond2a && cond3a;
Plot Supply_Created = ShowArrows && bearish_imbalance[-2];
Supply_Created.SetLineWeight(2);
Supply_Created.SetDefaultColor(Color.Cyan);
Supply_Created.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#Supply_Created.Hide();


###############################################################################
It appears to have plots.
https://usethinkscript.com/threads/help-with-three-candle-code.12427/page-2#post-117151

@QUIKTDR1 @SJP07
However, you can't scan for the plots as they use future bars so the scans can't find them in real time. They are repainted on previous candles; afterwards.

It appears to find entry and exit
tnVatvd.png
 
Last edited:

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