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

There is no market data available to drive the simulation engine.

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

    There is no market data available to drive the simulation engine.

    I am trying to use ninjascript to buy at the highest high of the last 30 bars. Here's my code.
    Code:
    protected override void OnBarUpdate()
            {
                 EnterLongStop(MAX(High,30)[0],"Long");
            }
    I get an error that says "There is no market data available to drive the simulation engine."

    Can someone tell me what's wrong?

    Thanks.

    #2
    Most likely due to the fact that you try this on a weekend where the market is closed. Have you tried this in the Strategy Analyzer?

    BertrandNinjaTrader Customer Service

    Comment


      #3
      but this works fine

      Code:
      EnterShortStop(MIN(Low,30)[0],"Short");
      i am ultimately trying to replicate the following easylanguage code:

      Code:
      buy 1 contract at highest(high,30) stop;
      sell 1 contract at lowest(low,30) stop;
      but, instead of submitting stop orders before the trigger price is hit, i want to submit a market order when the trigger price is hit. can you show me how to do this? thanks.
      Last edited by whitebelt; 04-19-2009, 09:26 AM. Reason: mistyped something

      Comment


        #4
        Hi whitebelt, you can try this snippet -
        Code:
         
        if (CrossAbove(Close, MAX(High, 30)[1], 1))
        {
        EnterLong(DefaultQuantity, "");
        }
        This will send a market order long once the highest high of last 30 bars is broken to the upside, maybe you need to add some kind of tick offset to filter.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          this snippet isnn't exactly doing what i want.

          1) it appears to trigger only when the close is higher than MAX(high,30)
          2) it only sends the order on the close of the bar

          i want to send the order as soon as the MAX(high,30) is touched by the current bar.

          can you show me how to do this?

          Comment


            #6
            Hi whitebelt, true in backtesting this is executed at the close of the bar, in realtime this will depend on the CalculateOnBarClose setting - http://www.ninjatrader-support.com/H...BarClose1.html

            To simulate intrabar fills, you can review this reference sample - http://www.ninjatrader-support2.com/...ead.php?t=6652
            BertrandNinjaTrader Customer Service

            Comment


              #7
              lets step back for a minute. in backtesting, how do i simply backtest the following:

              Code:
              buy 1 contract at highest(high,30) stop;
              sell 1 contract at lowest(low,30) stop;

              Comment


                #8
                Hi, you can use this -
                Code:
                 
                double myLongStopTrigger = MAX(High, 30)[0];
                
                EnterLongStop(myLongStopTrigger, "Long");
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  what about the short side? i read in an old thread that you can't have longs and shorts in the same strategy. is this still true?

                  what is the most efficient way to code this simple strategy (long and short side)?

                  Comment


                    #10
                    whitebelt,

                    You cannot have simultaneous long orders and short orders sitting at the market at the same time. You can have long and short orders in a single strategy just as long as they do not try to both enter at the same time.

                    Many people solve this simply by submitting whichever order the price is closest to. If the price gets closer to the other side they will cancel the first order and submit the new one. Note, this would only work if the prices are far enough apart to prevent constant flip flopping.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      i don't get it. how do i get it to do what i want. it's a simple strategy. why doesn't this code work?

                      EnterLongStop(MAX(High,30), "Long");
                      EnterShortStop(MIN(Low,30, "Short");

                      Comment


                        #12
                        As stated, you cannot have simultaneous working orders in opposite directions.

                        Code:
                        if (Close[0] >= MAX(High,30)[0])
                             // place an order
                        else if (Close[0] <= MIN(Low, 30)[0])
                            // place a different order
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          your code won't do what i want to backtest. your code only buys or sells at the close of the bar. i want to buy or sell as as soon as price touches the trigger. i know you said that in live trading, your code will do that if i toggle a setting. however, i want to see the backtest performance statistics.

                          EnterLongStop(MAX(High,30), "Long");
                          EnterShortStop(MIN(Low,30, "Short");

                          i want it to do exactly this on the backtest and see the performance statistics.
                          Last edited by whitebelt; 04-20-2009, 02:13 PM.

                          Comment


                            #14
                            whitebelt,

                            As stated, you cannot place simultaneous orders in opposite directions. You need to choose which one you want to place to the market. If price moves then change the order. I cannot spec out this for you. The idea is just look at the latest price and look at if its closer to your long order or your short order. If price is closer to the long order place in the long order. If the price becomes closer to the short order, cancel the long order and place in the short order.

                            The gist of the idea. You will need to work out all the details yourself.
                            Code:
                            if (MAX(High, 30)[0] - Close[0] > Close[0] - MIN(Low, 30)[0])
                                 EnterLongStop(...);
                            else
                                 EnterShortStop(...);
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              to be frank, i am quite surprised that ninjatrader can't do this. your logic that one should not be permitted to enter simultaneous orders in opposite directions is flawed. real trading does allow you to put a buy stop and a sell stop at the same time. also, your suggested solution is not a perfect solution so it will affect the performance report.

                              this is a basic bracket strategy that i'm sure many users will need in one form or another. i think you guys need to fix this problem. please bring this thread to the attention of NinjaTrader's owner.

                              there are a lot of other good features in NinjaTrader, but i don't think i will do too much more with NinjaTrader unless this is fixed.
                              Last edited by whitebelt; 04-20-2009, 02:41 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Jonafare, 12-06-2012, 03:48 PM
                              5 responses
                              3,984 views
                              0 likes
                              Last Post rene69851  
                              Started by Fitspressorest, Today, 01:38 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Fitspressorest  
                              Started by Jonker, Today, 01:19 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Jonker
                              by Jonker
                               
                              Started by futtrader, Today, 01:16 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post futtrader  
                              Started by Segwin, 05-07-2018, 02:15 PM
                              14 responses
                              1,791 views
                              0 likes
                              Last Post aligator  
                              Working...
                              X