rox2metal
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: November 11th, 2023
Contact: TradingView Profile

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

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!

Steve Burman
Moderator
Moderator
Posts: 109
Joined: January 13th, 2023

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

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

Return to “Pine Script Q&A”