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

How can I make an Addon that reads manually drawn fib levels?

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

    How can I make an Addon that reads manually drawn fib levels?

    I drew a fib retracement on the chart, and ran below addon code on button_click event:
    ----
    ChartControl CC=myChart.ActiveChartControl;
    for(int i = CC.ChartPanels[0].ChartObjects.Count-1; i >=0; i--)
    {
    string s=CC.ChartPanels[0].ChartObjects[i].Name;
    if(s=="Fibonacci retracements")
    {
    Print("Found Fib");
    ChartScale CS=CC.ChartPanels[0].Scales[1];
    Point[] pts=CC.ChartPanels[0].ChartObjects[i].GetSelectionPoints(CC,CS);
    foreach (Point pt in pts)
    {
    Print(pt.ToString());
    }
    break;
    }
    else Print(s);
    }
    ----
    The result is:
    ----
    Found Fib
    0,0
    0,0
    0,0
    ----
    How do I make the Addon read the selection points successfully?
    Thank you!

    #2
    Hi xxzbill, thanks for your note.

    I have an example here that detects manually drawn horizontal lines and labels them:
    This indicator will read the horizontal lines that you have applied to a chart and display the price at which that line sits.


    If you could make a reduced copy of your script I would be happy to take a look at it if the above does not resolve your inquiry.

    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chris for the tremendous help. I was able to read fib levels learning from your suggested codes.

      I am trying to accomplish the following:
      1.manually draw fib retracement on chart
      2.manually click my custom button added to chartTrader part of chart
      3.button_click automatically reads the price of a specific fib level, and places entry buy
      4.on fill of entry buy, addon automatically sends stop loss and take profit bracket orders

      I have finished step 3. Now stuck on step 4.
      OnOrderUpdate event doesn't seem to work in the addon namespace (only in indicators and strategies).
      How can I detect entry order fill from an AddOn?

      (edited for related questions)
      -A 2nd question if possible, on button_click event, I also want to send stop buy orders that is 4 tick above last trade price. I got everything figured out except how to get the the last trade price from within the button_click event.

      -Another question, on button_click event, I also hope to send buy order at price of the current mouse cursor position on the chart. Would it be possible to read price level corresponding to mouse cursor position on the chart?

      Thank you for any insight!
      Thank you !
      Last edited by xxzbill; 03-22-2020, 06:12 PM.

      Comment


        #4
        Hello xxzbill,

        Any NinjaScript can subscribe to Account OrderUpdate events to receive order update events for that account.

        I have an example indicator that implements AddOn code for submitting orders with Account.CreateOrder and Account.Submit. This example submits orders to the price level clicked on the chart. It also uses TriggerCustomEvwent on the button press so the reference to Close[0] is accurate.

        Account.CreateOrder - https://ninjatrader.com/support/help...reateorder.htm

        Account.Submit - https://ninjatrader.com/support/help...nt8/submit.htm

        TriggerCustomEvent - https://ninjatrader.com/support/help...ustomevent.htm

        I look forward to assisting.
        Attached Files
        JimNinjaTrader Customer Service

        Comment


          #5
          Thank you very much. These information is helping me along quite well.

          Question, after creating an order with myAccount.CreateOrder() and before myAccount.Submit() it, it seems impossible to cancel it(in case the market changes and I no longer want the order). If I just myAccount.Cancel() the order (without account.submit first), NT order page will say "Cancel pending", there will be an reverse order line on the chart trader, and there is nothing I can manually do to progress from this order status except reset the sim account.

          It seems after account.CreateOrder, the order is not only stored in an order object, it is also stored as part of the account. There is no account.DeleteOrder to remove it from the account. At this point if I don't want the order to carry out, I can either submit it and immediately cancel it, or cancel without being submitted which will stuck it in "Cancel pending" status. Besides these 2 ways, is there a better way to cancel the order created by account.CreateOrder?

          Thank you!

          Comment


            #6
            Hello xxzbill,

            The order will need to be submitted first before it can be cancelled. Cancelling before submission would not be proper usage and the order may then get stuck where resetting the sim account would be necessary to get the order unstuck. I would suggest setting the order object to null if you don't want to submit it.

            We look forward to assisting.
            JimNinjaTrader Customer Service

            Comment


              #7
              Thank you. That makes sense.

              Another question, would you know an indicator/addon that reads past trades in an account, and plot a green/red line from open order to close order for win/loss trades?

              Thank you!

              Comment


                #8
                Hello xxzbill,

                Thanks for your message.

                Reading past trades from the account would require accessing the NinjaTrader SQL database. This would exceed the level of support that we could offer, but I could point you to a NinjaTrader 7 thread where community members discuss reading the database file.

                https://ninjatrader.com/support/foru...sample?t=10296

                We look forward to assisting.
                JimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Tim-c, Today, 02:10 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by Taddypole, Today, 02:47 PM
                0 responses
                2 views
                0 likes
                Last Post Taddypole  
                Started by chbruno, 04-24-2024, 04:10 PM
                4 responses
                50 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Started by TraderG23, 12-08-2023, 07:56 AM
                10 responses
                401 views
                1 like
                Last Post beobast
                by beobast
                 
                Started by lorem, Yesterday, 09:18 AM
                5 responses
                25 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Working...
                X