Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time exit on tick chart

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

    Time exit on tick chart

    Suppose I work on a tick chart and that, following a given indicator, I have entered a buy order with its own profit and sell stop targets.
    I would like to exit the trade at market if none of these targets are reached within 15 minutes.
    Is it easily programmable?

    #2
    Gepetto, you could store the time of trade entry and then send a market order exit, if the current time is greater than your stored trade entry time + the offset you've chosen.

    http://www.ninjatrader-support.com/H...deV6/Time.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Questions

      Suppose we have the following code
      protectedoverridevoid Initialize()
      {
      SetProfitTarget(
      "", CalculationMode.Ticks, 8);
      SetStopLoss(
      "", CalculationMode.Ticks, 12,true);
      CalculateOnBarClose =
      true;
      }
      protectedoverridevoid OnBarUpdate()
      {
      if blabla
      {EnterShort(
      );}
      if (ToTime(Time[0] >= 80000)
      {ExitShort();}
      }
      Now I have an exit based on time... what about stoploss & profit target? Automatically canceled?

      Comment


        #4
        Yes, correct - if a position is closed by another strategy generated exit those would be cancelled.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Manipulating ToTime(Time[0])

          Suppose ToTime(Time[0])=074600.
          If I had 15 minutes, I would obtain 080100.
          How to derive the minutes (46) in order to know when to add 15 or substract 45.
          I first thought at
          h=Math.Floor(ToTime(Time[0])/10000);
          m=Math.Floor(ToTime(Time[0])/100)-100*h;
          but I have a problem concerning classes (Math.Floor does not perform correctly).
          Any help?

          Comment


            #6
            OK now

            Problem solved.
            I had to write it in 2 lines:
            hh=ToTime(Time[0])/10000;
            hh=Math.Floor(hh);

            Quite tricky but now it works...

            Comment


              #7
              Ok, great you have it working for you.
              BertrandNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by QuantKey_Bruce, Today, 02:31 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Waxavi, Yesterday, 03:19 PM
              3 responses
              15 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Started by markdshark, Today, 12:37 PM
              4 responses
              14 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by Jdmtrader, 03-22-2023, 09:21 AM
              49 responses
              230 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by ronyggg83, 02-09-2023, 06:54 PM
              37 responses
              739 views
              0 likes
              Last Post dj22522
              by dj22522
               
              Working...
              X