Page 1 of 1

Calculating a 30 minute ema & candle via code in a 3 minute chart

Posted: Sun Nov 12, 2023 12:02 pm
by rox2metal
hi!

New here and to Pinescript. Not new to programming, tho....

I have a 3 minute chart open.
I need to see if a fast ema is crossing a slower ema as if it were on a 30 minute chart AND see where the bar close is in relation to the EMAs.
I use this as a confluence.
I don't need to see it on the 3 minute chart (tho, it would be nice).
So, if you open a 30 minute chart, and add the EMAs (any fast and slow length), the EMA lines go right up to the last candle. The last candle's EMA lines move up and down when it's live. This lets me see if the current price is above or below the EMAs.

If I put these EMAs on a 3 minute chart, but with a 30 minute timeframe, they stop about 9 candles short of the latest candle.
How do I fill in the rest of the line, all the way to the last candle to test the price-close relation to the lines?
Honestly, I don't even need to see it, I just need it in code to test. But not sure how to do this.
Any help would be appreciated!

Re: Calculating a 30 minute ema & candle via code in a 3 minute chart

Posted: Mon Nov 13, 2023 4:17 am
by Steve Burman
Hey Rox2Metal, have you looked at request.security() and request.security_lower_tf() functions. I'm not sure if these will give you the answer you need but worth looking into.

Here's the references.

https://www.tradingview.com/pine-script ... t.security
https://www.tradingview.com/pine-script ... y_lower_tf