Cribbage
Member
I'm trying to get the opening price of the hourly extend right for two hours and keep a single color. I chopped up one of PelonSax's codes and added a displacer thinking this would work. Only problem is that on lower time frames, the displacer uses the opening price of the lower timeframe so the extensions change colors.
In other words, on the Hourly timeframe, the script works properly, but on the 5min time frame, the first plot follows the color I want it to, but the second plot may sometimes change.
If anyone can help it would be appreciated.
In other words, on the Hourly timeframe, the script works properly, but on the 5min time frame, the first plot follows the color I want it to, but the second plot may sometimes change.
If anyone can help it would be appreciated.
Code:
#-----------------------------------------------------
#
# S I M P L E
# C A N D L E O V E R L A Y
#
# Open line red/green for visualizing FTC
#
#
# a STRAT study by Ramon DV. aka Pelonsax
# based on Rob Smith's The STRAT
# Original Candle Overlay concept by Paul Townsend
#
#-----------------------------------------------------
DECLARE UPPER;
#------------------------------------
# MTF SECTION
#------------------------------------
###6/14/24 Cribbage added code to help identify OB opening price, marked below
input AddOutline = no;
input Time_Frame = AggregationPeriod.FIFTEEN_MIN;
plot H = high(period = Time_Frame);
H.setDefaultColor(color.gray);
H.setHiding(!AddOutline);
plot L = low(period = Time_Frame);
L.setDefaultColor(color.gray);
L.setHiding(!AddOutline);
def O = open(period = Time_Frame);
def C = close(period = Time_Frame);
plot zeroline = O;
zeroline.AssignValueColor(if C > O then color.red else if C < O then color.green else color.white);
zeroline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zeroline.setlineWeight(2);
###Cribbage
input displaceLength = 1;
plot Displacer = zeroline[displaceLength];
displacer.AssignValueColor(if C[displacelength] > O[displacelength] then color.red else if C[displacelength] < O[displacelength] then color.green else color.white);
displacer.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
displacer.setlineWeight(2);
###Cribbage End
# ADD LABEL
#------------------------------------
input Show_Label = yes;
AddLabel(Show_Label, Concat(if Time_Frame < 3600000 then Time_Frame / 60000 + "m" else if Time_Frame < 86400000 then Time_Frame / 3600000 + "h" else if Time_Frame < 604800000 then Time_Frame / 86400000 + "D" else if Time_Frame < 2592000000 then Time_Frame / 604800000 + "Wk" else if Time_Frame < 31536000000 then Time_Frame / 2592000000 + "Mo" else Time_Frame / 31536000000 + "Yr", if Time_Frame then " CANDLES" else ""), Color.light_Gray);
# end