Heiken Ashi from higher Timeframe do not work
Forums › ProRealTime English forum › ProBuilder support › Heiken Ashi from higher Timeframe do not work
- This topic has 20 replies, 4 voices, and was last updated 4 years ago by
Jerome888.
-
-
03/14/2021 at 11:09 AM #164075
Hi
My need is to get, from the 15min TF, the xopen value from the daily TF.
The here below code provides
- correct daily “Heiken Ashi Close” (xClose)
- uncorrect daily “Heiken Ashi Open” (xOpen) and I fail to understand why.
12345678TIMEFRAME(daily)if barindex>1 thenxClose = (Open + High + Low + Close) / 4xOpen = (xOpen[1] +xClose[1])/2endifTIMEFRAME(15 minutes)return xOpen, xClose coloured(255,0,0)Any idea ?
I search the problem since hours…
03/14/2021 at 12:49 PM #164098Change you code:
- add ONCE xOpen = Open as line 2
- line 3 must be written outside the IF…ENDIF
12345678TIMEFRAME(daily) //or TIMEFRAME(daily,UpdateOnClose) for yesterday's valuesONCE xOpen = OpenxClose = (Open + High + Low + Close) / 4if barindex>1 thenxOpen = (xOpen[1] +xClose[1])/2endifTIMEFRAME(15 minutes)return xOpen, xClose coloured(255,0,0)03/14/2021 at 1:11 PM #16410903/14/2021 at 6:00 PM #164132Yes, you are right. It’s really weird!
I suggest that you hit Ctrl+M from your platform and send a request for assistance.
Please post any solution you will be suggested. Thank you 🙂
03/14/2021 at 6:44 PM #16413403/15/2021 at 1:33 AM #164175If you just want the H.A. daily xopen and xclose you should use the xClose updated on the latest 15m bar not the xClose from the previous daily bar. The next code works for me:
123456789101112131415161718//initif barindex = 1 thenxOpen = openendiftimeframe(daily)dayOPEN = opendayhigh = highdaylow = lowtimeframe(default)IF dayOPEN <> dayOPEN[1] THEN //calculate daily HA openxOpen =( xOpen[1]+xClose[1])/2ENDIFxClose=(dayOpen+close+dayhigh+daylow)/4RETURN xOpen AS "xOPEN", xClose as "xClose"03/15/2021 at 5:47 AM #16418403/15/2021 at 5:57 AM #164186…i THINK I understand why but… unsure
And if I want to get data from previous daily Ha, I would do that but seems not working
123456789101112131415161718192021222324if barindex = 1 thenxOpen = openendiftimeframe(daily)dayOPEN = opendayOPEN1 = open[1]dayhigh = highdayhigh1 = high[1]daylow = lowdaylow1 = low[1]timeframe(default)IF dayOPEN <> dayOPEN[1] THEN //calculate daily HA openxOpen =( xOpen[1]+xClose[1])/2ENDIFIF dayOPEN[1] <> dayOPEN[2] THEN //calculate daily HA openxOpen1 =( xOpen[2]+xClose[2])/2ENDIFxClose=(dayOpen+close+dayhigh+daylow)/4xClose1=(dayOpen1+close[1]+dayhigh1+daylow1)/403/15/2021 at 5:58 AM #16418703/15/2021 at 9:23 AM #164196pableitor ‘s code works fine as long as you don’t use UPDATEONCLOSE.
It’s a workaround, but it should not be necessary, as it’s the same code as in prior posts and is executed every 15 minutes like the prior one.
It’s good it works, but it would be better that the prior code worked as well.
03/15/2021 at 9:35 AM #164198Just note that the daily HA Close is the same than the last 15minutes HA Close of the day, so we must use xClose[1] from the 15minutes timeframe, not the daily. In order to get the previous day HA data just save it in a couple of variables before updating the daily xOpen and xClose, like this:
12345678910111213141516171819if barindex = 1 thenxOpen = openendiftimeframe(daily)dayOPEN = opendayhigh = highdaylow = lowtimeframe(default)IF dayOPEN <> dayOPEN[1] THEN //calculate daily HA openxOpen1 = xOpenxClose1 = xClose[1]xOpen =( xOpen[1]+xClose[1])/2ENDIFxClose=(dayOpen+close+dayhigh+daylow)/4RETURN xOpen AS "xOPEN", xOpen1 AS "prev_xOpen" , xClose as "xClose", xClose1 as "prev_xClose"I used your variables names, but for multiple related variables you can use an array as well.
03/15/2021 at 12:50 PM #164211Pableitor, Robertogozzi
Thank you both.
To be honest : It works but I do not understand why and I am lost with regards to your thoughts.
Pableitor, thank you very much. Last question: I guess the same function but only applied the simple default TF would be simply
12345678IF BarIndex = 1 THENXOpen = (Open + Close) / 2ELSEXClose = TotalPriceXClose1=XClose[1]XOpen = (XOpen[1] + Xclose[1]) / 2XOpen1 = XOpen[1]ENDIFThank you again both
03/15/2021 at 4:56 PM #164237@jerome888 I just cleaned the code a little bit so it can be used on any default TF from 1 min up to 1h. BTW its a pity that PRT doesnt give the HA OHLC values as indicator so it would be easier to calculate the MTF values:
123456789101112131415if barindex = 1 thenxOpen = openendiftimeframe(daily)dayOPEN = openxClose=Totalpricetimeframe(default, updateonclose)IF dayOpen <> dayOPEN[1] THEN //calculate daily HA openxOpen =( xOpen[1]+xClose[1])/2ENDIFRETURN xOpen AS "xOPen" , xClose as "xClose"PS Yes your code works fine for the default TF.
03/15/2021 at 5:23 PM #16424103/15/2021 at 5:23 PM #164242pableitor – Do not use the ‘Quote’ button unless you are actually quoting someone! Your post had your own text included in a quote and no one else’s text in it.
- Be careful when quoting others in your posts. Only use the quote option when you need to highlight a particular bit of text that you are referring to or to highlight that you are replying to a particular member if there are several involved in a conversation. Do not include large amounts of code in your quotes. Just highlight the text you want to quote and then click on ‘Quote’.
-
AuthorPosts
Find exclusive trading pro-tools on