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

Buy sell signals

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

    Buy sell signals

    Dear NT7 support team,

    I have developed an indicator for NT7 version and trying to generate buy and sell signals based on OHLC data. I completed the code and compiled it successful. But, I'm not seeing the BUY / SELL arrows in chart. Could you please help me to get this issue resolved. Any sample code will also help.

    Thankyou

    #2
    Hello radhmu978,

    Welcome to the NinjaTrader forums!

    The OHLC can be obtained by calling the CurrentDayOHL() indicator and the current Close[0].



    You can draw arrows with DrawArrowUp() and DrawArrowDown() when the condition is true.



    You can send signals to a calling host script by setting a plot value in an indicator. Below is a link to an example.


    I am also including a link to a forum post with helpful information about getting started with NinjaScript and C#.



    One note, if you are just starting out, I would highly recommend starting with NinjaTrader 8 and not NinjaTrader 7 so your code doesn't quickly become obsolete.
    NinjaTrader 7 is no longer in active development and we are no longer considering new feature requests for NinjaTrader 7. Main development has shifted to our flagship platform NinjaTrader 8. This does mean updates from brokerages, data feeds, or operating systems that require an update in NinjaTrader will not be implemented in NinjaTrader 7 and may cause an interruption in service.

    While there is not a set ETA for the complete discontinuation of NinjaTrader 7, we highly recommend transitioning to NinjaTrader 8 as soon as possible before NinjaTrader 7 reaches its end of life to prevent interruption of service.

    Click below to download NinjaTrader 8.
    NinjaTrader is a futures trading platform that delivers integrated multi-device trading. Discover our best platform to trade futures for active futures traders.


    I'm also including a link to a forum post with the same information about getting started with NinjaScript and C# for NinjaTrader 8.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you. Will check the links. I have a pinescript that gives BUY/SELL alert in trading view. I'm trying to implement the same in NT7 and NT8. NT7 indicator that i creatd is displaying the plot in the bottom of the chart. Could you please check the screen cast link from trading view and NT7 chart. I want the match the output of tradingview.

      https://www.screencast.com/t/8RS8SBF5T - NT7 chrt

      https://www.screencast.com/t/JcolLFbD9BT - Tradingview
      Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.

      Comment


        #4
        Hello radhmu978,

        I wouldn't be able to advise on how another platform works or if the connection to data is the same data source.

        You can use prints however, to find out what is different. Such as printing the time of the bar and the open, high, low, and close. Keep in mind different data providers may have slightly different data.

        Below is a link to a forum post that demonstrates how to use prints to understand behavior.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you, will check. I want to know the functions that i can use in NT7 to display the buy, sell arrows with lable. include the code snippet from trading view pine script.

          plotarrow(series = isAbove ? 1 : isBelow ? -1 : na, colorup= color.lime, colordown = color.orange, maxheight=30)
          plotshape(series = isAbove ? 1 : na ,location = location.belowbar,color = color.green, style = shape.labelup, text = "BUY", textcolor = color.white)
          plotshape(series = isBelow ? 1 : na ,location = location.abovebar,color = color.orange, style = shape.labeldown, text = "SELL", textcolor = color.white)

          Comment


            #6
            Hello radhmu978,

            You can draw arrows with DrawArrowUp() and DrawArrowDown() when the condition is true.
            (Noted in post #2)
            https://ninjatrader.com/support/help...rawarrowup.htm
            https://ninjatrader.com/support/help...warrowdown.htm

            For a label you can use DrawText().
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Where exactly I need to place the drawArrow functions? When i started the indicator, I created 2 plot in indicator wizard


              protected override void Initialize()
              {
              Add(new Plot(Color.FromKnownColor(KnownColor.OrangeRed), PlotStyle.TriangleDown, "Sell"));
              Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.TriangleUp, "Buy"));
              Overlay = true;
              }

              but I need to draw up/down arrows

              DrawArrowDown(CurrentBar.ToString(), true, 0, Buy, Color.Blue);
              DrawArrowUp(CurrentBar.ToString(), true, 0, Sell, Color.Red);

              Comment


                #8
                Hello radhmu978,

                In the action block of the condition that when true you want to see arrows.

                if (/* condition here */)
                {
                DrawArrowDown(CurrentBar.ToString(), true, 0, High[0] + 2 * TickSize, Color.Blue);
                }
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I see some error in during the runtime, issue is with the CurrentDayOHL

                  Made it to line 84
                  Error on calling 'OnBarUpdate' method for indicator 'RMPriceAction' on bar 1: Object reference not set to an instance of an object.

                  closeOrg[0] = (CurrentDayOHL().CurrentOpen[0] + CurrentDayOHL().Close[0] + CurrentDayOHL().CurrentLow[0] + CurrentDayOHL().CurrentHigh[0])/4;

                  If you want I can send the full source code, including the pinescript logic that i'm trying to implement in NT7, Could you please check and let me know where I went wrong? is there an email i can use to send the details?

                  Comment


                    #10
                    Hello radhmu978,

                    CurrentDayOHL().Close[0], is this meant to be Close[0]?


                    Make a new script to test that line of code.

                    Print((CurrentDayOHL().CurrentOpen[0] + Close[0] + CurrentDayOHL().CurrentLow[0] + CurrentDayOHL().CurrentHigh[0])/4);

                    Does this also have the error in the new test script?

                    What is closeOrg? Is this a custom series? Has this been instantiated as a new DataSeries in Initialize()?

                    Last edited by NinjaTrader_ChelseaB; 12-20-2021, 11:50 AM.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      ok, this line is working perfectly. Looks like CurrentDayOHL().Close[0] is the issue, I replaced the line with Close[0] now

                      Comment


                        #12
                        Still the same issue, test script is working but i still see exception

                        Print("Made it to line 84");
                        closeOrg[0] = ((CurrentDayOHL().CurrentOpen[0] + Close[0] + CurrentDayOHL().CurrentLow[0] + CurrentDayOHL().CurrentHigh[0])/4);
                        //Print((CurrentDayOHL().CurrentOpen[0] + Close[0] + CurrentDayOHL().CurrentLow[0] + CurrentDayOHL().CurrentHigh[0])/4);

                        ##output window
                        Made it to line 68
                        Made it to line 84
                        Error on calling 'OnBarUpdate' method for indicator 'RMPriceAction' on bar 1: Object reference not set to an instance of an object.

                        Comment


                          #13
                          Hello radhmu978,

                          If the test script is working, then its not the call to the CurrentDayOHL indicator likely causing the issue.

                          I was not able to confirm, what is closeOrg?
                          Is this a custom series?
                          Has this been instantiated as a new DataSeries in Initialize()?
                          https://ninjatrader.com/support/help...ries_class.htm
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Yes, it is a custom dataseries, I did not initialize. Do i need get, set for all custom dataseries?
                            close_org will hold the average and open_org has a recursive, self referencing data. Any reference on how to assign the recursive self referencing variable?

                            ##pinescript Snippet##
                            open_org = 0.0
                            close_org = (open + high + low + close ) / 4.0
                            open_org:= (nz(open_org[1]) + close_org[1] ) / 2.0

                            Comment


                              #15
                              Hello radhmu978,

                              Custom data series have to be initialized to an object in the Initialized method. Please see the help guide for the example.

                              No, you will not have to have an auto-get unless the series is meant to be accessed from another script. But the variable does have to have a data series object assigned to it.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by tsantospinto, 04-12-2024, 07:04 PM
                              7 responses
                              126 views
                              0 likes
                              Last Post aligator  
                              Started by futtrader, 04-21-2024, 01:50 AM
                              5 responses
                              56 views
                              0 likes
                              Last Post NinjaTrader_Eduardo  
                              Started by PeakTry, Today, 10:49 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post PeakTry
                              by PeakTry
                               
                              Started by llanqui, Today, 10:32 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post llanqui
                              by llanqui
                               
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              45 responses
                              3,994 views
                              3 likes
                              Last Post johntraderuser2  
                              Working...
                              X