Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Orders Never Get Filled in Replay

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

    #16
    Hi guys,

    As a follow up, I wanted to try replay using SPY. I tried downloading from NT the replay data for SPY, but it said there was no L1 or L2 data for this. Can you tell me where I may be able to get this for SPY?

    Also, If I wanted my strategy to execute a trade only when the MA's crossover and a specific time of the day (or end of day) is met, how could I do this?

    Thanks,

    Lee

    Comment


      #17
      Hello Lee,

      SPY is not available for downloading from the replay servers, only the most common futures instruments are recorded on the servers.

      If you have access to live data with SPY you could enable your Ninjatrader to record the data for replay, however given the length of your moving averages you would need about 14 days of recording before you could start to use replay, or make sure you have historical data before the replay data start date that can provide the historical computations of the moving averages.

      To limit your trading to a time range, you could use something like:

      if (ToTime(Time[0]) >= ToTime(8, 0, 0) && ToTime(Time[0]) <= ToTime(15, 15, 0))
      {
      // execute your trade code here
      }
      The above code is comparing the time of the bar to 8:00 AM and also comparing it to 3:15 PM, so if the bar is between 8:00 AM and 3:15 PM then the trade code is executed.
      Paul H.NinjaTrader Customer Service

      Comment


        #18
        Paul,

        Thanks again for the info. Let me ask one question regarding the ToTime to limit my trading. If a MA crossover occurs outside this range, would it still give me the signal? In other words, what I would like is to only get the signal at a certain time, but not limit the signal to a time range. So if the crossover occurs at 8:00, I would like it to give me a signal at 12:00 (of the same day). Can this be done? Would I need to use the >= for the MA instead of the CrossAbove/CrossBelow commands?

        Thank you for all the help,

        Lee

        Comment


          #19
          Hello Lee,

          Thanks for your reply.

          Yes, you can put the time restriction as a condition for only the part of the code that executes the trade.

          Using part of your coding for example:

          Code:
          if (CrossAbove(HMA(AvLongFast), HMA(AvLongSlow1), 1) 
          && longEntryMadeToday == false 
          ||  CrossAbove(HMA(AvLongFast), JMA(AvLongSlow2, 0), 1)
          && longEntryMadeToday == false) 
                      {
                          EnterLong(DefaultQuantity, "");
                          DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0]-4*TickSize, Color.Lime);
          		longEntryMadeToday = true;
                      }
          You can set the time element to the entry like this:
          Code:
          if (CrossAbove(HMA(AvLongFast), HMA(AvLongSlow1), 1) 
          && longEntryMadeToday == false 
          ||  CrossAbove(HMA(AvLongFast), JMA(AvLongSlow2, 0), 1)
          && longEntryMadeToday == false) 
                      {
                          DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0]-4*TickSize, Color.Lime);
          		
                        [COLOR="Red"] if (ToTime(Time[0]) >= ToTime(8, 0, 0) && ToTime(Time[0]) <= ToTime(15, 15, 0))
                           {
                                EnterLong(DefaultQuantity, "");
                                longEntryMadeToday = true;
                           }[/COLOR]
                      }
          In the above code, the MA crosses will trigger and draw the arrow but will not enter the order unless it is between the hours shown and then set the Boolean flag.

          I'm not certain I've captured correctly what you are asking but I think you can see with NinjaScript and C# programming language you can build it just about any way you want it.
          Paul H.NinjaTrader Customer Service

          Comment


            #20
            Hi Paul,

            Yes, that looks like what I was going for. I should be able to get it with your suggestions.

            Thanks again for the help and timely responses,

            Regards,

            Lee

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Waxavi, Today, 02:10 AM
            0 responses
            6 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by TradeForge, Today, 02:09 AM
            0 responses
            11 views
            0 likes
            Last Post TradeForge  
            Started by Waxavi, Today, 02:00 AM
            0 responses
            2 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by elirion, Today, 01:36 AM
            0 responses
            4 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by gentlebenthebear, Today, 01:30 AM
            0 responses
            5 views
            0 likes
            Last Post gentlebenthebear  
            Working...
            X