Gekko Forum
Get current 10 minutes candle and last 10 minutes candle - Printable Version

+- Gekko Forum (https://forum.gekko.wizb.it)
+-- Forum: Gekko (https://forum.gekko.wizb.it/forum-13.html)
+--- Forum: Strategy Development (https://forum.gekko.wizb.it/forum-12.html)
+--- Thread: Get current 10 minutes candle and last 10 minutes candle (/thread-57440.html)



Get current 10 minutes candle and last 10 minutes candle - Syl - 07-26-2018

hi, I'm trying to write a custom strategy, and I wonder how can I get this 10 minutes candle and last 10 minutes candle.

if this question is  duplicate, pls give me some  reference, thank you!


RE: Get current 10 minutes candle and last 10 minutes candle - askmike - 07-26-2018

I'm working on some strategy guides and some videos. What you want to do is "store" the previous candle in your strategy like so:

Code:
strat.check = function(candle) {
  this.currentCandle = candle;

  // use the current and previous one
  if(this.currentCandle.close < this.previousCandle.close) { ... etc }
    
  // call the current candle previous one so the next time
  // the check function runs you can still access it
  this.previousCandle = this.currentCandle;
}



RE: Get current 10 minutes candle and last 10 minutes candle - Syl - 07-27-2018

Great! Thank you! Looking forward to guides and videos


RE: Get current 10 minutes candle and last 10 minutes candle - askmike - 07-27-2018

In the meantime: if you have other questions like this feel free to ask them Smile