Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

user variable in strategy wizard

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

    user variable in strategy wizard

    Hi guys,
    I am new to the forum and just starting to get familiar with strategy wizard and ninja's editor.
    I have defined the following inputs:
    n= number of lookback bars
    bx= percentage multiplier of range

    I've then defined variable0 as being the Range over the last n bars using the indicator "Range".

    I would like to buy when the current price (c) crosses over c+bx*variable0

    How can I define in the wizard a new variable1=c+bx*variable0?

    If not possible from the wizard what would be the correct syntax to define this variable on the editor?

    thanks,
    Giovanni

    #2
    Hi Giovanni,

    Thanks for your post.

    The math needed for this cannot be down with the Strategy Wizard, so this must be hand coded in the code editor.

    You mention "I would like to buy when the current price (c) crosses over c+bx*variable0"

    If c is the close price, it would seem unlikely that the close price could cross over a higher number if this is calculated and re-saved on each bar.

    Are you wanting to save the value of c+bx*variable0 on the first bar (or another previous bar) to be compared with later?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      OK I made some confusion:It is probably easier to start from scratch and explain exactly the strategy I am trying to code:

      BRange= the price range over the last n bars=the highest high of the last n bars (including the current bar) minus the lowest low of the last n bars (including the current bar)
      n= number of lookback bars
      bx= percentage multiplier of the BRange
      c=current price
      buyCh= c+ bx* Brange
      enter long position if next bar higher than buyCh


      tks
      Last edited by balucang; 11-24-2013, 08:56 AM.

      Comment


        #4
        Hello balucang,

        It sounds like you want something like the following:

        Code:
        int n = 10;
        double brange = 0;
        double bx = 1.5;
        double buych = 0;
        protected override void OnBarUpdate()
        {
        if (Close[0] > buych)
        EnterLong();
        
        brange = MAX(Close, n)[0] - MIN(Close, n)[0];
        buych = Close[0]+bx*brange;
        }
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          ok tks for your help

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          573 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          575 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X