Get each day’s highest/lowest MACD for the past 5 days

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #209556 quote
    Trianenn
    Participant
    New

    Hello,

    I’m looking for a way to retrieve the highest and lowest MACD values (the blue line) for each day for the past five days.

    Could anyone please help me with that?

    #209590 quote
    Nicolas
    Keymaster
    Master

    There are different ways to do, so could you just define how you want to use them or display them on the chart? So I could suggest the best solution.

    #209607 quote
    Trianenn
    Participant
    New

    I’d like to average these numbers to draw a line on the MACD indicator. The purpose is to know when there seems to be an overreaction to the upside or downside.

    #209614 quote
    Nicolas
    Keymaster
    Master

    Ok and it will be used on intraday timeframes such as 15-minutes for instance?

    #209625 quote
    Trianenn
    Participant
    New

    Yes, that’s correct!

    Does that mean the code is dependent on the graph’s timeframe and there is no way to search for data in-between given dates?

    Does the graph has to have a 5-day history for the data to be retrieved?

    #209632 quote
    Nicolas
    Keymaster
    Master

    I was thinking of different manner to do it, here is the code that calculate the mean of the last “period” days of highest and lowest MACD values.

    period = 5
    
    // ---------------------------
    imacd=MACD[12,26,9](close) 
    
    once hh = imacd 
    once ll = imacd 
    
    if IntradayBarIndex =0 then 
    ii=ii+1
    $hh[ii]=imacd
    $ll[ii]=imacd 
    endif
    
    $hh[ii]=max(imacd,$hh[ii])
    $ll[ii]=min(imacd,$ll[ii])
    
    //mean
    if ii>period then 
    sum = 0 
    for i = ii downto ii-period do 
    sum=sum+($hh[i]+$ll[i])/2
    next
    mean=sum/period
    endif 
    
    return mean//,$hh[ii],$ll[ii]
    Trianenn thanked this post
    #209646 quote
    Trianenn
    Participant
    New

    Thanks a lot Nicolas!

    I’m going to give a try and see if I can tailor it further.

    Does the graph have to extend beyond the period (5 days) to calculate the values or can they be calculated independently of the graph’s history length?

    #209648 quote
    GraHal
    Participant
    Master

    Link to above code added as Log 353 here …

    Snippet Link Library

    Trianenn thanked this post
    #209651 quote
    Nicolas
    Keymaster
    Master

    The chart must contained the X days history visible.

    #209663 quote
    Trianenn
    Participant
    New

    Is there no way around it?

    Can’t we parse historical data even if it’s not on the current graph?

    #209725 quote
    Nicolas
    Keymaster
    Master

    No, the highest and lowest values of an indicator calculated upon a data serie must read it and therefore must be visible on the chart.

    #209764 quote
    Trianenn
    Participant
    New

    Understood, thanks Nicolas!

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

Get each day’s highest/lowest MACD for the past 5 days


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Trianenn @trianenn Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/12/2023
Status: Active
Attachments: No files
Logo Logo
Loading...