Gekko Forum
Last candle data - Printable Version

+- Gekko Forum (https://forum.gekko.wizb.it)
+-- Forum: Gekko (https://forum.gekko.wizb.it/forum-13.html)
+--- Forum: Technical Discussion (https://forum.gekko.wizb.it/forum-23.html)
+--- 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.

Thanks


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

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


Code:
function check(candle) {}


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


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


etc


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.
Code:
this.lastCandle={};


Then at the end of the check function update this:
Code:
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!!