Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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.DrawingTools;
- #endregion
- //This namespace holds Indicators in this folder and is required. Do not change it.
- namespace NinjaTrader.NinjaScript.Indicators
- {
- public class BasicModifyPropertyAttribute : Indicator
- {
- private bool disableTestProperty;
- protected override void OnStateChange()
- {
- if (State == State.SetDefaults)
- {
- Description = @"Example of how to dynamically change the read-only attribute for properties.";
- Name = "BasicModifyPropertyAttribute";
- Calculate = Calculate.OnBarClose;
- IsOverlay = false;
- DisplayInDataBox = true;
- DrawOnPricePanel = true;
- DrawHorizontalGridLines = true;
- DrawVerticalGridLines = true;
- PaintPriceMarkers = true;
- ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
- IsSuspendedWhileInactive = true;
- DisableTestProperty = false;
- }
- }
- protected override void OnBarUpdate()
- {
- //Add your custom indicator logic here.
- }
- [RefreshProperties(RefreshProperties.All)]
- [Display(Name = "DisableTestProperty", GroupName = "1. Settings", Order = 0)]
- public bool DisableTestProperty
- {
- get { return disableTestProperty; }
- set
- {
- disableTestProperty = value;
- BrowsableAttribute theDescriptorBrowsableAttribute = TypeDescriptor.GetProperties(this.GetType())["TestProperty"].Attributes[typeof(BrowsableAttribute)] as BrowsableAttribute;
- System.Reflection.FieldInfo isBrowsable = theDescriptorBrowsableAttribute.GetType().GetField("Browsable", System.Reflection.BindingFlags.IgnoreCase | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
- isBrowsable.SetValue(theDescriptorBrowsableAttribute, value);
- }
- }
- [ReadOnly(false)]
- [Browsable(true)]
- [Display(Name = "TestProperty", GroupName = "1. Settings", Order = 1)]
- public string TestProperty { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement