Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

2 questions about Ninjascript coding..

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

    2 questions about Ninjascript coding..

    1) I want my strategy to enter the market at 8:17am and have used the line of code
    private string startTime = @"8:17"
    to accomplish this, and the code works, the strategy enters the market at 8:17am when I enter the strategy on a 1 minute NT7 chart... but if I enter the strategy on a 5 minute chart, then the strategy enters the market at 8:15am (eventhough I have hard coded 8:17)... is this because a 5 minute chart will only enter on increments of 5 minutes? does this mean that I have to always enter this strategy on a 1 minute chart or is there some code that I can add to my strategy so that I can enter it on greater than a 1 minute chart?

    2) I would like my strategy to 'flatten all' if a maximum daily drawdown of -$10,000 is hit, can you suggest the Ninjascript lines of code that I can utilize to accomplish this?

    Thanks for your time and assistance..

    #2
    sev888,

    1) Correct, the 5 min timestamps don't offer a more granular resolution, you could add a 1 min series and grab their timestamps then with Times.

    2) Unfortunately issuing a flatten all via NinjaScript is not supported, however you could check the RealTimeTrades cumulative Pnl for this and then return out of placing any trades - http://www.ninjatrader-support.com/H...luesClass.html

    Comment


      #3
      Thanks Bertrand..

      Comment


        #4
        I also have two conditions in which I need to flatten all:
        1) I reverse by doubling the order quantity in the opposite direction and orphan stops are left from the last trade,
        2) The strategy has reached a threshold at which I no longer want to play and MUST exit all open positions.

        What about Position.FlattenAll = true;?
        -OR-
        if (Position.MarketPosition == MarketPosition.Long)
        {
        ExitLong();
        }
        else if (Position.MarketPosition == MarketPosition.Short)
        {
        ExitShort();
        }

        Thank you.
        Last edited by CarlZAZ; 06-12-2010, 08:06 AM.

        Comment


          #5
          Welcome to our fourms, this is unfortunately not supported NinjaScript, however it might work for your purposes, you would need to test...

          The second part would certainly work to close open position from the strategy, but it would not perform other operations that a manual 'Flatten All' would.

          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
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          574 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X