jonshank62
New member
added show today only to specific time plot it is not exactly working right problem in the arguments that specify when to stop the plot previous plot extends into morning session not sure how to fix it if someone could look at this i would appreciate it
Code:
#plots high and low of defined timeframe.
#Inputs for periodstart and periodend have to be start times for bars of the aggregation period used on chart.
input ShowTodayOnly = yes;
input periodstart = 930;
input periodend = 935;
def activeperiod = If secondsFromTime(periodstart)>=0 and secondsTillTime(periodend)>0 then yes else Double.NaN;
def acriveperiodstartbar = if secondsFromTime(periodstart)==0 then barnumber() else acriveperiodstartbar[1];
def activeperiodendbar = fold i=0 to AbsValue(BarNumber()) while !IsNaN(GetValue(activeperiod,-i)) do GetValue(BarNumber(),-i);
def activeperiodlength = 1+(activeperiodendbar-acriveperiodstartbar);
def Today = if GetDay() == GetLastDay() then 1 else 0;
def activeperiodhigh;
if secondsFromTime(periodstart)==0 {
activeperiodhigh = high;
}else if !IsNaN(activeperiod) and high>=activeperiodhigh[1]{
activeperiodhigh = high;
}else{
activeperiodhigh = activeperiodhigh[1];}
def activeperiodlow;
if secondsFromTime(periodstart)==0 {
activeperiodlow = low;
}else if !IsNaN(activeperiod) and low<=activeperiodlow[1]{
activeperiodlow = low;
}else{
activeperiodlow = activeperiodlow[1];}
def activephigh = fold iah=0 to AbsValue(activeperiodlength) while !IsNaN(activeperiod) do GetValue(activeperiodhigh,-iah);
def activeplow = fold ial=0 to AbsValue(activeperiodlength) while !IsNaN(activeperiod) do GetValue(activeperiodlow,-ial);
def aph = fold iaph = 0 to 1 while !IsNaN(close[10]) do activeperiodhigh;
def apl = fold iapl = 0 to 1 while !IsNaN(close[10]) do activeperiodlow;
plot ActiveHigh =if ShowTodayOnly and !Today then Double.NaN else
if !IsNaN(activeperiod) and activephigh>0 then activephigh else Double.NaN;
ActiveHigh.SetPaintingStrategy(PaintingStrategy.LINE);
ActiveHigh.SetDefaultColor(Color.LIME);
plot ActiveLow = if ShowTodayOnly and !Today then Double.NaN else
if !IsNaN(activeperiod) and activeplow>0 then activeplow else Double.NaN;
ActiveLow.SetPaintingStrategy(PaintingStrategy.LINE);
ActiveLow.SetDefaultColor(Color.PINK);
plot APHigh =if ShowTodayOnly and !Today then Double.NaN else
if IsNaN(activeperiod) and aph>0 then aph else Double.NaN;
APHigh.SetPaintingStrategy(PaintingStrategy.DASHES);
APHigh.SetDefaultColor(Color.LIME);
plot APLow =if ShowTodayOnly and !Today then Double.NaN else
if IsNaN(activeperiod) and apl>0 then apl else Double.NaN;
APLow.SetPaintingStrategy(PaintingStrategy.DASHES);
APLow.SetDefaultColor(Color.PINK);
AddCloud(ActiveHigh,ActiveLow,color.GRAY,color.GRAY);
Last edited by a moderator: