Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting an error when moving a drawing tool

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

    Getting an error when moving a drawing tool

    Hi,

    I've created a drawing tool that draws a zone. The tool is derived from the RegionHighlightBase.
    When I attach the tool to All Charts and try to move it around the chart, the screen freeze for many seconds, and under the log screen, I see the message:
    "Error on getting/setting property 'InitialMouseDownAnchor' for NinjaScript 'Zone': Exception has been thrown by the target of an invocation."

    If I change the Attach To property to just the current chart, there is no problem.

    Can you think of a reason this happens?

    Below is the code:

    public override void OnMouseMove(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint)
    {
    base.OnMouseMove(chartControl, chartPanel, chartScale, dataPoint);

    StartAnchor.Price = Math.Round(StartAnchor.Price * 4, MidpointRounding.ToEven) / 4;
    EndAnchor.Price = Math.Round(EndAnchor.Price * 4, MidpointRounding.ToEven) / 4;
    Tag = String.Format("@Z {0:0.00}-{1:0.00}", Math.Round(StartAnchor.Price * 4, MidpointRounding.ToEven) / 4, Math.Round(EndAnchor.Price * 4, MidpointRounding.ToEven) / 4);


    if (StartAnchor.Price != lastStartAnchorPrice || EndAnchor.Price != lastEndAnchorPrice)
    {
    if (lastEndAnchorPrice != 0 && disableUponMove)
    {

    Active = false;
    }
    lastStartAnchorPrice = StartAnchor.Price;
    lastEndAnchorPrice = EndAnchor.Price;
    }

    }​

    #2
    Hello ofiramitai,

    Thanks for your post.

    I have moved this forum post to the NinjaTrader Desktop General Development section of the Forums since the question is related to creating a DrawingTool and not specifically an Indicator.

    That said, it could be possible that you are causing an endless loop in the script. When working with any issue, it is important to take steps to isolate the issue so that the exact line causing the behavior can be found. This is a process of elimination and a process of debugging by adding prints.

    I suggest reducing the script by ​commenting out code until the behavior stops. Then uncomment lines of code until the behavior returns to identify the specific line causing the behavior in your script. Debugging prints may also be added to narrow in on the offending code.

    Let me know if you have further questions.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X