Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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])

    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by burtoninlondon, Today, 12:38 AM
    0 responses
    5 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    12 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    13 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,982 views
    3 likes
    Last Post jhudas88  
    Working...
    X