diff --git a/Indicator/HLevel.lib.pinescript b/Indicator/HLevel.lib.pinescript index 6aa1a98..e1995a2 100644 --- a/Indicator/HLevel.lib.pinescript +++ b/Indicator/HLevel.lib.pinescript @@ -62,6 +62,10 @@ export type level bool isHide label priceLableId +method time(level this) => + int bars = bar_index - this.barIndex + timeframe.in_seconds(timeframe.period) * bars + export type levelsClass int maxBars int minNearLevels @@ -121,7 +125,7 @@ method markStrongLevels(levelsClass this, level lvl, int nextLevelIndex, distanc for int i = 0 to strongLevels.size() - 1 level _level = strongLevels.get(i) _level.hasNearLevel := true - + export method update(levelsClass this, pivotsList pivots, float priceRange, float distanceBetweenNearLevels) => pivot p = pivots.get(0) if not na(p.hPrice) @@ -220,6 +224,7 @@ export type levelDrawerClass color defaultPriceColor string priceShowOptions float transparent + bool showLevelTime export method init(levelDrawerClass this, string priceShowOptions, float transparent = 70, color roundPriceColor = color.green, color defaultPriceColor = color.white) => this.styles := array.new() @@ -275,11 +280,15 @@ export method draw(levelDrawerClass this, levelsClass levelList) => else color.new(this.defaultPriceColor, transparent) + string labelText = str.format("{0,number}", lvl.price) + if this.showLevelTime + labelText += str.format("\n{0,number,#}h", lvl.time() / 3600) + if na(lvl.priceLableId) lvl.priceLableId := label.new( x = lvl.barIndex, y = 0, - text = str.tostring(lvl.price), + text = labelText, size = this.priceShowOptions, style = label.style_none, textcolor = textColor, @@ -290,5 +299,6 @@ export method draw(levelDrawerClass this, levelsClass levelList) => 0 else lvl.priceLableId.set_textcolor(textColor) + lvl.priceLableId.set_text(labelText) 0 //#endregion \ No newline at end of file diff --git a/Indicator/ScalpingLevelLite.pinescript b/Indicator/ScalpingLevelLite.pinescript index bb67101..5ad8ff0 100644 --- a/Indicator/ScalpingLevelLite.pinescript +++ b/Indicator/ScalpingLevelLite.pinescript @@ -6,7 +6,7 @@ //@version=5 indicator("Scalping level [Lite] 1.3.0", overlay = true, max_lines_count = 500) -import stupean/HLevel/40 as HLevel +import stupean/HLevel/48 as HLevel //#region INPUTS ============================================ // Local level @@ -39,6 +39,7 @@ int weakLevelTransparent = input.int(defval = 85, minval = 0, maxval = 100, titl // Common float maxLevelDistanceCoef = input.float(defval = 0.7, title = "Max distance to level", group = "common") +bool showLevelTime = input.bool(defval = true, title = "Show level time", group = "common") // Price string priceShowOptions = input.string(defval = size.normal, options = [size.huge, size.large, size.normal, size.small, size.tiny, "none"], title = "Size", group = "price") @@ -164,6 +165,7 @@ if not isInit levels.addLifetime(BREAK_PERIOD, breakLevelLifetimeBars) drawer.init(priceShowOptions = priceShowOptions, transparent = weakLevelTransparent, defaultPriceColor = defaultPriceColor, roundPriceColor = roundPriceColor) + drawer.showLevelTime := showLevelTime drawer.addStyle(HLevel.lineStyle.new(localLevelWidth, localLevelColor)) drawer.addStyle(HLevel.lineStyle.new(middleLevelWidth, middleLevelColor)) drawer.addStyle(HLevel.lineStyle.new(globalLevelWidth, globalLevelColor))