Test on MTF does not return same value

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #162275 quote
    Khaled
    Participant
    Veteran

    Hello everyone, please bear me with me… I’m trying to test a simple code on TF 12min and TF 4 min, whatever the TF – it’s about the principle… So my condition is when price is higher than the EMA8 under TF 12 min. When I plug the same indicator under graph 4 Min, it gives a different result than on 12 min graph, even though the code starts with “TIMEFRAME (12 minutes)”. As you can see on the attached graph, the trend is down at 19:48 and 19:52 on 4min chart (arrows) and trend is up at the very same time on chart 12 min (arrow).

    Please help me understand what’s wrong with my code.

    Thanks

    TIMEFRAME (12 minutes)
    
    if close>=ExponentialAverage[8](close) then
    Trend=1
    elsif close<ExponentialAverage[8](close) then
    Trend=-1
    endif
    
    return Trend
    2021-02-21-204548.png 2021-02-21-204548.png
    #162278 quote
    Vonasi
    Moderator
    Master

    Your chart is showing Heiken Ashi candles but your indicator uses the closing price of Japanese candles.

    Khaled thanked this post
    #162279 quote
    Khaled
    Participant
    Veteran

    Thank you Vonasi, but with all due respect, the indicator uses the candles prices on both charts, so it doesn’t have an impact. In both cases, I’m comparing CLOSE to EMA… no HA price.

    #162280 quote
    Khaled
    Participant
    Veteran

    Same test with prices of normal candles, same issue, signal doesn’t match

    2021-02-21-214749.png 2021-02-21-214749.png 2021-02-21-214724.png 2021-02-21-214724.png
    #162284 quote
    Vonasi
    Moderator
    Master

    Add this indicator on to your price chart with Japanese candlesticks and NOT Heiken Ashi candles and you will see that your 12 minute average indicator works just fine.

    TIMEFRAME (12 minutes)
    
    avg=ExponentialAverage[8](close)
    
    return avg
    
    Khaled thanked this post
    Screenshot_1-3.png Screenshot_1-3.png
    #162314 quote
    Nicolas
    Keymaster
    Master

    BTW, keep in mind that without using “updateonclose” for your 12-minutes timeframe definition, you will get the intra bar values in your 4-minutes timeframe. So by looking on your chart history, you might see a green candle on the 12-minutes, while most of your histograms could have been red in your 4-minutes timeframe.

    #162325 quote
    Khaled
    Participant
    Veteran

    Thanks Nicolas, I’m actually trying to do the opposite: have the final value of 12 min , hence UPDATONCLOSE, on the 4 min chart, i.e. each time the bar is green on 12 min chart the 3 bars (3*4) should also be green on the 4 min chart. Any idea how I can do that? I understand Vonasi’s HA point, but I’m using “closing” which is price of standard candles.

    Thanks again.

    #162327 quote
    Nicolas
    Keymaster
    Master

    So you want to redraw in the past?

    #162328 quote
    Vonasi
    Moderator
    Master

    I would suggest adding this indicator to price on a 4 minute chart and then you will have a clear idea of the difference between DEFAULT and UPDATEONCLOSE:

    TIMEFRAME (12 minutes, default)
    defavg=ExponentialAverage[8](close)
    
    TIMEFRAME (12 minutes, updateonclose)
    udocavg=ExponentialAverage[8](close)
    
    return defavg as "Default", udocavg as "UpDateOnClose"
    Nicolas and Khaled thanked this post
    #162341 quote
    Khaled
    Participant
    Veteran

    Guys, I don’t want to lose more of your precious time with this basic issue, but when I copy the code of Vonasi above and plug it on 4 min and 12 min charts, you can see on the last bar starting at 12.36pm that the “Default” is equal on both graphs (13906,..), but the “12 min UpDateOnClose” is different on 4 min chart (13909,…) and 12 min chart on the last bar (13906,…). My question is how to get these two UPDATEONCLOSE numbers identical? or why that’s not possible?

    I took this simple example of EMA to make the case, but imagine that a trading signal is built on 4min chart using two criteria: Criteria1 based on 12min (updateonclose) and criteria2 based on 4min(default), so the value the Algo will take is the one based on the graph where you execute ProOrder which should be the least of both, which is 4min chart. The value of criteria1 is different on chart 12 min from the value on chart 4 min eventhough it’s marked UPDATEONCLOSE. If the variable is binary, it can trigger or not a trade.

    Many thanks

    20200221_EMA8-MTF.png 20200221_EMA8-MTF.png
    #162346 quote
    Nicolas
    Keymaster
    Master

    Please take time to understand how it works, during a bar, the value change, you can’t see that on the 12-minutes bar, but you can see what’s happening in it by using an inferior timeframe and that’s what you are doing with the 4-min one.

    In your 4-min TF, with the 12-min bar “updateonclose” the timeframe is updated only 1 time, at Close. So on a 4-minutes timeframe you’ll get the previous 12-minutes bar value (not the opened one). To get the value of the 12-minute “live”, remove updateonclose.

    In French, see what is all about MTF and how it works in this topic: Première approche sur le multi timeframe avec ProRealTime

    In English: First approach to multi timeframe trading with ProRealTime

    Khaled thanked this post
    #162350 quote
    Khaled
    Participant
    Veteran

    Sorry Nicolas, I could only clic one single time on “Thanks” otherwise I’d have put many….

    I’ve my answer… This is excatly the confirmation I was looking for.

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

Test on MTF does not return same value


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Khaled @khaled Participant
Summary

This topic contains 11 replies,
has 3 voices, and was last updated by Khaled
4 years, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/21/2021
Status: Active
Attachments: 5 files
Logo Logo
Loading...