How can I get information on the candle previous to the one that just closed in creating a Freqtrade strategy for Binance in python?

Viewed 1121

I'm going to preface this by saying I'm a complete newb. I actually have a python certification from Codecademy but it's dawning on me that I nevertheless know absolutely nothing!

I have three questions:

  1. Using freqtrade I want to run hour by hour based in part on the previous candle. When one candle closes and the next one begins, the bot should do its calculation then and get in as soon to immediately as possible. Then it needs to stop and wait until the end of the next interval. Can I do this with dataframe["close"] in my buy signal or will that be checking continuously? How can I make sure that it gets in right away and then waits until the close of the current candle to do the next thing?

  2. Using freqtrade in coding my strategy I know I can use dataframe["close"] to refer to the close of the most recent candle (I think). How I can get the information from the candle previous to the one that just closed, 'open' 'close' 'high' 'low', all of it? What about the candle previous to that one?

  3. I've been looking through documentation for the past week trying to find answers to these questions-- the TALIB documentation, pandas dataframe documentation, freqtrade documentation-- I can't find it! Even if you don't feel like answering my questions could you please direct me to the specific place I can answer them for myself? I'm completely stuck with this project and the assistance on the course I'm taking is worthless.

Thanks in advance for any help or guidance you can give.

1 Answers

You can access the previous candle's close price with:

dataframe['close'].shift(N)

where N is the number of candles before the current one.

So the previous candle would be:

dataframe['close'].shift(1)
Related