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

Adding to a position

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

    Adding to a position


    I was wondering if someone can post an example of how to scale into an existing position. I have searched the forums and other sites that use C# for an example of how to add to a position that is already open. It doesn’t matter what you use to enter or eixt, I just need a format to follow as I am a new to coding and learn best through example and it might help other people on the forum as well. If now one can, I understand as it looks like it is a pain to write the code for it.
    I have already looked at using OnExecution() and IOrder for entering another position based on the ATR with no luck.

    #2
    Create a new strategy via wizard, unlock it so you are in the NinjaScript Editor.

    Add the following code to OnBarUpdate():

    if (Close[0] > Open[0]) EnterLong();

    Now run a backtest on a 1 minute chart with exit on close set to true and change the "Entries per direction" value from 1 to 2, then to 3. Take a look at your back test results, look at the chart.
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks Ray.
      I will mess around with this some more and see if I can get it to work with ATR.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      148 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Started by mattbsea, Today, 05:44 PM
      0 responses
      5 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      33 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      5 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,282 views
      0 likes
      Last Post Leafcutter  
      Working...
      X