Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

profit within days

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

    profit within days

    Hi Guys,

    In the backtesting strategy wizard is it possible to have a condition where if the stock is not in profit within 2 weeks then the stock will be stopped out at that days close.

    I've also added the conditions of profit and loss on percentage that I want to keep as well.

    Any help would be great thanks!

    #2
    Hello NZJim,

    Using the condition builder, you can access the value RealizedPnL. It's under the strategy category. The "two week part" is challenging to do in the strategy wizard only. You can write in a specific date check for with Time > Time series == Time > Date value. Anything more involved with date / time requires working with code directly.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      Thanks for the quick response

      How would I do this in the code?

      cheers
      Jim

      Comment


        #4
        In programming there are usually multiple ways to do things, so following is only provided as an example to get you started on an approach. General help for working with DateTime objects is available here.

        You can capture the DateTime of the first bar and then compare this value + 14 days to the bars's time stamp. Consider the Minimum bars required you're using for your strategy and maybe capture according to this instead of 0.

        //variables region
        private DateTime = myDateTime;


        if (CurrentBar == 0)
        myDateTime = Time[0];


        if (ToDay(Time[0]) <= ToDay(myDateTime.AddDays(14)))
        {
        }
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thanks Ryan,

          I'll go and have a go at it!

          cheers
          Jim

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by algospoke, 04-17-2024, 06:40 PM
          6 responses
          48 views
          0 likes
          Last Post algospoke  
          Started by arvidvanstaey, Today, 02:19 PM
          4 responses
          11 views
          0 likes
          Last Post arvidvanstaey  
          Started by samish18, 04-17-2024, 08:57 AM
          16 responses
          61 views
          0 likes
          Last Post samish18  
          Started by jordanq2, Today, 03:10 PM
          2 responses
          9 views
          0 likes
          Last Post jordanq2  
          Started by traderqz, Today, 12:06 AM
          10 responses
          18 views
          0 likes
          Last Post traderqz  
          Working...
          X