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 Karado58, 11-26-2012, 02:57 PM
    8 responses
    14,828 views
    0 likes
    Last Post Option Whisperer  
    Started by Option Whisperer, Today, 09:05 AM
    0 responses
    1 view
    0 likes
    Last Post Option Whisperer  
    Started by cre8able, Yesterday, 01:16 PM
    3 responses
    11 views
    0 likes
    Last Post cre8able  
    Started by Harry, 05-02-2018, 01:54 PM
    10 responses
    3,204 views
    0 likes
    Last Post tharton3  
    Started by ChartTourist, Today, 08:22 AM
    0 responses
    6 views
    0 likes
    Last Post ChartTourist  
    Working...
    X