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

New here- question

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

    #16
    Please post a screenshot of the NinjaScript editor, with the error column fully expanded and the line of code causing the error included.

    To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CRTL + V to paste the image. Lastly, save as a jpeg file and post the file as an attachment.
    Ryan M.NinjaTrader Customer Service

    Comment


      #18
      Thanks for the screenshot. It may be worthwhile for you to work in the strategy wizard for a bit, which allows you to define conditions in a point and click interface. You can then view resulting code with the correct syntax and copy - paste working code into a separate script if you like.

      The compiler points to issues with the indicator VWAP, so that should be the first place to correct. If you don't know how to resolve the issue, you can also import and it will overwrite with a working version.

      For setting plot colors on indicators added to a strategy, this post should help:
      Ryan M.NinjaTrader Customer Service

      Comment


        #19
        is there a VWAP code somewhere without the STDEV- just the daily VWAP?

        I have searched and searched.

        VWAP is classified as a method and i need it to be classified as an indicator.

        Comment


          #20
          I'm not aware of a different one than is provided in the V7 indicators section, by NinjaTrader_Josh.

          In C# terminology, indicators are considered methods.

          The best way to learn syntax initially is through the strategy wizard. You should consider attending today's webinar on strategy development where I'll walk you through creating a simple strategy with the wizard.
          Ryan M.NinjaTrader Customer Service

          Comment


            #21
            Is it possible to have the crossover have some "wiggle room" aka something along the lines of SLOW +X or I want the signal to be more concreate- a cross above slow by 0.5 points or so ....

            TIA

            {
            if (Bars.BarsSinceSession +1> Slow && CrossAbove(VWMA(Fast), VWMA(Slow), 1))
            EnterLong();

            }

            Comment


              #22
              Yes, you can add or subtract to values using standard math operators + / - . For the right syntax for this, I suggest using the strategy wizard, and playing with offset field when defining a condition. There are examples of setting this up in the following link:

              How to offset an item value
              Ryan M.NinjaTrader Customer Service

              Comment


                #23
                thats great stuff, but even when i build the indicator- and I get it to work, I cannot find the code for that variable... and I need to see the code... one would think it would be very simple...

                Comment


                  #24
                  Yes, you can add or subtract using the standard symbols for this. Basic syntax with NinjaScript is available in this help guide article:


                  myValue + 10 //adds 10
                  myValue - 10 //subtracts 10.

                  Using the strategy wizard, you can build the whole expression in the condition builder, including an offset. You can view code at any time by clicking view code.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #25
                    Thank you for all of your help. For Some reason, this compiles, but does not show up on my screen or backtest. Dumb, Dumber, and Fast are all fast moving averages, and Slow is a slow. I need all fast to cross above the slow to signal a buy, and vice versa.

                    {
                    if (Bars.BarsSinceSession +1> Slow && CrossAbove(VWMA(Dumb),VWMA(Slow), 1)&& CrossAbove(VWMA(Dumber),VWMA(Slow), 1)&& CrossAbove(VWMA(Fast),VWMA (Slow),1))
                    EnterLong();
                    else if (Bars.BarsSinceSession +1> Slow && CrossBelow(VWMA(Dumb),VWMA(Slow), 1)&& CrossBelow(VWMA(Dumber),VWMA(Slow), 1)&& CrossBelow(VWMA(Fast),VWMA(Slow),1))
                    EnterShort();

                    Comment


                      #26
                      To debug your code, you will need to Print() all relevant values. For crossing, this includes the current [0] and prior value [1] to test for a crossing. It may also help to add drawing objects in addition to order placement so you can visualize when signals are true. To track strategy order submission, add TraceOrders= true; to your Initialize() method. Both Print() output and TraceOrders output is logged to the Tools > Output Window. Help with debugging is available here:
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #27
                        I have tried hundreds of ways to do something very simple... a 3 VWMA crossover

                        here is where I am at... and for some reason I have an odd error



                        I have coded it by adding multiple crosses as well (shown below), but that gives me false entry signals when the VWMA are not crossing, so i believe I need to stick with the first set of code (screen shot)

                        Bottom line... this should be simple.... especially the screen shot, not sure why it is not working.

                        {
                        if (Bars.BarsSinceSession + 1 > 21 && (Cross1 == true) && (Cross2 == true) && (Cross3 == true))
                        EnterLong();
                        else if (Bars.BarsSinceSession + 1 > 21 && (Cross1 == false) && (Cross2 == false) && (Cross3 == false))
                        EnterShort();
                        }

                        }

                        Comment


                          #28
                          Or it is telling me to using strings... and strings are not relational, i need relational.

                          // Resolution Sample Code - Testing to see if both strings are the same
                          if ("string" == "string2")

                          Additional Error Descriptions
                          Operator ‘<’ cannot be applied to operands of type ‘string’ and ‘string’
                          Operator ‘<=’ cannot be applied to operands of type ‘string’ and ‘string’
                          Operator ‘>=’ cannot be applied to operands of type ‘string’ and ‘string’

                          Comment


                            #29
                            wprosser,

                            You need to compare the double values, so apply indexing to your indicator. It has been suggested in this thread multiple times that it will be much easier for you to use the strategy wizard for building these simple expressions. The strategy wizard will help you in every case you have posted so far. Is there any reason you are not using the strategy wizard to build simple expressions like this?

                            There's really no reason to work with code until you can get the basic construction down. If you want to get started with code, the basic tutorials serve as a nice introduction to proper syntax:
                            Ryan M.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by elirion, Yesterday, 09:32 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post elirion
                            by elirion
                             
                            Started by cre8able, Yesterday, 09:15 PM
                            1 response
                            8 views
                            0 likes
                            Last Post bltdavid  
                            Started by cummish, Yesterday, 08:43 PM
                            0 responses
                            16 views
                            0 likes
                            Last Post cummish
                            by cummish
                             
                            Started by Option Whisperer, Yesterday, 07:58 PM
                            4 responses
                            21 views
                            0 likes
                            Last Post Option Whisperer  
                            Started by ETFVoyageur, 05-07-2024, 07:05 PM
                            13 responses
                            87 views
                            0 likes
                            Last Post ETFVoyageur  
                            Working...
                            X