Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NBarsDown question...

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

    NBarsDown question...

    Hi All...

    So I've had yet another bright idea for my new strategy that I'd love to test out.

    In the process of researching exactly how to implement my new idea... I've learned a TON of new cool stuff about NinjaScript (thanks to all you forum participants who have helped me so far!).

    So I've hit a bit of a snag... here's what's happening:

    I'm in a trade... things are tooling along nicely, when suddenly... price moves against my position by 3 ticks... but... these are not consecutive closes... price has taken its time to move these three ticks... one tick down... one tick back up... then two ticks down... then one back up... then another back up... then two back down... and finally... that third tick...

    I would like to exit the trade when this tick happens... but I can't figure out how to make the NBarsDown function work for me in this scenario... (maybe because it's not designed to... not sure).

    Is there a method in NinjaScript (available from the wizard... hehehe... ) which will allow me to do this? Maybe using variables? Something is swimming around the back of my mind regarding the use of variables for this but it's just a fuzzy picture at the moment...

    Just a wee nudge in the right direction would be fantastic!

    Thanks again to you all.

    -V

    #2
    Originally posted by Aurum View Post
    Hi All...

    So I've had yet another bright idea for my new strategy that I'd love to test out.

    In the process of researching exactly how to implement my new idea... I've learned a TON of new cool stuff about NinjaScript (thanks to all you forum participants who have helped me so far!).

    So I've hit a bit of a snag... here's what's happening:

    I'm in a trade... things are tooling along nicely, when suddenly... price moves against my position by 3 ticks... but... these are not consecutive closes... price has taken its time to move these three ticks... one tick down... one tick back up... then two ticks down... then one back up... then another back up... then two back down... and finally... that third tick...

    I would like to exit the trade when this tick happens... but I can't figure out how to make the NBarsDown function work for me in this scenario... (maybe because it's not designed to... not sure).

    Is there a method in NinjaScript (available from the wizard... hehehe... ) which will allow me to do this? Maybe using variables? Something is swimming around the back of my mind regarding the use of variables for this but it's just a fuzzy picture at the moment...

    Just a wee nudge in the right direction would be fantastic!

    Thanks again to you all.

    -V
    Code:
    if ((Position.MarketPosition == MarketPosition.Long) && (Close[0] <= MAX(High, BarsSinceEntry())[0] - 3 * TickSize)) ExitLong();

    Comment


      #3
      Thank you Koganam! That was QUITE a nudge!

      Excited to give this a try... so... I opened up my wizard straight away and began entering the data... I notice one shortcoming in the wizard... unfortunately, it seems like "BarsSinceEntry()" is not an option from inside the "MAX" method in the wizard.

      Here are the steps I took to get there:

      1. Grab a fresh cup of coffee.
      2. Open the Strategy Wizard.
      3. Click "Add."
      4. On the left I select Close and leave the "bars ago" field at "0."
      5. On the center bar, I select "<=".
      6. On the right side... I select "MAX."
      7. In the "Input series" field, I click and select "High" (nothing appears in the bottom pane).
      8. I click okay, and now I'm back in the "MAX" parameters window.
      9. I click on "Period" assuming this is where the "BarsSinceEntry" should go.
      10. I scroll up and down and don't see the little blue "misc" icon.

      So... I tried every other parameter field... clicking on the little oval button which appears on each... and none of them allow me to select "BarsSinceEntry."

      If I pay more... can I get this option?

      Any thoughts?

      Thank you again... you are so helpful on these forums. I hope you are compensated in some great way for all the effort you expend helping people like me become better traders, and better logical thinkers!

      May all your days be filled with kindness.

      -V

      Comment


        #4
        Originally posted by Aurum View Post
        Thank you Koganam! That was QUITE a nudge!

        Excited to give this a try... so... I opened up my wizard straight away and began entering the data... I notice one shortcoming in the wizard... unfortunately, it seems like "BarsSinceEntry()" is not an option from inside the "MAX" method in the wizard.

        Here are the steps I took to get there:

        1. Grab a fresh cup of coffee.
        2. Open the Strategy Wizard.
        3. Click "Add."
        4. On the left I select Close and leave the "bars ago" field at "0."
        5. On the center bar, I select "<=".
        6. On the right side... I select "MAX."
        7. In the "Input series" field, I click and select "High" (nothing appears in the bottom pane).
        8. I click okay, and now I'm back in the "MAX" parameters window.
        9. I click on "Period" assuming this is where the "BarsSinceEntry" should go.
        10. I scroll up and down and don't see the little blue "misc" icon.

        So... I tried every other parameter field... clicking on the little oval button which appears on each... and none of them allow me to select "BarsSinceEntry."

        If I pay more... can I get this option?

        Any thoughts?

        Thank you again... you are so helpful on these forums. I hope you are compensated in some great way for all the effort you expend helping people like me become better traders, and better logical thinkers!

        May all your days be filled with kindness.

        -V
        Code Wizards of any kind can only do that which is programmed into them. If something that you seek is not available in the Wizard, then you have to unlock the code, and write the new code manually.

        Comment


          #5
          Hello Aurum,

          Thank you for your post.

          If I am not mistaken on your inquiry you could use the average price of the position and compare it against the Close[0] as seen in the attached screenshot.
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          649 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 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
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          576 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X