Looking to draw a line on todays chart that is yesterday's midpoint.
Have coding that create a label but also looking to ad the line on the chart as well. here is the code I have.
**************
input candletype = {default candle, heikinashi};
def HAclose = hlc3;
rec HAopen = CompoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh = Max( high, Max( HAopen, HAclose ) );
def HAlow = Min( low, Min( HAopen, HAclose ) );
plot Data = if candletype == candletype.heikinashi
then (HAhigh + HAlow) / 2
else hl2;
Data.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Data.AssignValueColor(if Data > Data[1] then Color.GREEN else CreateColor(102, 0, 0));
Data.SetLineWeight(5);
def midpoint = data;
Plot Previousbar = data[1];
AddLabel(yes, "prev bar = " + data[1], Color.white );
Plot Currentbar = data;
AddLabel(yes, "Curr bar = " + data, Color.white );
#------------------------------------
# LABEL SECTION
#------------------------------------
#AddLabel(yes,
#if Data[1] < close then “Abv prev Midpoint” else if Data[1] > close then “Below prev Midpoint” else "WAIT", Color.white);
#AddLabel(yes, if midpoint < close then Color.LIGHT_GREEN else if midpoint > close then Color.LIGHT_RED else Color.white);
AddLabel(yes, "Previous Bar", if data[1] < close then Color.LIGHT_GREEN else if data[1] > close then Color.Light_red else Color.WHITE);
AddLabel(yes, "Current Bar", if data < close then Color.light_green else if data > close then Color.LIGHT_RED else Color.WHITE);
Thank you in advance.
Have coding that create a label but also looking to ad the line on the chart as well. here is the code I have.
**************
input candletype = {default candle, heikinashi};
def HAclose = hlc3;
rec HAopen = CompoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh = Max( high, Max( HAopen, HAclose ) );
def HAlow = Min( low, Min( HAopen, HAclose ) );
plot Data = if candletype == candletype.heikinashi
then (HAhigh + HAlow) / 2
else hl2;
Data.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Data.AssignValueColor(if Data > Data[1] then Color.GREEN else CreateColor(102, 0, 0));
Data.SetLineWeight(5);
def midpoint = data;
Plot Previousbar = data[1];
AddLabel(yes, "prev bar = " + data[1], Color.white );
Plot Currentbar = data;
AddLabel(yes, "Curr bar = " + data, Color.white );
#------------------------------------
# LABEL SECTION
#------------------------------------
#AddLabel(yes,
#if Data[1] < close then “Abv prev Midpoint” else if Data[1] > close then “Below prev Midpoint” else "WAIT", Color.white);
#AddLabel(yes, if midpoint < close then Color.LIGHT_GREEN else if midpoint > close then Color.LIGHT_RED else Color.white);
AddLabel(yes, "Previous Bar", if data[1] < close then Color.LIGHT_GREEN else if data[1] > close then Color.Light_red else Color.WHITE);
AddLabel(yes, "Current Bar", if data < close then Color.light_green else if data > close then Color.LIGHT_RED else Color.WHITE);
Thank you in advance.