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

Buy/sell signals not showing



  • Hi, I'm new to this platform and am running into problems with the plotting. The logic seems to work fine and the trades go through but on the chart itself I expect the green and red arrows to appear. I got the forex data from HistData. They're downloaded as xlsx files originally but I've converted it to a csv format.

    1b8cdf49-2a9a-46f7-a11c-ee301163fcc5-image.png

    I suspect the problem lies within the data because I got similar data that I downloaded from Yahoo and the arrows show up.

    8fd595b7-9854-42ca-bab1-eb0ecc491b31-image.png

    There are two differences between the data as far as I can tell. The first as that one (the one that doesn't work) is 1m and the second is 1d. The second is that there is no "Adj Close" column in the 1m csv. The columns are Date, Open, High, Low, Close, Vol. Where for the 1d csv there is Adj Close after Close. I've tried simply copying the Close column into a Adj Close column but that didn't fix anything.

    Here is the code:

    import backtrader as bt
    import pandas as pd
    from strategies import GoldenCross
    
    cerb = bt.Cerebro()
    cerb.broker.setcash(1000)
    
    fname = "data/GBPUSD_1d.csv"
    # fname = "data/testing.csv"
    data = pd.read_csv(fname, index_col=0, parse_dates=True)
    # data["Adj Close"] = data["Close"]
    
    feed = bt.feeds.PandasData(dataname=data)
    cerb.adddata(feed)
    cerb.addstrategy(GoldenCross)
    print(cerb.broker.getvalue())
    cerb.run()
    cerb.plot(style='candlestick', plotlinelabels='True')
    

    Any help would be greatly appreciated!



  • Just a guess. It probably worth to specify the timeframe and the compression for the PandasData ( the default is 1 day if I'm not mistaken).


Log in to reply
 

});