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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    60 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    146 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    161 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    97 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    284 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X