Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy not taking live trades but showing historical trades

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

    #16
    Okay. So when I create a template with extended hours, do I use it in the added data series like this:

    AddDataSeries(instrumentName: Instrument.FullName,
    barsPeriod: new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, MarketDataType = Data.MarketDataType.Last, Value = 1 },
    tradingHoursName: "ES RTH Extended Hours", isResetOnNewTradingDay: false);

    Or do I apply the template to the trading hour settings on the chart?

    Thanks.
    Last edited by AdeptistJune; 12-21-2021, 10:04 AM.

    Comment


      #17
      Hello AdeptistJune,

      You can use this for the AddDataSeries() call. All series, including the chart series, need to be in session.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        I made a template that has the regular hours plus the extended hours, but it doesn't separate the Globex RTH high, low, open from the RTH high, low, open. Is there a certain way to create the trading hours template?

        Comment


          #19
          Hello AdeptistJune,

          All trading hours would need to be in session for the script to process. (Or the updates will be queued until the sessions align)

          If the ETH trading hours overlap, you could get the start and end times of the RTH session and calculate the Open, High, Low yourself.
          NinjaTrader.Data.TradingHours.All would contain all of the templates.


          If they don't overlap, you could get the data with a BarsRequest instead.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            Hello, Chelsea,

            To get the start and end times of the RTH and calculate the Open, High, Low, I would need a true or false condition?

            Comment


              #21
              Hello AdeptistJune,

              The start and end times/ OHLC values would not be true or false values. If you are asking how to access price data you can use the specific series like Close[0] to get the current close as an example.

              The start and end times of a trading hours template would be unknown unless you specifically look that information up in the trading hours template. Chelsea linked the documentation for that in the last post which contains some examples. https://ninjatrader.com/support/help...s_sessions.htm

              You can check the Time[0] to see what bar is currently processing and its time, based on that you could delegate your logic. For example if you were trying to get values from the ETH hours you would need to check from the beginning of the ETH time until the beginning of the RTH time and then use the values from the bars which fall in that timespan.

              Comment


                #22
                Okay. I did this:

                if (Times[0][0].TimeOfDay >= new TimeSpan(17, 00, 00) && Times[0][0].TimeOfDay <= new TimeSpan(08, 30, 00))
                {

                ONOpen[0] = CurrentDayOHL1.CurrentOpen[0];
                ONHigh[0] = CurrentDayOHL1.CurrentHigh[0];
                ONLow[0] = CurrentDayOHL1.CurrentLow[0];
                }

                But it doesn't plot anything and it doesn't give me an error either.

                Comment


                  #23
                  Hello AdeptistJune,

                  Thanks for your note.

                  I understand that you do not see the plots in your script placed on the chart.

                  Please check the Log tab of the Control Center for any error messages that may occur.

                  See the attached example script demonstrating how to plot the CurrentDayOHL values.

                  Ultimately, to understand why the script is behaving as it is, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

                  In the script, add prints that print the values of every variable used in every condition that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

                  Below is a link to a forum post that demonstrates how to use prints to understand behavior.
                  https://ninjatrader.com/support/foru...121#post791121

                  Please let me know if I may further assist
                  Attached Files
                  <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


                    #24
                    When I write the script this way

                    if (Times[0][0].TimeOfDay >= new TimeSpan(08, 30, 00) && Times[0][0].TimeOfDay <= new TimeSpan(17,00, 00))
                    {

                    ONOpen[0] = CurrentDayOHL1.CurrentOpen[0];
                    ONHigh[0] = CurrentDayOHL1.CurrentHigh[0];
                    ONLow[0] = CurrentDayOHL1.CurrentLow[0];
                    }

                    It give me the High, Low, Open of the RTH, which is what I want to plot. But when I do a check between 1700 and 0830, it will not plot the Globex High, Low, Open. So I did a check between 1700 and 0000, and it gave the Open, High, Low of the check between the two time spans. So is my syntax wrong?

                    Comment


                      #25
                      Hello AdeptistJune,

                      Use print to find out the answer to your inquiry.

                      Print the Time[0], print the Times[0][0].TimeOfDay, print the first time span, print the second time span, print the CurrentDayOHL1.CurrentOpen[0].

                      Include the output saved to a text file with your next reply. Let us know at what time stamp you would like us to direct our attention.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #26
                        Hello, it's not allowing me to upload the file. This is the error message I get: NinjaScript Output 12_26_2021 3_ 33PM.txt
                        Your file of 2.00 MB exceeds the limit of 1.00 MB.

                        Comment


                          #27
                          Hello AdeptistJune,

                          Use less days in the test.

                          Use a file transfer service such as wetransfer.com.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #28
                            Hello,

                            I still can't get the file. But I will copy and paste some of the output print:

                            Session 6: Wednesday at 1700 to Thursday at 830 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 7: Thursday at 830 to Thursday at 1700 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 8: Thursday at 1700 to Friday at 830 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 9: Friday at 830 to Friday at 1700 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 0: Sunday at 1700 to Monday at 830 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 1: Monday at 830 to Monday at 1700 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 2: Monday at 1700 to Tuesday at 830 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 3: Tuesday at 830 to Tuesday at 1700 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 4: Tuesday at 1700 to Wednesday at 830 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 5: Wednesday at 830 to Wednesday at 1700 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 6: Wednesday at 1700 to Thursday at 830 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 7: Thursday at 830 to Thursday at 1700 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 8: Thursday at 1700 to Friday at 830 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 9: Friday at 830 to Friday at 1700 | CurrentDayOHL1.CurrentOpen: 4689
                            Session 0: Sunday at 1700 to Monday at 830
                            Session 1: Monday at 830 to Monday at 1700
                            Session 2: Monday at 1700 to Tuesday at 830
                            Session 3: Tuesday at 830 to Tuesday at 1700
                            Session 4: Tuesday at 1700 to Wednesday at 830
                            Session 5: Wednesday at 830 to Wednesday at 1700
                            Session 6: Wednesday at 1700 to Thursday at 830
                            Session 7: Thursday at 830 to Thursday at 1700
                            Session 8: Thursday at 1700 to Friday at 830
                            Session 9: Friday at 830 to Friday at 1700
                            Session 0: Sunday at 1700 to Monday at 830
                            Session 1: Monday at 830 to Monday at 1700
                            Session 2: Monday at 1700 to Tuesday at 830
                            Session 3: Tuesday at 830 to Tuesday at 1700
                            Session 4: Tuesday at 1700 to Wednesday at 830
                            Session 5: Wednesday at 830 to Wednesday at 1700
                            Session 6: Wednesday at 1700 to Thursday at 830
                            Session 7: Thursday at 830 to Thursday at 1700
                            Session 8: Thursday at 1700 to Friday at 830
                            Session 9: Friday at 830 to Friday at 1700
                            Enabling NinjaScript strategy 'MyCustomStrategy2unlock/211652991' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=By strategy position ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes


                            I timespan I'm focused on is 1700 - 0830.

                            Comment


                              #29
                              Hello AdeptistJune,

                              Did wetransfer give you an error message? If so, what is the error message?

                              What is the time of the bar? What is the time.TimeOfDay?
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #30
                                Hello,

                                wetransfer didn't give any error message. When the file transferred, it was the exact same file size which is over the limit.

                                I don't understand your last message when you asked what is the time of the bar? What is the time.TimeOfDay? I thought the print statements I added to the script showed the session time, time of day, and time of bar.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by NullPointStrategies, Yesterday, 05:17 AM
                                0 responses
                                64 views
                                0 likes
                                Last Post NullPointStrategies  
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                139 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                75 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                45 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                50 views
                                0 likes
                                Last Post TheRealMorford  
                                Working...
                                X