freqtrade / freqtrade

Free, open source crypto trading bot

Home Page:https://www.freqtrade.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to plot bool indicators below or above candles & plot shapes?

snussik opened this issue · comments

Describe your environment

  • Operating system: Win 11
  • Python Version: 3.12.2
  • CCXT version: 4.2.87
  • Freqtrade Version: freqtrade 2024.4-dev-e6da491ca

Plotting boolean objects below or above candles

Is it possible to plot bool indicators below or above candles?

For example, how should be plot_config set for such a pinescript analogue:

upcandle = close[1] < close

plotshape(upcandle, title='upcandle', text='', style=shape.circle, textcolor=color.rgb(0, 19, 230), size=size.tiny, location=location.belowbar, color=color.rgb(0, 19, 230), offset = -1)

Well i have no clue what the pinescript function actually tries to do.

You can however plot indicators just fine.
for booleans which go onto the main chart, i usually recommend to pick "one" line - and assign it something like this:

dataframe.loc[dataframe['bool'], 'bool_indicator'] = dataframe['close']

You can then use the type "scatter" in freqUI to plot these values - which will show up at the line. (obviously, you can also use open/high/low - or move it up/down a bit to make it more visible - that's then up to you / experimentation on how it looks the way you desire.

@xmatthias the question was mostly in manipulating object's rendering positions and types \ modes:

  • location=location.belowbar - renders circle shape below bar (as entry and exit signals do with triangles)
  • also, I'd like plot some other shapes like rectangles and so on.

In the ~/freqtrade/plot/plotting.py I've found limited support for some Bar & Scatter objects. But as it's considered as legacy. may be in frequi the support was extended. So I've not found any code examples of how the config for that should look.

Everything freqUI can render can be configured as part of the plot configurator.
If it ain't there - you can't do it. Plot-config is output of that configurator for "ease of use" in a strategy - but the UI will guide you through it.
Support has been extended for some common schemes (like area plots).

That said - the first point - you can absolutely do with the above described method. While it's a combination of dataframe and plotting - it's the way to go.

You can't plot other shapes - but i also don't really see the usecaes if i'm honest - so maybe you can describe why you think you need to plot random symbols on a chart? (most likely, there's a different / better way to do it).

@xmatthias I'd like to render on the charts smth. like that (it can be done with horizontal lines only, but if there are a lot of them - it becomes messy, & also I'd like to see block (rectangle) intersections):

Screenshot 2024-05-10 at 22 25 19

except for the labels - you can accomplish that figure using the method described above.

In essence, it's simply 2 indicators (columns in the dataframe) - one for the upper, one for the lower line of the rectangle.
When the rectangle starts/ends - their values become NaN in the dataframe (essentially, not assigned).
You then connect them as Area in the plot configurator - and it'll become a rectangle automatically (obviously assuming that the numbers you assigned form a straight line).

Labels / text won't be possible - and i also don't think that it's going to be something that we'll be adding to plots - as that tends to make plots very messy rather quickly - and i'd not know how to generalize this in a way to make it useful for more than 1 dedicated strategy.