OPEN-SOURCE SCRIPT
papa experiment

//version=6
indicator("Edufx AMD", shorttitle="Edufx AMD", overlay=true)
// ───── Inputs ─────
timezone = input.string("America/New_York", "Timezone")
enableDailyCycles = input.bool(true, "Enable Daily Cycles")
colorAcc = input.color(color.new(color.gray, 80), "Accumulation")
colorManip = input.color(color.new(color.red, 80), "Manipulation")
colorDist = input.color(color.new(color.green, 80), "Distribution")
// ───── Daily Anchor (NY 8PM) ─────
var int dayStart = na
if na(dayStart) or time >= dayStart + 86400000
dayStart := timestamp(timezone, year, month, dayofmonth, 20, 0)
accEnd = dayStart + 9 * 60 * 60 * 1000
manEnd = dayStart + 15 * 60 * 60 * 1000
distEnd = dayStart + 24 * 60 * 60 * 1000
// ───── State ─────
var float accLo = na
var float accHi = na
var float manLo = na
var float manHi = na
var float disLo = na
var float disHi = na
var bool accDone = false
var bool manDone = false
var bool disDone = false
// ───── Daily AMD ─────
if enableDailyCycles
// Accumulation
if time >= dayStart and time < accEnd
accLo := na(accLo) ? low : math.min(accLo, low)
accHi := na(accHi) ? high : math.max(accHi, high)
if time >= accEnd and not accDone and not na(accLo)
box.new(dayStart, accHi, accEnd, accLo,
xloc=xloc.bar_time, bgcolor=colorAcc, border_color=colorAcc)
accDone := true
// Manipulation
if time >= accEnd and time < manEnd
manLo := na(manLo) ? low : math.min(manLo, low)
manHi := na(manHi) ? high : math.max(manHi, high)
if time >= manEnd and not manDone and not na(manLo)
box.new(accEnd, manHi, manEnd, manLo,
xloc=xloc.bar_time, bgcolor=colorManip, border_color=colorManip)
manDone := true
// Distribution
if time >= manEnd and time < distEnd
disLo := na(disLo) ? low : math.min(disLo, low)
disHi := na(disHi) ? high : math.max(disHi, high)
if time >= distEnd and not disDone and not na(disLo)
box.new(manEnd, disHi, distEnd, disLo,
xloc=xloc.bar_time, bgcolor=colorDist, border_color=colorDist)
disDone := true
// Reset
if time >= distEnd
accLo := na
accHi := na
manLo := na
manHi := na
disLo := na
disHi := na
accDone := false
manDone := false
disDone := false
indicator("Edufx AMD", shorttitle="Edufx AMD", overlay=true)
// ───── Inputs ─────
timezone = input.string("America/New_York", "Timezone")
enableDailyCycles = input.bool(true, "Enable Daily Cycles")
colorAcc = input.color(color.new(color.gray, 80), "Accumulation")
colorManip = input.color(color.new(color.red, 80), "Manipulation")
colorDist = input.color(color.new(color.green, 80), "Distribution")
// ───── Daily Anchor (NY 8PM) ─────
var int dayStart = na
if na(dayStart) or time >= dayStart + 86400000
dayStart := timestamp(timezone, year, month, dayofmonth, 20, 0)
accEnd = dayStart + 9 * 60 * 60 * 1000
manEnd = dayStart + 15 * 60 * 60 * 1000
distEnd = dayStart + 24 * 60 * 60 * 1000
// ───── State ─────
var float accLo = na
var float accHi = na
var float manLo = na
var float manHi = na
var float disLo = na
var float disHi = na
var bool accDone = false
var bool manDone = false
var bool disDone = false
// ───── Daily AMD ─────
if enableDailyCycles
// Accumulation
if time >= dayStart and time < accEnd
accLo := na(accLo) ? low : math.min(accLo, low)
accHi := na(accHi) ? high : math.max(accHi, high)
if time >= accEnd and not accDone and not na(accLo)
box.new(dayStart, accHi, accEnd, accLo,
xloc=xloc.bar_time, bgcolor=colorAcc, border_color=colorAcc)
accDone := true
// Manipulation
if time >= accEnd and time < manEnd
manLo := na(manLo) ? low : math.min(manLo, low)
manHi := na(manHi) ? high : math.max(manHi, high)
if time >= manEnd and not manDone and not na(manLo)
box.new(accEnd, manHi, manEnd, manLo,
xloc=xloc.bar_time, bgcolor=colorManip, border_color=colorManip)
manDone := true
// Distribution
if time >= manEnd and time < distEnd
disLo := na(disLo) ? low : math.min(disLo, low)
disHi := na(disHi) ? high : math.max(disHi, high)
if time >= distEnd and not disDone and not na(disLo)
box.new(manEnd, disHi, distEnd, disLo,
xloc=xloc.bar_time, bgcolor=colorDist, border_color=colorDist)
disDone := true
// Reset
if time >= distEnd
accLo := na
accHi := na
manLo := na
manHi := na
disLo := na
disHi := na
accDone := false
manDone := false
disDone := false
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.