Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Super Simple Indicator keeps on loading om some timeframes

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

    Super Simple Indicator keeps on loading om some timeframes

    Hi
    I have a super simple indicator I hace placed on 4 charts, but some of the charts it seems that eventhough the data are there the indicator keeps on loading.
    I need to close the window and create a new one then it works again until I change symbol then it crashes again sometimes please see attached image.
    I use Interactive Brokers as the data provider.


    Code:
    public class TheStratScenarios : Indicator
    {
    private string scenario;
    private SolidColorBrush scenarioBrush;
    
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "TheStratScenarios";
    Calculate = Calculate.OnBarClose;
    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;
    
    //Setting Default Colors
    ColorIB = Brushes.Gold;
    ColorTrend = Brushes.White;
    ColorOB = Brushes.Red;
    }
    else if (State == State.Configure)
    {
    }
    }
    
    protected override void OnBarUpdate()
    {
    if(CurrentBar==0)
    return;
    
    string scenario = GetScenario();
    //Draw.Text(this, CurrentBar.ToString(), scenario, 0, Low[0] - (Low[0]/150),scenarioBrush );
    
    Draw.Text(this,CurrentBar.ToString(),false,scenari o,0, Low[0], -80, scenarioBrush, new SimpleFont("Verdana",12), TextAlignment.Center,Brushes.Transparent,Brushes.T ransparent,0);
    }
    
    private string GetScenario()
    {
    string scenario = "0";
    if(High[0] <= High[1] && Low[0] >= Low[1])
    {//Inside Bar
    scenario = "1";
    scenarioBrush = ColorIB;
    }
    else if (High[0] >= High[1] && Low[0] >= Low[1])
    {
    scenario = "2u";
    scenarioBrush = ColorTrend;
    }
    else if (High[0] <= High[1] && Low[0] <= Low[1])
    {
    scenario = "2d";
    scenarioBrush = ColorTrend;
    }
    else if (High[0] > High[1] && Low[0] < Low[1])
    {
    scenario = "3";
    scenarioBrush = ColorOB;
    }
    
    return scenario;
    }
    [XmlIgnore]
    [ NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Color IB (1)", GroupName = "NinjaScriptParameters", Order = 0)]
    public SolidColorBrush ColorIB
    { get; set; }
    
    [XmlIgnore]
    [ NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Color Trend (2)", GroupName = "NinjaScriptParameters", Order = 0)]
    public SolidColorBrush ColorTrend
    { get; set; }
    
    [XmlIgnore]
    [ NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Color OB (3)", GroupName = "NinjaScriptParameters", Order = 0)]
    public SolidColorBrush ColorOB
    { get; set; }
    }
    Attached Files

    #2
    Hello SuneSorgenfrei,

    Thank you for your post.

    The glaring issue I see in your script is that you're referring to SolidColorBrush but using predefined WPF brushes, and I don't see that you're properly serializing the brushes. I suspect the errors you're receiving likely have to do with that. Here's the revisions I would suggest:

    Code:
    public class TheStratScenarios : Indicator
    {
    private string scenario;
    private Brush scenarioBrush;
    
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "TheStratScenarios";
    Calculate = Calculate.OnBarClose;
    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;
    
    //Setting Default Colors
    ColorIB = Brushes.Gold;
    ColorTrend = Brushes.White;
    ColorOB = Brushes.Red;
    }
    else if (State == State.Configure)
    {
    }
    }
    
    protected override void OnBarUpdate()
    {
    if(CurrentBar==0)
    return;
    
    string scenario = GetScenario();
    //Draw.Text(this, CurrentBar.ToString(), scenario, 0, Low[0] - (Low[0]/150),scenarioBrush );
    
    Draw.Text(this,CurrentBar.ToString(),false,scenari o,0, Low[0], -80, scenarioBrush, new SimpleFont("Verdana",12), TextAlignment.Center,Brushes.Transparent,Brushes.T ransparent,0);
    }
    
    private string GetScenario()
    {
    string scenario = "0";
    if(High[0] <= High[1] && Low[0] >= Low[1])
    {//Inside Bar
    scenario = "1";
    scenarioBrush = ColorIB;
    }
    else if (High[0] >= High[1] && Low[0] >= Low[1])
    {
    scenario = "2u";
    scenarioBrush = ColorTrend;
    }
    else if (High[0] <= High[1] && Low[0] <= Low[1])
    {
    scenario = "2d";
    scenarioBrush = ColorTrend;
    }
    else if (High[0] > High[1] && Low[0] < Low[1])
    {
    scenario = "3";
    scenarioBrush = ColorOB;
    }
    
    return scenario;
    }
    #region Properties
    [XmlIgnore]
    [ NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Color IB (1)", GroupName = "NinjaScriptParameters", Order = 0)]
    public Brush ColorIB
    { get; set; }
    
    [Browsable(false)]
    public string ColorIBSerialize
    {
    get { return Serialize.BrushToString(ColorIB); }
    set { ColorIB = Serialize.StringToBrush(value); }
    }
    
    [XmlIgnore]
    [ NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Color Trend (2)", GroupName = "NinjaScriptParameters", Order = 0)]
    public Brush ColorTrend
    { get; set; }
    
    [Browsable(false)]
    public string ColorTrendSerialize
    {
    get { return Serialize.BrushToString(ColorTrend); }
    set { ColorTrend = Serialize.StringToBrush(value); }
    }
    
    [XmlIgnore]
    [ NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Color OB (3)", GroupName = "NinjaScriptParameters", Order = 0)]
    public Brush ColorOB
    { get; set; }
    
    [Browsable(false)]
    public string ColorOBSerialize
    {
    get { return Serialize.BrushToString(ColorOB); }
    set { ColorOB = Serialize.StringToBrush(value); }
    }
    #endregion
    }
    I would suggest reviewing this page of our help guide on working with Brushes:

    https://ninjatrader.com/support/help...th_brushes.htm

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by POTTER16, Today, 03:31 PM
    0 responses
    4 views
    0 likes
    Last Post POTTER16  
    Started by enricbcn, 05-08-2018, 01:36 AM
    78 responses
    43,514 views
    1 like
    Last Post Wessel
    by Wessel
     
    Started by Wessel, Today, 12:50 PM
    0 responses
    8 views
    0 likes
    Last Post Wessel
    by Wessel
     
    Started by asmmbillah, Today, 12:39 PM
    0 responses
    8 views
    0 likes
    Last Post asmmbillah  
    Started by dtmtradingco, Today, 12:30 PM
    0 responses
    7 views
    0 likes
    Last Post dtmtradingco  
    Working...
    X