Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

4 digit precision instead of 5 digit precision

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

  • junkone
    replied
    if you are a trader and attach a order to the indicator, in Forex, the change order exceeds 120 changes every minute.
    i created a override EMA indicator that rounds to half pip instead of 1/10 of pip.
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class CustomEMA : Indicator
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "CustomEMA";
    Calculate = Calculate.OnPriceChange;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    Period = 1;
    AddPlot(Brushes.Tomato, "TrimmedEMA");
    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    Value[0]= Math.Round(EMA(Period)[0],4);
    if(IsFirstTickOfBar)
    Print("rounded value " + RoundUpToNearest(EMA(Period)[0]) + "original " + EMA(Period)[0]);

    }

    public Double RoundUpToNearest(Double passednumber)
    {
    if(TickSize==.00001)
    return Math.Round(passednumber*2,4)/2;
    else
    return Math.Round(passednumber*2,2)/2;

    }


    #region Properties
    [Range(1, int.MaxValue)]
    [NinjaScriptProperty]
    [Display(Name="Period", Order=1, GroupName="Parameters")]
    public int Period
    { get; set; }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> TrimmedEMA
    {
    get { return Values[0]; }
    }
    #endregion

    }
    }

    #region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private CustomEMA[] cacheCustomEMA;
    public CustomEMA CustomEMA(int period)
    {
    return CustomEMA(Input, period);
    }

    public CustomEMA CustomEMA(ISeries<double> input, int period)
    {
    if (cacheCustomEMA != null)
    for (int idx = 0; idx < cacheCustomEMA.Length; idx++)
    if (cacheCustomEMA[idx] != null && cacheCustomEMA[idx].Period == period && cacheCustomEMA[idx].EqualsInput(input))
    return cacheCustomEMA[idx];
    return CacheIndicator<CustomEMA>(new CustomEMA(){ Period = period }, input, ref cacheCustomEMA);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.CustomEMA CustomEMA(int period)
    {
    return indicator.CustomEMA(Input, period);
    }

    public Indicators.CustomEMA CustomEMA(ISeries<double> input , int period)
    {
    return indicator.CustomEMA(input, period);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.CustomEMA CustomEMA(int period)
    {
    return indicator.CustomEMA(Input, period);
    }

    public Indicators.CustomEMA CustomEMA(ISeries<double> input , int period)
    {
    return indicator.CustomEMA(input, period);
    }
    }
    }

    #endregion

    Leave a comment:


  • NinjaTrader_PatrickG
    replied
    Pip size is determined automatically from the provider. This is to prevent rounding issues when configuring a pip size which is not native to the provider.

    Everything in NinjaTrader 8 is Tenth-pip under the hood and will display in whichever format the provider sends.

    This is not possible to configure.

    Leave a comment:


  • junkone
    started a topic 4 digit precision instead of 5 digit precision

    4 digit precision instead of 5 digit precision

    how can i force a 4 digit precision for forex (eur/gbp/aud) and 2 digit precision(jpy) instead of the extra1/10 precision that i have today?
    the reason is that there are too many order changes that happens when i attach the order to indicator. the 1/10 precision is way too much for my simple systems.

Latest Posts

Collapse

Topics Statistics Last Post
Started by cre8able, 02-11-2023, 05:43 PM
3 responses
232 views
0 likes
Last Post rhubear
by rhubear
 
Started by frslvr, 04-11-2024, 07:26 AM
8 responses
111 views
1 like
Last Post NinjaTrader_BrandonH  
Started by stafe, 04-15-2024, 08:34 PM
10 responses
44 views
0 likes
Last Post stafe
by stafe
 
Started by rocketman7, Today, 09:41 AM
3 responses
8 views
0 likes
Last Post NinjaTrader_Jesse  
Started by traderqz, Today, 09:44 AM
2 responses
5 views
0 likes
Last Post NinjaTrader_Gaby  
Working...
X