Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rounding EMA

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

    Rounding EMA

    I like to round an EMA to a wished format ie : 121.25 instead of 121.2469857...

    I want to use the rounded EMA value in a strategy. If the EMA value of the current bar is equal to the value of the previous bar than an entry (long or short) is not allowed. But I want the EMA in that condition to be rounded to 2 numbers behind the point - like 121.25 instead of 121.2469857

    I have seen things like using 'math.round' and 'round2ticksize' on the forum. However, in these posts there are no examples of what the programming should look like. Since I'm a newbie to programming, has anybody any ideas or an example?

    Thanks in advance.

    #2
    Welcome to our forums.

    Correct one approach would be using Math.Round straight from C#, just supply it the double value you wish to round i.e. Math.Round(EMA(20)[0]) - that would be for the current bars EMA value.

    Round2TickSize would be a NinjaScript method - Instrument.MasterInstrument.Round2TickSize(EMA(20)[0])

    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