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

One trade per setup and force close

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

    One trade per setup and force close

    I am wondering how I can force only one trade per setup? ie if the trade moves 25 ticks and my target is 10ticks, that it only takes the one trade and not re enters another 2 times.
    Also, how do I force it to close trades when a timeto is met. ie. Force close an open trade that began at 9:25am and the timeto period of no trading is set to 9:27 to 9:32
    The Timeto setting I have seem to work ok, but only stops new trades begining and doesn't force open trades to close.
    Thanks in advance

    #2
    vast524, to take only one trade per setup you work with user variables or flags like in this sample - http://www.ninjatrader-support2.com/...ad.php?t=15417

    To exit trades at a certain time, you can work with time filters, too - for example this snippet closes open longs and shorts at 10:15:00 -

    Code:
     
    if (ToTime(Time[0]) >= 101500)
    {
    ExitShort();
    ExitLong();
    }
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks Bertrand
      If I had several time periods that need to be avoided. ie opening, lunch times and close. ie. No trade between 9:28 to 9:33, 12:00 o 13:00 and 1:55 to 16:02. I have a series of ToTime commands in a row separated by ||. The coding sems to be in order.
      Would I need to place the following for each time frame.

      if (ToTime(Time[0]) >= 101500)
      {
      ExitShort();
      ExitLong();
      }

      Comment


        #4
        Sure, just work with this each time you want to exit at a specific time. Please note that this will simplpy get you net flat as it exits longs and shorts, whatever position is present at this time then.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Austiner87, Today, 03:42 PM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by cshox, Today, 11:11 AM
        2 responses
        15 views
        0 likes
        Last Post cshox
        by cshox
         
        Started by algospoke, Today, 06:53 PM
        0 responses
        9 views
        0 likes
        Last Post algospoke  
        Started by mlprice12, 12-21-2021, 04:55 PM
        3 responses
        296 views
        0 likes
        Last Post paypachaysa  
        Started by lorem, 04-25-2024, 09:18 AM
        20 responses
        86 views
        0 likes
        Last Post lorem
        by lorem
         
        Working...
        X