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

Getting the new Price when de HorizontalLine Move

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

    Getting the new Price when de HorizontalLine Move

    Hello.

    I'm developing an indicator. This indicator draw an horizontal line over the chart with the function Draw.HorizontalLine(). I have an object HorizontalLine to save the object retorned.

    Like:

    Horizontal LineLmt = Draw.HorizontalLine(this, IdLimit.ToString(), openOrderMessage.Order.LmtPrice, Brushes.Red);

    I would like to get the new anchor(price) when the line is move on the chart..

    I don't know how to do it.

    Anyone can help me?

    Thanks...

    #2
    Hello brokerbombero,

    Thank you for the post.

    In this situation, there is not a specific event that would be triggered for the lines moving. You could possibly use OnRender to read the value while the chart is being re-rendered.

    It would also depend on when you need to read the value, if this is being used in OnBarUpdate nothing additional would be needed as you have an instance to the object, you may just need to make a class level variable instead if you have not already. If that is the case you could just access the objects anchors to gather their prices when OnBarUpdate is called.

    Can you provide more detail on what the end goal is, that would help me determine what direction you might want to take here.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I found the solution

      Hello.

      I'm developing an indicator, that it send order to another broker. So I wanted to simulate the same functionality that when you place an order on the chart with NinjaTrader8, it draw a line and you can move this line over the chart, and the price of the Stop or Limit change.
      Inside DrawingTools
      The solution it's to Create a new public class PintaOrden : Line, INotifyPropertyChanged
      { ......

      Inside this class I have added some properties necessaries for me, one of the Price.

      I have override OnMouseUp (when the user leave the line on the chart), inside this method a get the new price, and raise the event OnPropertyChange.

      public override void OnMouseUp(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint)
      {
      base.OnMouseUp(chartControl, chartPanel, chartScale, dataPoint);
      //Print("Ha terminado de moverse la orden "+IdOrden+"siendo el precio: "+EndAnchor.Price);
      Precio = EndAnchor.Price;

      }

      So inside of the indicator, I know that the price has change, so I can cancel the old order, and I put the new one.

      Inside of the indicator it's necessary to create a new object of PintaOrden and subscribe to the event OnPropertyChange.

      The solution it could be a little complicated, but it's works for me.

      Thanks a lot.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by f.saeidi, Today, 05:56 AM
      1 response
      3 views
      0 likes
      Last Post Jltarrau  
      Started by Jltarrau, Today, 05:57 AM
      0 responses
      4 views
      0 likes
      Last Post Jltarrau  
      Started by Stanfillirenfro, Yesterday, 09:19 AM
      7 responses
      51 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by TraderCro, 04-12-2024, 11:36 AM
      4 responses
      70 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Mindset, Yesterday, 02:04 AM
      1 response
      15 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X