Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Buy sell signals

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

    #16
    Hi Chelsea - Thank you for your support. I resolved the runtime error by initializing the custom DataSeries. Now I'm able to plot the data on chart. But still I have an issue with the data. I'm trying to get the ohlc data from the chart, it could be 1 min, 3 min, 5 min or 8 Range 0r 500 ticks. Whatever the chart setting is, i want to pass the default data in chart setting for the calculation.

    CurrentDayOHL price is not reflecting the current price. Current price is 4641.75, but CurrentDayOHL open, close price is at 4605.

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

    How do i get the real time dataSeries from chart and pass it to the indicator?

    Click image for larger version

Name:	MES-1min.png
Views:	201
Size:	239.8 KB
ID:	1182577
    Thank you

    Comment


      #17
      Hello radhmu978,

      Print the CurrentDayOHL().CurrentOpen[0] with the time of the bar and include the output with your reply.


      Please show us this doesn't match the open of the session on the chart.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        No worries, I got it fixed - ((Open[0] + Close[0] + High[0] + Low[0])/4); is returning me the right data expected from the chart. Could you please let me know how to fill color betweenthe plot lines?
        Attached the chart from trading view and NT7 for reference.

        this is my pine script
        p1 = plot(wOpen, color=color.green,style = plot.style_circles,linewidth=1)
        p2 = plot(wClose, color=color.red,style = plot.style_circles,linewidth=1)

        fill(p1, p2, color = wClose > wOpen ? color.new(color.lime,30) : color.new(color.red,30))

        NT7 Script

        Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Sell"));
        Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Buy"));
        Buy.Set(wOpen[0]);
        Sell.Set(wClose[0]);
        Attached Files

        Comment


          #19
          Hello radhmu978,

          You can fill the region between plot lines with DrawRegion().

          Below is a link to the help guide.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            Thank you, will check the Drawregion. for the plot - I have initialize() and OnBarUpdate() functions. For DrawRegion() do we need to initialize something? in pinescript i use p1,p2 plot objects to fill color. is it possible to pass the 2 dataseries or the plat object to fill color in DrawRegion? if you can share some sample code snippet, it would be helpful.

            fill(p1, p2, color = wClose > wOpen ? color.new(color.lime,30) : color.new(color.red,30))

            Initialize()
            Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Sell"));
            Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Buy"));

            OnBarUpdate()
            Buy.Set(wOpen[0]);
            Sell.Set(wClose[0]);

            Comment


              #21
              Hello radhmu978,

              DrawRegion is a method that can be called from OnBarUpdate() and is not a variable that needs to be instantiated with an object. Please see the help guide on DrawRegion for the description and sample code.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #22

                I'm not getting the expected output, both colors are getting filled. DrawRegion is expecting multiple dataseries. Could you please check and help me to correct my NT7 script?

                pinescript

                fill(p1, p2, color = wClose > wOpen ? color.new(color.lime,30) : color.new(color.red,30))

                Ninjascripts

                if(wClose[0] > wOpen[0])
                DrawRegion("Buy", CurrentBar, 0, wOpen, wClose, Color.Empty, Color.Lime, 4);

                if(wClose[0] < wOpen[0])
                DrawRegion("Sell", CurrentBar, 0, wOpen , wClose, Color.Empty, Color.Red, 4);

                Comment


                  #23
                  Hello radhmu978,

                  Previously, in post # you have inquired:
                  "Could you please let me know how to fill color betweenthe plot lines?"

                  To confirm, you have two plots and you want to fill the color between these plots, is this correct?

                  This is what DrawRegion does. It fills the color between two plots.

                  Are you supplying plots as the inputs to DrawRegion?

                  When you say both colors are being filled, it appears you are drawing from the first bar of the chart (CurrentBar as barsAgo) to the current bar (0). Are you wanting to color only to the previous bar (1), and not the first bar of the chart?
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #24
                    Are you supplying plots as the inputs to DrawRegion? - Not sure how to send the plots as input. Please check my code below

                    Are you wanting to color only to the previous bar (1), and not the first bar of the chart? I want to color the downtrend as red and uptrend as green, not the single bar or current and previous bars alone

                    Initialize()
                    Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Sell"));
                    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Buy"));

                    OnBarUpdate()

                    Buy.Set(wOpen[0]);
                    Sell.Set(wClose[0]);

                    if(wClose[0] > wOpen[0]) // Uptrend
                    DrawRegion("Buy", CurrentBar, 0, Buy, Sell, Color.Lime, Color.Lime, 4);

                    if(wClose[0] < wOpen[0]) // Downtrend
                    DrawRegion("Sell", CurrentBar, 0, Buy , Sell, Color.Red, Color.Red, 4);

                    Comment


                      #25
                      Hello radhmu978,

                      From the help guide:
                      DrawRegion(string tag, int startBarsAgo, int endBarsAgo, IDataSeries series1, IDataSeries series2, Color outlineColor, Color areaColor, int areaOpacity)

                      For example:
                      DrawRegion("myRegion"+CurrentBar, 1, 0, SMA(7)[0], SMA(14)[0], Color.Blue, Color.Blue, 10);

                      I am linking the help guide once more in case you have not read this page.



                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #26
                        It worked, thank you so much. Appreciate your help.

                        Comment


                          #27
                          Hi,

                          I need one more help with the DrawArrow function. I see arrows in all candles. I want to draw arrows on condition only at the particular bar, not on all the bars.

                          if (isBelow[0] > 0)
                          {
                          DrawArrowDown(CurrentBar.ToString(), true, 0, isBelow[0] + TickSize, Color.Blue);
                          Print("Value is below " + isBelow[0]);
                          }

                          if (isAbove[0] > 0)
                          {
                          DrawArrowUp(CurrentBar.ToString(), true, 0, isAbove[0] - TickSize, Color.Orange);
                          Print("Value is above " + isAbove[0]);
                          }
                          Attached Files

                          Comment


                            #28
                            Hello radhmu978,

                            Thanks for your note.

                            This is Brandon responding on behalf of Chelsea who is out of the office at this time.

                            I see you are passing a unique tag name into the drawing methods. When using CurrentBar as the tag name, each arrow's tag name will be the current bar number. Since each bar number is different, the tag names are unique.

                            DrawArrowDown(CurrentBar.ToString(), true, 0, isBelow[0] + TickSize, Color.Blue);
                            DrawArrowUp(CurrentBar.ToString(), true, 0, isAbove[0] - TickSize, Color.Orange);


                            If you pass a unique tag name to the DrawArrowDown()/DrawArrowUp() methods, a new arrow will be drawn fon each bar that the condition to draw the arrow becomes true.

                            To only draw a single arrow on the bar when the condition to draw it is triggered, you would need to use a non-unique tag name. By passing in the same tag name, the drawing object will be removed for the previous bar it was triggered and is redrawn on the new bar where the condition is triggered.

                            DrawArrowDown("arrowDown", true, 0, isBelow[0] + TickSize, Color.Blue);
                            DrawArrowUp("arrowUp", true, 0, isAbove[0] - TickSize, Color.Orange);


                            See the help guide pages below for more information.
                            DrawArrowDown: https://ninjatrader.com/support/help...warrowdown.htm
                            DrawArrowUp: https://ninjatrader.com/support/help...rawarrowup.htm

                            Let us know if we may assist further.
                            <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


                              #29
                              Thank you Brandon. It worked, but i see the up and down arrow for past 2 matching conditions, not sure why the script is lot looking back into the historical bars and adding the arrow. Please check the screencast link below.

                              World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.

                              Comment


                                #30
                                Hello radhum978,

                                Thanks for your note.

                                In the screenshot you attached, I see one up arrow and one down arrow drawn on the chart. These arrows are likely being drawn where the condition to draw them was triggered. This would be expected since the up arrow is using a different tag name than the down arrow.

                                If you would like a single arrow drawn on the chart (up or down), you would need to pass in the same tag name when calling the drawing object methods.

                                Let us know if we may assist further.
                                <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
                                558 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                324 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
                                545 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