evanevans
Active member
I put the following code together. But I'm having problems getting it to work right. I'm putting it on a 1 minute chart. Is that the issue? How do you check for High of Year on a Minute chart? Any help?
(@Welkin my brother? )
(@Welkin my brother? )
Code:
# ChartAlert New High/Low of Year
# Evan Evans
input PCTnearHOY = 0.09;
input PCTnearLOY = 0.09;
def agg = AggregationPeriod.Day;
#def HOD = Highest(High(period = agg), 1);
def HOY = Highest(High(period = agg), 252);
#def LOD = Lowest(Low(period = agg), 1);
def LOY = Lowest(Low(period = agg), 252);
DefineGlobalColor("isHOY",Color.Green);
DefineGlobalColor("nearHOY",Color.Dark_Green);
DefineGlobalColor("nearLOY",Color.Dark_Red);
DefineGlobalColor("isLOY",Color.Red);
DefineGlobalColor("default",Color.Current);
AssignBackgroundColor(if Close >= HOY then GlobalColor("isHOY")
else if Close >= (HOY*(1-PCTnearHOY)) then GlobalColor("nearHOY")
else if Close <= LOY then GlobalColor("isLOY")
else if Close <= (LOY*(1+PCTnearLOY)) then GlobalColor("nearLOY")
else GlobalColor("default"));