Gekko Forum
Last candle data - Printable Version

+- Gekko Forum (
+-- Forum: Gekko (
+--- Forum: Technical Discussion (
+--- Thread: Last candle data (/thread-57775.html)

Last candle data - Kris191 - 11-23-2018

Hi all,

Can someone help me please. I want to pull the low and high of the last candle into my strat and log in console, for some reason i cannot figure out how to get the data pulled through, can anyone help me out please.


RE: Last candle data - Gryphon - 11-26-2018

Ensure that you are within a function that has candle data passed into it.

function check(candle) {}

Then you can use candle.high, candle.low as regular variables.

console.log(`Candle High = ${candle.high}`);


RE: Last candle data - Kris191 - 11-26-2018

Thank you for this Gryphon. would i use lastCandle to call on the data? ive been looking at arrays but cant get it to return the candle data juts returns a 0

RE: Last candle data - Gryphon - 11-26-2018

Oh, missed that bit. In init, create a last candle var.

Then at the end of the check function update this:
this.lastCandle = candle

If you'd get errors from an undefined last candle, you can set a first run check and for the very first run set lastCandle to candle before it's checked.

RE: Last candle data - Kris191 - 11-26-2018

you are a true gentleman thank you so much!!