Greetings All,
I have a question about the Accumulation Distribution Divergence indicator developed by @BenTen .
https://usethinkscript.com/threads/accumulation-distribution-divergence-for-thinkorswim.1546/
Thanks, Ben, for the awesome indicator. I was trying to make some edits to the code. The code indicates that the start time is 9:30, but the end time is the final hour of trading. I was wondering if I could make a code that suggests an end time of 4:00 p.m. I have tried to edit like the following but could not land to a definite solution,
I was wondering if anyone could please help with how to make it calculate and plot until 4:00 p.m. Also, the plot for the next day doesn't appear until 9:30 a.m. Is it possible to see the next day's plot on the previous day. Can the same be made for a "daily chart"? If so, please share the solution.
Thank you,
Shakib
I have a question about the Accumulation Distribution Divergence indicator developed by @BenTen .
https://usethinkscript.com/threads/accumulation-distribution-divergence-for-thinkorswim.1546/
Thanks, Ben, for the awesome indicator. I was trying to make some edits to the code. The code indicates that the start time is 9:30, but the end time is the final hour of trading. I was wondering if I could make a code that suggests an end time of 4:00 p.m. I have tried to edit like the following but could not land to a definite solution,
Ruby:
#
# Accumulation_Distribution_Divergence
# Assembled by Kory Gill (@korygill) for BenTen at usethinkscript.com
#
declare lower;
declare once_per_bar;
input OpenTime = 0930;
input Endtime = 1600;
def startcounter = SecondsFromTime(OpenTime);
def endcounter = SecondsFromTime(Endtime);
def bn = BarNumber();
def nan = Double.NaN;
def sft = SecondsFromTime(OpenTime);
def cet = SecondsFromTime(Endtime);
def targetperiod = if sft >= 0 and cet >= 0 then 1 else 0;
# plot p1 = sft;
def data = if close > close[1] then close - Min(close[1], low) else if close < close[1] then close - Max(close[1], high) else 0;
def SumData = if bn == 1 then data else SumData[1] + data;
def ADBP = SumData;
# dont use built in function, it's slow. Avoid calling TotalSum on each subsequent bar.
# def ADBP = AccumDistBuyPr().AccDist;
def hVal;
def lVal;
if bn == 1
then
{
hVal = nan;
lVal = nan;
}
else if bn == 2
then
{
hVal = ADBP;
lVal = ADBP;
}
else
{
if targetperiod == 0
then
{
hVal = ADBP;
lVal = ADBP;
}
else
{
hVal = Max(hVal[1], ADBP);
lVal = Min(lVal[1], ADBP);
}
}
def pdh = if targetperiod and !targetperiod[1] then hVal else pdh[1];
def pdl = if targetperiod and !targetperiod[1] then lVal else pdl[1];
def pdm = 0.5 * (pdh + pdl);
plot ppdh = pdh;
plot ppdl = pdl;
plot ppdm = pdm;
ppdh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ppdl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ppdm.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ppdh.SetDefaultColor(GetColor(1));
ppdl.SetDefaultColor(GetColor(0));
ppdm.SetDefaultColor(GetColor(9));
#plot ph = hVal;
#plot pl = lVal;
plot pADBP = ADBP; "
I was wondering if anyone could please help with how to make it calculate and plot until 4:00 p.m. Also, the plot for the next day doesn't appear until 9:30 a.m. Is it possible to see the next day's plot on the previous day. Can the same be made for a "daily chart"? If so, please share the solution.
Thank you,
Shakib
Last edited by a moderator: