Last candle data
#1
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
  Reply
#2
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
  Reply
#3
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
  Reply
#4
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.
  Reply
#5
you are a true gentleman thank you so much!!
  Reply


Forum Jump:


Users browsing this thread: