Hello all,
Trying to write a script with the following conditions:
1. Find a Green bar.
2. Find a Topping Tail Red bar with a higher high and higher low in any 15 bars after condition 1 is met.
3. If both conditions are met, then draw a red arrow on any 20 bars after the 2nd condition is met that makes a lower low (trades below the low of the Topping Tail Red bar).
Is it possible to write a working script for the conditions mentioned above?
I tried Chatgpt but getting errors (please see code).
Any help with this is appreciated.
Thank you in advance.
Trying to write a script with the following conditions:
1. Find a Green bar.
2. Find a Topping Tail Red bar with a higher high and higher low in any 15 bars after condition 1 is met.
3. If both conditions are met, then draw a red arrow on any 20 bars after the 2nd condition is met that makes a lower low (trades below the low of the Topping Tail Red bar).
Is it possible to write a working script for the conditions mentioned above?
I tried Chatgpt but getting errors (please see code).
Any help with this is appreciated.
Thank you in advance.
Code:
# Define Green Candle Conditions
def isGreenBar = close > open;
# Define Topping Tail Red Candle Conditions
def isToppingTailRed = close < open
and high - open > close - low;
# Initialize variables to track Green and Topping Tail Red Candles
def greenBar = 0;
def toppingTailBar = 0;
# Find Green Bar
if isGreenBar {
greenBar = 1 else;
}
# Find Topping Tail Red Bar with Higher High and Higher Low within the next 15 bars
for i = 1 to 15 {
if isToppingTailRed
and high > high[i]
and low < low[i] {
toppingTailBar = i;
break;
}
}
# Initialize variables to track the lower low condition
def lowerLowBar = -1;
# Find a bar with a lower low within the next 20 bars after the Topping Tail Red Bar
if toppingTailBar > 0 {
for j = 1 to 20 {
if low < low[toppingTailBar] {
lowerLowBar = j;
break;
}
}
}
# Draw a Red Arrow with "Sell" When the Lower Low Condition Is Met
def sellCondition = greenBar > 0 and toppingTailBar > 0 and lowerLowBar > 0;
plot sellSignal = if sellCondition then low else double.nan;
sellSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
sellSignal.SetDefaultColor(Color.RED);
AddLabel(yes, "Sell", Color.RED);