Hello coders,
Would the below simple indicator work on a 1 Hr chart?
defparam drawonlastbaronly = true
if CurrentTime = 172000 Or OpenTime = 172000 Then
DrawText(“Check 65m TimeFrame”,barindex,high+10,SansSerif,standard,16)coloured(255,255,255)
Endif
Return
if it doesn’t work, is there a way to fix the code to make it work?
1-hour TF will only open, and close, every hour, so there will never be a chance for a condition to be met at a 20-minute time.
You need to change TF or your code as follows:
if Time = 172000 or (Time > 172000 and Time[1] < 172000) then
you can replace TIME by OPENTIME.
I am confused. Did you mean the code will never work on 1 Hr chart no matter what or are you saying if I change the code to what you suggested then the 20 minute time condition will be met on 1 Hr chart?
No, it allows your condition to be checked on the first TF boundary AFTER 172000.
On a 1-hour TF your condition will be met at 180000.
With your code it will never be met.
No good mate. I want my condition to be met at precisely 172000 when I am on a 1 Hr chart. is it possible?
Tnx Roberto. Much appreciated mate.
Would the below trick code work and Draw the Text at 15.45 on the 1 Hr Chart?
defparam drawonlastbaronly = true
elapsed = timestamp - opentimestamp
if OPENTIME = 150000 then
if elapsed = 2700 then
DrawText("Check 135m F9",barindex,high+10,SansSerif,standard,16)coloured(255,255,255)
Endif
Endif
Return
The above code should work, but the text will appear only at exact timestamp. But you will probably not see it for 2 reasons:
- “elapsed” is equal to 7200 seconds, there is only a small chance the 1-hour bar will update at this precise second
- if the text is plotted, it will disappear automatically since you are using a drawonlastbaronly