function Init() indicator:name("Previous Week Tails"); indicator:description("Previous Week Tails"); indicator:requiredSource(core.Bar); indicator:type(core.Indicator); end local source = nil; local Period; local DaySource; local WeekSource; function Prepare() source = instance.source; Period=instance.parameters.Period; local name = profile:id() .. "(" .. source:name() .. ")"; instance:name(name); DaySource = core.host:execute("getSyncHistory",source:instrument() , "D1", true,1 ,2, 1); WeekSource = core.host:execute("getSyncHistory",source:instrument() , "W1", true,3 ,4, 1); end local PreviousTradingDayClose; local PreviousTradingWeekClose; local date; local weekstart,weekend; local daystart,dayend; local x1; local y1; local x2; local y2; function Update(period, mode) PreviousTradingDayClose= DaySource.close[period-1]; PreviousTradingWeekClose= WeekSource.close[period-1]; PreviousTradingWeekOpen= WeekSource.open[period-1]; PreviousTradingWeekHigh= WeekSource.high[period-1]; PreviousTradingWeekLow = WeekSource.low[period-1]; date = source:date(period); weekstart,weekend = core.getcandle("W1", date, core.host:execute("getTradingDayOffset"), core.host:execute("getTradingWeekOffset")); daystart,dayend = core.getcandle("D1", date, core.host:execute("getTradingDayOffset"), core.host:execute("getTradingWeekOffset")); context:createPen (1, context.SOLID, 3, core.rgb(0, 0, 0)); context:createSolidBrush (2, core.rgb(0, 0, 255)); x1= weekstart; y1= PreviousTradingWeekHigh; x2= weekend; if(PreviousTradingWeekClose > PreviousTradingWeekOpen) then y2= PreviousTradingWeekClose; else y2 = PreviousTradingWeekOpen ; end context:drawRectangle (1, 2, x1, y1, x2, y2, 50); context:createSolidBrush (2, core.rgb(0, 255, 0)); y1= PreviousTradingWeekLow; if(PreviousTradingWeekClose < PreviousTradingWeekOpen) then y2= PreviousTradingWeekClose; else y2 = PreviousTradingWeekOpen ; end context:drawRectangle (1, 2, x1, y1, x2, y2, 50); end