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

Draw.VerticalLine success until it fails! Are there any Limits ?

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

    Draw.VerticalLine success until it fails! Are there any Limits ?

    Hello All,

    I am drawing a large number of Vertical Lines successfully in a strategy. I current have 5 indicators which all use the same code snittip below. My problem is on the last indicator I cannot use these lines:
    SellCrossVerticalLine.Stroke.Opacity = 15; // % transparent
    SellCrossVerticalLine.Stroke.Width = 3; // 7 pixels wide
    without returning this error:
    Error on calling 'OnBarUpdate' method on bar 508: Object reference not set to an instance of an object.

    It seems I am having a problem referencing the VerticalLine returned Object. I would like to test for its validity to furthor understand my problem. All of my vertical lines have a somewhat unique tag string

    tag = ProcDescript = Instrument.FullName + "." + BarsPeriod.Value + "_" + Name + "_" + "_XBelow_" + Bars.GetTime(CurrentBars[0]).Minute

    as you can see below. I understand for each indicator I will have 4 cases and each with a "Minute" base unique tag. I don't mind it they are overwritten intime.

    When I run my set of Indicators in a strategy it will fail like mention above unless I comment out all references to the return VerticalLine object only in the Last indicator as written/refernced in the Strategey script.

    Why is this happening? What can I do make this work consistantly?

    Thank you for your time and consideration




    Code Looks like this:
    //************************************************** **********
    //************** Turn UP or Turn Down ************************
    //************************************************** **********


    turnLong[0] = TurnUP(Values[2], 50.0, DebugPrint, ProcDescript + Bars.GetTime(CurrentBars[0]));
    if (turnLong[0])
    {
    BuyTurnVerticalLine = Draw.VerticalLine(this, ProcDescript + "_TurnUP_" + Bars.GetTime(CurrentBars[0]).Minute, 0, Brushes.Green, DashStyleHelper.Solid, 2, false);
    BuyTurnVerticalLine.Stroke.Opacity = 25;
    BuyTurnVerticalLine.Stroke.Width = 5;
    }
    else
    {
    turnShort[0] = TurnDown(Values[2], 50.0, DebugPrint, ProcDescript + Bars.GetTime(CurrentBars[0]));
    if (turnShort[0])
    {
    SellTurnVerticalLine = Draw.VerticalLine(this, ProcDescript + "_TurnDown_" + Bars.GetTime(CurrentBars[0]).Minute, 0, Brushes.Red, DashStyleHelper.Solid, 2, false);
    SellTurnVerticalLine.Stroke.Opacity = 15; // % transparent
    SellTurnVerticalLine.Stroke.Width = 5; // 7 pixels wide
    }
    }

    crossLong[0] = XAbove(Values[1], Values[2], 50.0 , 1, DebugPrint, ProcDescript + Bars.GetTime(CurrentBars[0]));
    if (crossLong[0])
    {
    BuyCrossVerticalLine = Draw.VerticalLine(this, ProcDescript + "_XAbove_" + Bars.GetTime(CurrentBars[0]).Minute, 0, Brushes.Green, DashStyleHelper.Solid, 2, false);
    BuyCrossVerticalLine.Stroke.Opacity = 25;
    BuyCrossVerticalLine.Stroke.Width = 3;
    }
    else
    {
    crossShort[0] = XBelow(Values[1], Values[2], 50.0 , 1, DebugPrint, ProcDescript + Bars.GetTime(CurrentBars[0]));
    if (crossShort[0])
    {
    SellCrossVerticalLine = Draw.VerticalLine(this, ProcDescript + "_XBelow_" + Bars.GetTime(CurrentBars[0]).Minute, 0, Brushes.Red, DashStyleHelper.Solid, 2, false);
    SellCrossVerticalLine.Stroke.Opacity = 15; // % transparent
    SellCrossVerticalLine.Stroke.Width = 3; // 7 pixels wide
    }
    }


    #2
    Hello MartinT,

    Thank you for your note.

    To clarify, is it specifically the set with these lines on which the error occurs?

    SellCrossVerticalLine.Stroke.Opacity = 15; // % transparent
    SellCrossVerticalLine.Stroke.Width = 3; // 7 pixels wide

    I'm not seeing anything obvious here that would cause an error, however, I'd want to see a reduced example strategy that replicates the behavior you're experiencing. Any code unnecessary to reproduce (such as order submission) should be removed. You can either attach your reduced example to your reply here, or if you'd rather not post it publicly, you can send it to us directly via platformsupport [at] ninjatrader [dot] com. If you send it via email, please put "2649858 ATTN Kate W." in the subject line and provide a link to this post in the body of the email.

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate,

      Thank you for your response,
      Yes, the Error occurs with those lines. I had narrowed it down to them using print statements. It may only be the Opacity statement in fact but I included both because the both are related to the Stroke object. The thing is I can use multiple (5x) instances of this indicator with the problem code on a chart not integrated in a strategy and it will work. Being able to check the return object/value would be a big help. I will look into building a simple strategy that demostrates the problem and get back to you. It may take sometime to do.

      Comment


        #4
        Hi Kate,
        I tried cutting my strategy down to bare bones. I found the error did not occur. I guess I will just work around it.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by nandhumca, Today, 03:41 PM
        0 responses
        4 views
        0 likes
        Last Post nandhumca  
        Started by The_Sec, Today, 03:37 PM
        0 responses
        3 views
        0 likes
        Last Post The_Sec
        by The_Sec
         
        Started by GwFutures1988, Today, 02:48 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by ScottWalsh, 04-16-2024, 04:29 PM
        6 responses
        33 views
        0 likes
        Last Post ScottWalsh  
        Started by frankthearm, Today, 09:08 AM
        10 responses
        36 views
        0 likes
        Last Post frankthearm  
        Working...
        X