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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    67 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    36 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    60 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X