Hi,
I am still on PRT 10.3 and I would like to create an indicator on my 1 hour charts that traces two lines from the close at 11pm (“close”:
a line that is equal to “close”+Daily ATR 14
a line that is equal to “close”-Daily ATR 14
Can someone help me build that please?
Thanks
This will use the current Daily value at 110000, if you prefer yesterday’s ATR value at close time, use the line in the comment (UpdateOnClose instead of Default):
Timeframe(Daily,Default) //or Timeframe(Daily,UpdateOnClose) to have yesterday's data at close
MyATR = AverageTrueRange[14](close)
//
Timeframe(default)
IF Time = 110000 THEN
AtrHI = close + MyATR
AtrLO = close - MyATR
ENDIF
RETURN AtrHI AS "Upper Band",AtrLO AS "Lower Band"
you may also want to replace TIME with OPENTIME as suits you best.
You may also colour the lines with the indicator properties.
Hi there, this was helpful to me for what I’m trying to do, but I have a problem. I get a calculation error I can’t figure out:
My objective is to draw ATR lines 45 minutes after market open (USA), so 10:15 EST. I just have 000000 now for testing. I want to link the ATR lines to either the current low or high of the day at 10:15 and can float like this for the rest of the day.
Timeframe(Daily,UpdateOnClose) //or Timeframe(Daily,UpdateOnClose) to have yesterday's data at closeTimeframe(Daily,UpdateOnClose)
MyATR = AverageTrueRange[14](close)
rmg = (((DHigh(0) - DLow(0))/2)) + DLow(0) //median for day
//
Timeframe(default)
IF (Time => 000000) and (CLOSE > rmg) THEN
AtrLO = DLow(0)
AtrHI = DLow(0) + MyATR
elsif (Time => 000000) and (CLOSE < rmg) THEN
AtrHI = DHigh(0)
AtrLO = DHigh(0) - MyATR
ENDIF
RETURN AtrHI AS "Upper Band",AtrLO AS "Lower Band"
In CET time (Utc +2), 101500 EST (Utc – 4) is 161500.
In Canada you will have to adjust it to your TZ:
Timeframe(Daily,UpdateOnClose) //or Timeframe(Daily,UpdateOnClose) to have yesterday's data at closeTimeframe(Daily,UpdateOnClose)
MyATR = AverageTrueRange[14](close)
rmg = (((High - Low)/2)) + Low //median for day
DayHI = high
DayLO = low
//
Timeframe(default)
IF (Time => 161500) and (CLOSE > rmg) THEN
AtrLO = DayLO
AtrHI = DayLO + MyATR
elsif (Time => 161500) and (CLOSE < rmg) THEN
AtrHI = DayHI
AtrLO = DayHI - MyATR
ENDIF
RETURN AtrHI AS "Upper Band",AtrLO AS "Lower Band"
I replaced DHIGH e DLOW with DayHI and DayLO because I was reported a calculation error.
Getting closer thanks. These lines return the median/high/low prices for the day before, but I need them for the live trading day.
rmg = (((High - Low)/2)) + Low //median for day
DayHI = high
DayLO = low
Replace UpdateOnClose with Default in line 1.
Actually using Default in line 1 makes it useless using the Daily TF.