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

buy on indicator

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

    buy on indicator

    I am new to NT7 and trying to program my first script. It's supposed to buy something when VIX goes above its bollinger band. I started with the Wizard then unlocked the codes because it's multi-instrument. Upon running the script it showed zero trades. With my limited knowledge on scripting I can't really figure out what's wrong with this otherwise simple script. Any help would be greatly appreciated.

    protected override void Initialize()
    {
    Add("^VIX", PeriodType.Day, 300);
    CalculateOnBarClose = true;
    }
    protected override void OnBarUpdate()
    {
    if (CrossAbove(BarsArray[1], Bollinger(BarsArray[1], 2, 14).Upper, 1))
    {
    EnterLong(0);
    }
    }

    #2
    Add("^VIX", PeriodType.Day, 300); first of all this would add a 300 Day VIX. so 1 candle every 300 days. basicly a Yearly Bar rather than a daily.

    Comment


      #3
      Hello,
      Your EnterLong() command is telling the strategy to submit 0 orders.
      If you are wanting for it to submit a market order for the strategies defult quantity you can just leave it is EnterLong();
      Please see the following link on the EnterLong() method: http://ninjatrader.com/support/helpG.../enterlong.htm
      Cody B.NinjaTrader Customer Service

      Comment


        #4
        ok I made it "EnterLong()", and changed 300 to 1 for Add, but it still doesn't work.

        Comment


          #5
          Hello,
          Do you have ExitOnClose set to true or false for the strategy?

          I have ran the strategy as you have described plus the changes suggested and I do see orders submitted historically.
          Cody B.NinjaTrader Customer Service

          Comment


            #6
            The script doesn't have ExitOnClose command, is it default to true or false? I have been scratching my head and I don't understand the reason there's no trades triggered. Just to be sure, if I want to buy MSFT when VIX goes over bollinger band, BarsArray[1] is referring to VIX, and EnterLong would trigger buy on MSFT?

            Comment


              #7
              Hello,
              ExitOnClose would be set to true by default.

              Yes, BarsArray[1] is referring to the VIX and EnterLong(); will submit on MSFT.
              How many days to load do you have set? What time frame do you have selected for MSFT? I am seeign trtades submitted with a MSFT 1 minute chart set to load 5 days.
              Cody B.NinjaTrader Customer Service

              Comment


                #8
                I am trying to use this script to backtest on historical data, so on the backtest menu, I selected "Day" for type, "1" for value (which I assume means daily), and Jan 1/2015 to Dec 15/2015 for timeframe (which is the default that I didn't change). Curious, the ADD command is adding daily bars, how are you triggering trades on 1 minute bars?

                Comment


                  #9
                  Hello,
                  The ADD command does add daily bars but this does not mean that your primary data sereis must be daily as well. You could select Minute Bars for the MSFT when backtesting if you have intraday data for it. This would still add in a daily data series for the ^VIX. Please see the following link on working with Muliple Timeframes and Instruments. 3
                  What data provider are you using for your backtest data?
                  Cody B.NinjaTrader Customer Service

                  Comment


                    #10
                    I am using Yahoo so it only has end of day quotes, hence the design of the script. This is such a short script that I reallly can't see what else to modify to make it work. Perhaps I can trouble you to run the same setup I have so far, using daily bars etc.

                    Comment


                      #11
                      Hello,
                      Yahoo does not support indexes so it the backtest it unable to pull the VIX index data. Please see the following link on what data is provided by the various data providers: http://ninjatrader.com/support/helpG...rical_data.htm

                      Since the VIX index data is unable to populate the strategy is unable to process the data and trades will not appear. If you are just looking for end of day data you could connect to Kinetick End of Day to receive equity and index data. To connect to Kinetick End of Day go to File> Connect > Kinetick - End of Day(Free)
                      Cody B.NinjaTrader Customer Service

                      Comment


                        #12
                        I tried using Kinetick as connection and it didn't make any difference. With Yahoo as connection I am able to bring up a daily chart of VIX, so I assume NT7 can retrieve data from Yahoo to run strategy too.

                        Comment


                          #13
                          Hello,
                          Yahoo does not support indexes and I am unable to bring up a ^VIX chart. I am able to bring up a VIX chart with a Yahoo connection, but this is an equity and not the index. With Index charts you have to put the carat before them exactly like "^VIX."

                          While connected to Kinetick End Of Day and backtesting on MSFT 1 day I get the results displayed in the attached screenshot.

                          Can you provide settings that you have selected fro the backtest as well as your results?
                          Attached Files
                          Cody B.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by rexsole, Today, 08:39 AM
                          2 responses
                          6 views
                          0 likes
                          Last Post NinjaTrader_Erick  
                          Started by cmtjoancolmenero, Yesterday, 03:58 PM
                          6 responses
                          28 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by gbourque, Today, 06:39 AM
                          2 responses
                          14 views
                          0 likes
                          Last Post gbourque  
                          Started by trilliantrader, Yesterday, 03:01 PM
                          3 responses
                          31 views
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Started by Brevo, Today, 01:45 AM
                          1 response
                          14 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Working...
                          X