Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Run a strategy realtime

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

    Run a strategy realtime

    I want to run a strategy realtime on a certain instrument that I have in my instrument list. I also have print statements in the strategy when a signal is generated. What is the best way to monitor the strategy.


    when i try to add it to a chart, i don't seem to be getting onbarupdates?


    additionally I want to print the signals only when a realtime bar arrives, is that possible?

    thanks
    Last edited by newworldguy; 06-23-2014, 11:56 AM.

    #2
    Hello newworldguy,

    Thanks for your post about monitoring a strategy.

    As you mentioned having print statements in your script I assume you want to see each order state change. In that case the best method to use is TraceOrders which is set in the initialize section of your code. Here is a link to the help guide section on trace orders: http://www.ninjatrader.com/support/h...raceorders.htm

    If you want to monitor basic information such as position, P&L and Unrealized P&L, then use the control center and select the Strategies tab. Each strategy will be listed.

    By default when adding a strategy to a chart it has the "Enabled" property set to false. You must specifically set it to true in the strategy parameters window. Here is the help guide reference: http://www.ninjatrader.com/support/h...t_strategy.htm

    Please let me know if I can be of further assistance.

    Comment


      #3
      That is helpful. Additionally, I want to print only if its realtime bar as opposed toa historical bar when the chart is first created. How can I do that?

      I also want to print the prior sessions OHLC just for the current sessions. Can i do that in initialize()?

      If I were to backtest I use FIrstBarofSession Condition.

      thanks,
      Last edited by newworldguy; 06-23-2014, 12:25 PM.

      Comment


        #4
        Hello newworldguy,

        Thanks for your reply.

        You can use the NinjaScript boolean "Historical" to test if you are looking at new data. For example after OnBarUpdate you could add:

        Code:
        if (Historical) return;   // Do not process historical data
        Here is a link to the help guide about the prior days OHLC indicator: http://www.ninjatrader.com/support/h...r_day_ohlc.htm

        Please let me know if I can be of further assistance.

        Comment


          #5
          I tried:

          if (Historical==false)
          {
          Print(Time[0].ToString() + " #CANDLE#");
          }
          else
          {
          Print(Time[0].ToString() + " #HISTORICAL CANDLE#");
          }

          Realtime candles are showing up as historical candles for some reason! Please advice.

          Comment


            #6
            Hello newworldguy,

            Thanks for your post. Your code logic is correct but when I compiled it I had errors relating to string literals. I changed the ' to " and it compiled and then ran fine processing the historical data and when new data came in showed that as non historical. I have attached a picture showing the code I used, a chart of historical data and data that began when I used market replay. I marked the last historical noted candle and added the output window.

            Also, if you are using WaitUntilFlat, make note of the tip in this section of the help guide: http://www.ninjatrader.com/support/h...historical.htm

            Please let me know if I can be of further assistance.
            Attached Files

            Comment


              #7
              Bars.FirstBarOfSession

              I am trying to use:
              if (Bars.FirstBarOfSession && CurrentBar > 0)
              {
              }

              to run a strategy with a chart realtime. I notice that this clause is never qualified for some reason please advice. also advice how i can make a new post? i can not find the link

              Comment


                #8
                Hello newworldguy,

                Thanks for your post. I see that you have figured out how to create a new thread and posted the same there and that a colleague is working with you on solving the issue.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                651 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                370 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                109 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                574 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                577 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X