Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting up parameters with click mouse and values with drawing objects

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

    Setting up parameters with click mouse and values with drawing objects

    I am having an issue setting double bool and timestamps for some reason my function will not set the parameters.
    When I use mouse click I can get the the x and y values, but I want to place those values in a new parameter. For some reason it will not allow me. Here is the code.

    private void btnRay_Click(object sender, EventArgs e)
    {

    SendKeys.SendWait("{F3}");
    Print("Ray Anchors Reset"); // wierd thing is Ray Anchors Reset shows but the printed bool value will not
    bStartAnchor= true;
    Print(bStartAnchor.ToString());
    }

    //second section

    protected void MouseClicked(object sender, MouseButtonEventArgs e)
    {
    // convert e.GetPosition for different dpi settings
    clickPoint.X = ChartingExtensions.ConvertToHorizontalPixels(e.Get Position(ChartPanel as IInputElement).X, ChartControl.PresentationSource);
    clickPoint.Y = ChartingExtensions.ConvertToVerticalPixels(e.GetPo sition(ChartPanel as IInputElement).Y, ChartControl.PresentationSource);

    convertedPrice = Instrument.MasterInstrument.RoundToTickSize(chartS cale.GetValueByY((float)clickPoint.Y));

    convertedTime = ChartControl.GetTimeBySlotIndex((int)ChartControl. GetSlotIndexByX((int)clickPoint.X));

    Print(convertedPrice); // Converted price and Time will display
    Print(convertedTime);
    Print("^^^^^^^^^^^^^^^^^");
    Print(bStartAnchor);

    startconvertedPrice =convertedPrice;
    startconvertedTime = convertedTime;

    if(bStartAnchor == true) // anchor never changed to true
    {
    Print(startconvertedPrice); // will not display
    Print(startconvertedTime);
    bStartAnchor = false;
    }

    }


    EVEN when the flag is changed to true from the button ray it never does? I need the start and the end anchor points I will need anchor points everytime a Draw and object. The objects I am drawing are rays, horizontal lines rectangles etc.

    Click image for larger version

Name:	nin.PNG
Views:	291
Size:	11.1 KB
ID:	1130919

    #2
    I got it to work. The issue I had restart ninjatrader. I have to find the bug. Every time i use refresh, the indicator does not work. It works well until a refresh

    Comment


      #3
      Hello ballboy11,

      One note, if you doing anything that involves a series, like modifying a drawing object, getting the time or indicator price or close price, you must use TriggerCustomEvent() in a non-data-driven method like a mouse event handler.



      I don't see bStartAnchor declared, but if this actually an anchor then it's tied to the chart bars series and TriggerCustomEvent() needs to be used before getting this value.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

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