I'm trying to remove the Decimals from the text that is printing on the screen. I can't seem to figure out where to put the FormatPrice script (not sure if this is what I really need to use).
Any help would be greatly appreciated.
Thank you for your time.
James
#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.Gui.Tools;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.Indicators;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
//This namespace holds Strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies
{
public class myATR : Strategy
{
private double CurrentATR;
private ATR ATR1;
private Gui.Tools.SimpleFont textFont;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "myATR";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
ATRperiod = 5;
textFont = new Gui.Tools.SimpleFont("Arial", 14);
TextColor = Brushes.Red;
TextBackColor = Brushes.Yellow;
myTextBox = TextPosition.BottomRight;
CurrentATR = 0;
}
else if (State == State.Configure)
{
}
else if (State == State.DataLoaded)
{
ATR1 = ATR(Close, Convert.ToInt32(ATRperiod));
}
}
// FormatPriceMarker method of a custom indicator
public override string FormatPriceMarker(double price)
{
// Formats price marker values to 4 decimal places
return price.ToString("N0");
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
// Set 1
if (ATR1[0] > 0)
{
CurrentATR = ATR1[0];
Draw.TextFixed(this, @"myATR", Convert.ToString(CurrentATR), myTextBox, TextColor, TextFont, Brushes.Transparent, TextBackColor, 100 );
}
}
#region Properties
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="ATRperiod", Order=1, GroupName="Parameters")]
public int ATRperiod
{ get; set; }
[Display(Name="Text box location", Description="Select text location", Order=1, GroupName="Parameters")]
public TextPosition myTextBox
{ get; set; }
[Display(Name = "Text Font", Description= "Select font, style, size to display on chart", GroupName= "Parameters", Order= 2)]
public Gui.Tools.SimpleFont TextFont
{
get { return textFont; }
set { textFont = value; }
}
[XmlIgnore]
[Display(Name="Text Color", Description="Text color ", Order=3, GroupName="Parameters")]
public Brush TextColor
{ get; set; }
[Browsable(false)]
public string TextColorSerializable
{
get { return Serialize.BrushToString(TextColor); }
set { TextColor = Serialize.StringToBrush(value); }
}
[XmlIgnore]
[Display(Name="Text Background color", Description="Background color ", Order=4, GroupName="Parameters")]
public Brush TextBackColor
{ get; set; }
[Browsable(false)]
public string TextBackColorSerializable
{
get { return Serialize.BrushToString(TextBackColor); }
set { TextBackColor = Serialize.StringToBrush(value); }
}
#endregion
}
}

Comment