Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Newbie strategy help

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

    Newbie strategy help

    I’m a Ninja newbie. I have just made my first attempt to translate an Easy Language strategy I developed into a Ninja strategy. I now have many questions about the code produced by the Strategy Wizard.

    I hope that I will not be considered presumptuous for asking so many questions but this is my introductory meeting with the Strategy Wizard and I don’t know where else to find these answers. I am very appreciative for the help Ninja makes available and I thank you all for that.

    I printed out the Strategy Wizard code which comprised three pages of familiar-looking code, followed by over twenty pages of green-colored code under the heading of “Region: Wizard settings, neither change nor remove”

    1-What is the meaning of green-colored code?
    2-What is the meaning of “Wizard settings”?

    In the first two pages of code, there is Region called Variables. Following are a list of variables which I had entered into the Wizard as “Inputs”. In C# are Inputs called Variables?

    After the close of the Variables Region, there is a section preceded by this sentence:
    Protected override void Initialize.
    To me, this means this section is initializing Variables. However the section comprises eight lines of code repeating this line: “Add(LinReg(Close , 34));

    3-Why is this line repeated eight times and why is the other Variable in the Easy Language code not initialized? (My Easy Language code declared two variables: LinReg and LinRegDelta.)

    4-What does “Override” mean?

    After
    Condition Set 1, which reads: (Position.Market Position ==MarketPosition.Flat && LinReg(Close, 34) [0] < LinReg(Close, 34)[LinRegLB]) followed by:
    EnterLong(100000, “B.pp”) ;

    5-Should there have been an indication of the instrument, such as
    “Instrument.Fullname”?
    6-Is this Strategy associated with a particular chart, as in Easy Language? If so, how is the code connected to a specific chart?

    In Condition Set 3, (the same type of condition as in Set 1, but for a Long position), the code shows:
    Position.MarketPosition == MarketPosition.Long && LinReg(Close, 34) + 0.0018
    < LinReg(Close, 34) [LinRegLB] + 0.0018)

    This code seems garbled to me. The 0.0018 is the value of the Input (Variable?) called “Buffer”.

    7-Shouldn’t the code show “Buffer” (Buffer is an Input (Variable) instead of
    0.0018?

    Also, in Condition Set 4, there is this action line:
    ExitShort(“100000, CS.pp”, “ “) ;

    8-Shouldn’t the code read: “ExitShort(100000, “CS.pp”, “ “) ;
    9-What does the “ “ mean in that code?

    In Condition Set 5:, if (Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) >= MaxPosProfit
    Exit Long(“100000, CS.pp”, “ “) ;

    10-What is the difference between PositionGetProfitLoss and Unrealized?
    11- What does “PerformanceUnitCurrency” mean?

    12-How do I know whether this code has been compiled? If not, how do I compile and will the compiler correct the above errors?
    13-Is all the code in this Namespace called an Assembly? If not, what is an Assembly?

    #2
    Hi skat100,

    One of our NinjaScript trainees will respond to you later today. Thank you for your patience.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi Skat100,

      Thank you for your post and congratulations on starting out with NinjaTrader!

      1. Green code is generally commented out code that is not being compiled (just like in TS when you add // in front of a code line)

      2. This is the region of code that holds the configuration settings of the Strategy Wizard, rememember once the strategy code is unlocked you cannot use the Wizard for this strategy anymore to configure it.

      3. Yes, your inputs are declared as Variables used throughout the code. The "Initialize" section just configures the study / strategy before any calculation is done. Your variables have already been initialized in the Variables section.

      4. Override just means that a new implementation is started.

      5. The instrument you trade against is determined when you are starting your strategy. If you put your strategy on a chart of AAPL, it will trade to AAPL.

      6. Your strategy is associated with the chart you load it onto. It will take data from the charted instrument and run all its logic based on that instrument. You do not need to explicitly program anything for this behavior.

      7. Yes, if you correctly declared "Buffer" as your input and then pointed to it in later stages of the wizard while entering your condition, it should reflect that in the code. Please check your condition, the offset should reference your user declared input "Buffer".

      8. Your code seems correct, NinjaScript does it slightly differently than Easy Language.

      9. In the " " you could enter a specific, unique entry order name from that your ExitShort statement then exits, very useful for scale in and out stratgies, as well as organizing your code to accomodate different signals in one strategy.

      10. PositionGetProfitLoss refers to the PnL of a closed position, whereas Unrealized refers to the PnL of a open position.

      11. PerformanceUnitCurrency means it will reflect an amont of a currency, instead of Ticks or percentage based ones.

      12. You know that your code is compiled successfully when it is listed under Strategies as you try to add it from a chart or the Strategies tab. If not, open the code and hit F5. Scoll to the bottom window where potential errors are listed and doubleclick on them to see where issues still exist. Correct them and hit F5 again to compile. Repeat those steps until no errors show up.

      13. No, assembly is the machine level compiled DLL that NinjaTrader maintains for all indicators and strategies. It comes in handy when you choose to export your codes to friends, but do not want to hand out any source code... http://www.ninjatrader-support.com/HelpGuideV6/Export1.html

      Have a great time developing with NinjaTrader!

      Comment


        #4
        Thanks for your help.
        I unlocked the code and am now in the editor.
        1-Is there anywhere a complete strategy that I can use as a model for my programming?
        2-In the editor my variable declarations (inputs) are missing.
        3-Under the heading Variables (the word Variables is in a rectangle) the Trailing Stop declaration appeared. Is this where it should be? Or should it be under the Conditions section?
        4-The LinReg variable appears as "Add(LinReg(Close, 34));" Are variable declarations always preceded by the work "Add"?
        5-There are also no Using declarations under the Using Declarations heading.
        6-There are no entries under the Properties heading.
        7-I feel somewhat stupid about asking these very simplistic questions. Is there anywhere a manual explaining all this elementary stuff? I have an excellent C# book but these questions really pertain to the Ninja editor requirements.
        8-Where do I find a listing of Reserved Words and Functions with their parameters?

        Comment


          #5
          Hi skat100,

          Thank you for your post.

          1. I would suggest you refer to these reference samples on our forum - http://www.ninjatrader-support.com/vb/forumdisplay.php?f=30

          2. Please expand the Variables section by clicking " + " sign on the left side next to it.

          3. The SetStopLoss and SetProfitTarget commands should be in the "Initialize" section of your code.

          4. No, this refer to the Add() method - http://www.ninjatrader-support.com/HelpGuideV6/Add.html and it is likely in there, because you selected your indicators to be plotted from the strategy to help visualize it.

          5. Please click the " + " sign to the left to expand the Using Declarations section.

          6. Please click the " + " sign to the left to expand the Properties section.

          7. Yes, please bring up the help guide by hitting F1 anywhere in NinjaTrader, then locate the contents tab, then read the NinjaScript and NinjaScript editors sections closely and also follow the tutorials, this should give you a excellent overview. The more time you spend coding the more improvement you will see. Also check the reference samples I posted under 1.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          571 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          330 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          548 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          549 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X