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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    57 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    78 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    39 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    101 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    61 views
    0 likes
    Last Post PaulMohn  
    Working...
    X