I am trying to display numerical labels (for example for EMA values) instead of lines in Indie.
The expected result is similar to Pine Script, where the EMA values are displayed as labels above/below the latest bar. However, I am facing several challenges while implementing this in Indie.
What I Have Tried So Far:
Using
@plot.marker()
Instead of@plot.line()
I replaced
@plot.line()
with@plot.marker()
to display numerical markers instead of plotted lines.I attempted to show the EMA values on the last bar only using
self.is_last_bar
.
Issues Faced:
Markers do not display numerical values.
I am unable to display the actual EMA values in the markers.
I need a way to pass text or numbers inside the marker.
How to Hide Status Line by Default.
- I can disable this manually in settings, but is there a way to disable it by default in the code?
Markers Do Not Disappear When a New Bar Appears.
When a new bar appears, the markers stay visible on both the last and second-to-last bar instead of updating dynamically.
Is there a way to clear old markers automatically when a new bar forms? Example of indicator
# indie:lang_version = 5
import math
from indie import indicator, plot, color, param
from indie.algorithms import Ema
# Indicator Definition
@indicator("EMA Levels Display", overlay_main_pane=True)
@param.int("ema1Len", default=10, min=1, title="EMA 1 Length")
@param.int("ema2Len", default=21, min=1, title="EMA 2 Length")
@param.int("ema3Len", default=50, min=1, title="EMA 3 Length")
@param.int("ema4Len", default=89, min=1, title="EMA 4 Length")
# Using markers instead of lines to display values
@plot.marker("ema1_label", color=color.RED)
@plot.marker("ema2_label", color=color.YELLOW)
@plot.marker("ema3_label", color=color.GREEN)
@plot.marker("ema4_label", color=color.BLUE)
def Main(self, ema1Len, ema2Len, ema3Len, ema4Len):
"""
Main function to calculate EMA values and display them as markers.
The goal is to display these markers ONLY on the last bar.
"""
ema1 = Ema.new(self.close, ema1Len)[0]
ema2 = Ema.new(self.close, ema2Len)[0]
ema3 = Ema.new(self.close, ema3Len)[0]
ema4 = Ema.new(self.close, ema4Len)[0]
# Show markers only on the last bar; otherwise, use NaN
label1 = ema1 if self.is_last_bar else math.nan
label2 = ema2 if self.is_last_bar else math.nan
label3 = ema3 if self.is_last_bar else math.nan
label4 = ema4 if self.is_last_bar else math.nan
return label1, label2, label3, label4
Expected Output:
I want text labels showing the exact EMA values on the latest candle.
These values should be dynamically updated only on the latest bar, disappearing from previous bars when a new one forms.
The status line values should be hidden (if possible via code).
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744683958a4587801.html
评论列表(0条)