For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

ZigZag indicator for live trading.



  • Hi !
    This kind of worked but there are still flat tops. I wonder if they can be removed? I circle these in blue.

    plot 1.png



  • Hi.
    Снимок экрана 2020-04-15 в 22.41.22.png

    Everything works. You forgot to add second data in the code that you posted. So second ZZ doesn't have any data to operate with.

    df = pd.read_csv('datas\\EURUSD2019.csv', sep=',', header=0, index_col=0, parse_dates=True)
    df1 = pd.read_csv('datas\\EURUSD2019.csv', sep=',', header=0, index_col=0, parse_dates=True)
         
    data = bt.feeds.PandasData(dataname=df, timeframe=bt.TimeFrame.Minutes, compression=1)
    data1 = bt.feeds.PandasData(dataname=df1, timeframe=bt.TimeFrame.Minutes, compression=1)
     
    cerebro.adddata(data)
    cerebro.adddata(data1)


  • Or use second ZZ on the same data. Not data1.



  • Hi Niko, I am resampling from data and so, it adds to cerebro already.
    anyway, I like to check with you, its probably not your code, I just do not understand why the trend occillates on my large timeframe 4hrs.

    I have 2 zz lines in init:
    self.zz = ZigZag(self.data, period=self.p.zzperiod, retrace=self.p.retrace1, minbars=self.p.minbars) -> run on 1 min data
    self.zz1 = ZigZag(self.data1, period=self.p.zzperiod, retrace=self.p.retrace2, minbars=self.p.minbars) -> run on 4hr data

    in def next(self):
    I call :
    print(self.data0.datetime.datetime(0), self.zz.l.trend[0], self.zz.l.trend[-1], self.data1.datetime.datetime(0), self.zz1.l.trend[0], self.zz1.l.trend[-1])
    I get ocillating trends at some points for the larger timeframe. New higher TF bar in the print out shows that a new bar is formed on the 4hr timeframe.
    2020-04-10 07:53:00 1.0 1.0 2020-04-10 04:00:00 1.0 1.0
    2020-04-10 07:54:00 1.0 1.0 2020-04-10 04:00:00 1.0 1.0
    2020-04-10 07:55:00 1.0 1.0 2020-04-10 04:00:00 1.0 1.0
    2020-04-10 07:56:00 1.0 1.0 2020-04-10 04:00:00 1.0 1.0
    2020-04-10 07:57:00 1.0 1.0 2020-04-10 04:00:00 1.0 1.0
    2020-04-10 07:58:00 1.0 1.0 2020-04-10 04:00:00 1.0 1.0
    2020-04-10 07:59:00 -1.0 1.0 2020-04-10 04:00:00 1.0 1.0
    new higher TF bar
    2020-04-10 08:00:00 -1.0 -1.0 2020-04-10 08:00:00 1.0 1.0
    2020-04-10 08:01:00 -1.0 -1.0 2020-04-10 08:00:00 -1.0 1.0
    2020-04-10 08:02:00 -1.0 -1.0 2020-04-10 08:00:00 1.0 1.0
    2020-04-10 08:03:00 -1.0 -1.0 2020-04-10 08:00:00 -1.0 1.0
    2020-04-10 08:04:00 -1.0 -1.0 2020-04-10 08:00:00 1.0 1.0
    2020-04-10 08:05:00 -1.0 -1.0 2020-04-10 08:00:00 -1.0 1.0

    any idea why?



  • Ok, I understand what is your problem. The indicator was not designed to work with two timeframes at the same time. It should be modified for your goals.

    any idea why?
    If you have 2 data flows: 1 and 4 hour
    next happens 4 times at 4 hour data flow


Log in to reply
 

});