Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to normalize a dataset by its maximum value?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to normalize a dataset by its maximum value?

    Hi All,

    I'm trying to normalize the data obtained from an EMA by its maximum value over a period of 256 candles. Something like this....

    public Series <double> ema_set;
    public Series <double> ema_set;_norm

    double ema14 = EMA(...)[0];
    ema_set = ema14;
    ema_set_norm = ema_set / ema_set.Max();

    But it's not working like this, or when using other alternatives like Math.Max().

    Any suggestions?

    Thanks guys

    #2
    Welcome to the forums mauva27!

    I'm by no means a mathematician, but taking this Normalize formula from stackoverflow, I would consider setting up the following:

    Code:
    protected override void OnBarUpdate()
    {
        if (CurrentBar < 256)
            return;
    
        double normalized = Normalize(EMA(14)[0], MIN(EMA(14), 256)[0], MAX(EMA(14), 256)[0], 0, 100);
        Print(String.Format("EMA: {0} Normalized: {1} Min: {2} Max:{3}", EMA(14)[0], normalized, MIN(EMA(14), 256)[0], MAX(EMA(14), 256)[0]));
    }
    
    private double Normalize(double val, double valmin, double valmax, double min, double max)
    {
        return (((val - valmin) / (valmax - valmin)) * (max - min)) + min;
    }
    Publicly available link: https://stackoverflow.com/questions/...-to-3/51161208

    We look forward to asissting.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X