order_target_percent is not aimed at stop-loss. The order_target_xxx family of methods allow to size an order using for example expected value or percentage of value but don't set stop losses.
There is no need for __init__ in that sample. The logic for the orders is 100% in next and is explained here:
Post some sample code (it really helps)
If the target is to write the values of indicators use the standard functionality Writer
Don't forget to do this with your indicator:
self.mysma = bt.indicators.SMA(self.data, period=30)
self.mysma.csv = True
The default behavior is to not write the value of indicators with a writer to avoid cluttering in the csv output and thus selected indicators must have the csv flag activated.
If a single data feed is added to the system with replaydata, only this data will be output. In this case the only data known to cerebro is the one with timeframe=bt.TimeFrame.Minutes and compression=15. The original is NOT in the system
Add it too with: cerebro.adddata(data)
The original behavior of backtrader enforced adding the larger timeframe data feeds after the smaller timeframe feeds. With the new sychronization mechanism available since 1.9.x., this is no longer needed. In any case the suggestions would be for this:
Add the larger timeframe (your replaydata) after the smaller timeframe (adddata)
In that case: self.data0 will be the smaller timeframe and self.data1 the larger timeframe. Use the appropriate reference when creating the indicators
Although not strictly needed use cerebro.run(next=True). This will keep the buffers fully sync'ed and allows plotting.
As pointed out by RandyT you can port the indicator easily, imho.
If it's a data feed there is direct support for loading a pandas.Dataframe. See:
https://www.backtrader.com/docu/dataautoref.html (look for PandasData)
If you have something precalculated which is not a data feed the use case is about synchronization, because you probably want to use it as an indicator. You should then check the datetime of the data feed passed to the indicator to fetch the proper data from the dataframe.
A more detailed use case would help in understanding what may (or may not) missing.
This is a non-expected usage pattern and for sure one which is not going to work.
LineBuffer is an internal object which is not meant for user consumption. And of course self.dval1 is turning into a float, you are assigning a float to the member attribute you created yourself.
This is not the same as self.lines.xxx = yyy during the __init__ phase, because in that case self.lines is an object, and xxx is constructed by means of Descriptors, which allows controlling things like assignment (via __set__). But assignment cannot be controlled on a member attribute you have created.
The use case is actually a lot easier:
self.dval1 = bt.ind.Lowest(self.data.low, period=10) # or bt.ind.MinN(self.data.low, period=10)
print('the current lowest value is:', self.dval1)
The indicator family is big and tries to cover all possible aspects