I'm working on a script for a simple % Absolute Change from Open indicator.
This is the code I use for the Daily timeframe.
def y=round(100*((close/open)-1),2);
plot x=absValue(round(100*((close/open)-1),2));
x.assignValueColor( if y < 0 then color.RED else color.GREEN);
However, I'd like to start at 9:45 am instead of 9:30 am.
----------------------------------------------------------------------------------------
This is what I have so far, but it's showing me the same results.
input StartAggregation= 0945;
input StartPlotTime= 1;
def durationSec = StartPlotTime* 60 * 60;declare upper;
def PlotStartTime = 0945;#Hint PlotStartTime: Adjust begin time to pre/market open
def PlotEndTIme = 1600;#Hint PlotEndTime: Adjust end time to after/market close
#def Set = close(period = AggregationPeriod.DAY, priceType = PriceType.LAST)[1];#Auto grabs last close
def abs = absValue(round(100*((close/open)-1),2));
def CloseTime2 = SecondsTillTime(PlotEndTIme) >= 0;
def OpenTime2 = SecondsFromTime(PlotStartTime) >= 0;
def MarketOpen = OpenTime2 and CloseTime2;
def Chart = MarketOpen;
def secondsPassed = SecondsFromTime(StartPlotTime);
plot x= if chart>0 and startaggregation > 0 and secondsPassed >= 0 and secondsPassed <= durationSec then abs else double.NaN;
x.assignValueColor( if x < 0 then color.RED else color.GREEN);
----------------------
This is another script I've tried but am getting NaN results in the columns
declare lower;
input timeofday = 0945;
input pricetype = {default open, high, low, close};
input method = {Date, default Periods};
###
input Date = 20221104;
###
input periodsback = 0;
def ymd = GetYYYYMMDD();
def candles = !IsNaN(open);
def capture = candles and ymd != ymd[1];
def periodCount = CompoundValue(1, if capture then periodCount[1] + 1 else periodCount[1], 0);
def thisperiod = (HighestAll(periodCount) - periodCount) ;
###
def timewhen = if SecondsTillTime(timeofday)[1] > 0 and
SecondsTillTime(timeofday) <= 0 or
(SecondsTillTime(timeofday)[1] < SecondsTillTime(timeofday) and
SecondsTillTime(timeofday)[1] > 0)
then 1
else 0
;
def pricewhen = if method == method.Periods and
thisperiod == periodsback and
timewhen
then Fundamental(pricetype)
else if method == method.Date and
ymd == Date and
timewhen
then Fundamental(pricetype)
else pricewhen[1];
plot test = if pricewhen then absValue(round(100*((close/open)-1),2))else double.NaN;
Any help would be greatly appreciated!
Thanks!!
This is the code I use for the Daily timeframe.
def y=round(100*((close/open)-1),2);
plot x=absValue(round(100*((close/open)-1),2));
x.assignValueColor( if y < 0 then color.RED else color.GREEN);
However, I'd like to start at 9:45 am instead of 9:30 am.
----------------------------------------------------------------------------------------
This is what I have so far, but it's showing me the same results.
input StartAggregation= 0945;
input StartPlotTime= 1;
def durationSec = StartPlotTime* 60 * 60;declare upper;
def PlotStartTime = 0945;#Hint PlotStartTime: Adjust begin time to pre/market open
def PlotEndTIme = 1600;#Hint PlotEndTime: Adjust end time to after/market close
#def Set = close(period = AggregationPeriod.DAY, priceType = PriceType.LAST)[1];#Auto grabs last close
def abs = absValue(round(100*((close/open)-1),2));
def CloseTime2 = SecondsTillTime(PlotEndTIme) >= 0;
def OpenTime2 = SecondsFromTime(PlotStartTime) >= 0;
def MarketOpen = OpenTime2 and CloseTime2;
def Chart = MarketOpen;
def secondsPassed = SecondsFromTime(StartPlotTime);
plot x= if chart>0 and startaggregation > 0 and secondsPassed >= 0 and secondsPassed <= durationSec then abs else double.NaN;
x.assignValueColor( if x < 0 then color.RED else color.GREEN);
----------------------
This is another script I've tried but am getting NaN results in the columns
declare lower;
input timeofday = 0945;
input pricetype = {default open, high, low, close};
input method = {Date, default Periods};
###
input Date = 20221104;
###
input periodsback = 0;
def ymd = GetYYYYMMDD();
def candles = !IsNaN(open);
def capture = candles and ymd != ymd[1];
def periodCount = CompoundValue(1, if capture then periodCount[1] + 1 else periodCount[1], 0);
def thisperiod = (HighestAll(periodCount) - periodCount) ;
###
def timewhen = if SecondsTillTime(timeofday)[1] > 0 and
SecondsTillTime(timeofday) <= 0 or
(SecondsTillTime(timeofday)[1] < SecondsTillTime(timeofday) and
SecondsTillTime(timeofday)[1] > 0)
then 1
else 0
;
def pricewhen = if method == method.Periods and
thisperiod == periodsback and
timewhen
then Fundamental(pricetype)
else if method == method.Date and
ymd == Date and
timewhen
then Fundamental(pricetype)
else pricewhen[1];
plot test = if pricewhen then absValue(round(100*((close/open)-1),2))else double.NaN;
Any help would be greatly appreciated!
Thanks!!