# Emini Addict # Half Gap Fill, Full Gap Fill, and # Trading Hours only Pivot Point (9:30a - 4:00p). # This study is intended for the 15 minute chart only. # No warranties or guarantees. Modify at your own risk. # $V:build_1324:2009.05.09:1.0.3 input Show_Today_Only = {"Yes", default "No"}; input Hide_GapFills_Once_Hit = {"Yes", default "No"}; input Display_24Hour_Pivot = {"Yes", default "No"}; def OPEN_ACTUAL_TIME = 0930; def CLOSE_ACTUAL_TIME = 1600; def OPEN_OFFSET_TIME = 0945; def GLOBEX_CLOSE_TIME = 1615; def goPlot = if(getDay() == getLastDay(), 1, if(Show_Today_Only, 1, 0)); def isAllowed = if(getAggregationPeriod() == 900000, 1, 0); def isMarketOpen = if(if(secondsTillTime(OPEN_OFFSET_TIME) > 0, 0, 1) and !if(secondsTillTime(CLOSE_ACTUAL_TIME) > 0, 0, 1), 1, 0); def isFirstBar = if (getDay()[1] != getDay(), 1, 0); def isOpeningBell = if (secondsTillTime(OPEN_OFFSET_TIME)[1] > 0 and secondsTillTime(OPEN_OFFSET_TIME) <= 0 or (secondsTillTime(OPEN_OFFSET_TIME)[1] < secondsTillTime(OPEN_OFFSET_TIME) and secondsTillTime(OPEN_OFFSET_TIME)[1] > 0), 1, 0); def isGlobexDisplay = if(Display_24Hour_Pivot,0,1); def isClosingBell = if( secondsTillTime(CLOSE_ACTUAL_TIME)[1] > 0 and secondsTillTime(CLOSE_ACTUAL_TIME) <= 0 or (secondsTillTime(CLOSE_ACTUAL_TIME)[1] < secondsTillTime(CLOSE_ACTUAL_TIME) and secondsTillTime(CLOSE_ACTUAL_TIME)[1] > 0), 1, 0); def isGlobexClose = if( secondsTillTime(GLOBEX_CLOSE_TIME)[1] > 0 and secondsTillTime(GLOBEX_CLOSE_TIME) <= 0 or (secondsTillTime(GLOBEX_CLOSE_TIME)[1] < secondsTillTime(GLOBEX_CLOSE_TIME) and secondsTillTime(GLOBEX_CLOSE_TIME)[1] > 0), 1, 0); def isTradingHrs = if((secondsFromTime(OPEN_ACTUAL_TIME) >= 0 && secondsTillTime(CLOSE_ACTUAL_TIME) > 0), 1, 0); rec marketHoursHigh = if(high > marketHoursHigh[1] and isMarketOpen, high, if(isMarketOpen and !isFirstBar, marketHoursHigh[1], high)); rec regHoursLow = if(low < regHoursLow[1] and isMarketOpen, low, if(isMarketOpen and regHoursLow[1] > 0 and !isFirstBar, regHoursLow[1], low)); rec valueAtClose = compoundValue(1, if isClosingBell then close[1] else valueAtClose[1], close); rec prevClose = compoundValue(1, if isClosingBell then valueAtClose else prevClose[1], close); rec prevHigh = compoundValue(1, if isClosingBell then marketHoursHigh[1] else prevHigh[1], high); rec prevLow = compoundValue(1, if isClosingBell then regHourslow[1] else prevlow[1], low); rec regHoursOpen = compoundValue(1, if isOpeningBell then open[1] else regHoursOpen[1], open); rec valueAtGlobexClose = compoundValue(1, if isGlobexClose then close[1] else valueAtGlobexClose[1], close); rec globexClose = compoundValue(1, if isGlobexClose then valueAtGlobexClose else globexClose[1], close); plot Pivot_Point = if(isAllowed && goPlot && isTradingHrs, (prevClose + prevHigh + prevLow) / 3, double.nan); Pivot_Point.SetStyle(curve.POINTS); Pivot_Point.SetDefaultColor(color.cyan); plot Half_GapFill = if(isAllowed && goPlot && isTradingHrs, if( secondsTillTime(OPEN_ACTUAL_TIME) <= 0 && secondsTillTime(OPEN_OFFSET_TIME) > 0, prevClose + (open - prevClose) / 2, prevClose + (regHoursOpen - prevClose) / 2), double.nan); Half_GapFill.SetDefaultColor(color.lime); Half_GapFill.SetStyle(curve.POINTS); Half_GapFill.setHiding(!Hide_GapFills_Once_Hit); plot Full_GapFill = if(isAllowed && goPlot && isTradingHrs, prevClose, double.nan); Full_GapFill.SetStyle(curve.POINTS); Full_GapFill.SetDefaultColor(color.white); Full_GapFill.setHiding(!Hide_GapFills_Once_Hit); plot Globex_Pivot = if(isAllowed && goPlot && isGlobexDisplay && isTradingHrs, (globexClose + prevHigh + prevLow) / 3, double.nan); Globex_Pivot.SetStyle(curve.POINTS); Globex_Pivot.SetDefaultColor(Color.LIGHT_GREEN); plot Full_GapFillP10 = if(isAllowed && goPlot && isTradingHrs, prevClose+10, double.nan); Full_GapFill.SetStyle(curve.POINTS); Full_GapFill.SetDefaultColor(color.white); Full_GapFill.setHiding(!Hide_GapFills_Once_Hit); plot Full_GapFillM10 = if(isAllowed && goPlot && isTradingHrs, prevClose-10, double.nan); Full_GapFill.SetStyle(curve.POINTS); Full_GapFill.SetDefaultColor(color.white); Full_GapFill.setHiding(!Hide_GapFills_Once_Hit);