Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple Target profits

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

    #61
    Hello Pladijske,

    Thank you for your reply.

    You can use Instrument.FullName to get the instrument name and expiry if applicable:

    Code:
    protected override void OnBarUpdate()
    {
      // Print the full name (including contract month) of the configured instrument
      Print(String.Format("{0} is being used as the input series", Instrument.FullName));
    }
    For the Period, you can get that from BarsPeriod:

    Code:
    Print(BarsPeriod.Value + " " + BarsPeriod.BarsPeriodType);
    You can use those in the message that the SendMail sends to get that info.

    Please let us know if we may be of further assistance to you.

    Comment


      #62
      Hello Kate,

      Thank you but where do I have to put that in the sendmail()?

      I now use:

      SendMail(@"XXX@XXX", @"Aankoop Dax Short", + Environment.NewLine + "Prijs = " + Convert.ToString(Close[0]) + ";" + Environment.NewLine + "Tijd = "+ Convert.ToString(Times[0][0].TimeOfDay) + ";" + Environment.NewLine + "Aantal = " + Convert.ToString(Position.Quantity));

      Do I just add:
      + Environment.NewLine + "Welk Instrument = " + Instrument.Fullname
      + Environment.NewLine + "Welk Timeframe = " + BarsPeriod.BarsPeriodType

      Or is that not correct?


      Comment


        #63
        Hello Pladijske,

        SendMail takes a string as input for the message body.

        You can create a new string, add those items to your string and then pass that string to SendMail.

        I have included some educational resources on working with strings in C#. This is a publicly available resource external to NinjaTrader.

        Learn about strings in C# programming. See information on declaring and initializing strings, the immutability of string objects, and string escape sequences.

        In C#, you can use strings as array of characters, However, more common practice is to use the string keyword to declare a string variable. The string keyword is an alias for the System.String class.


        SendMail documentation can be referenced below.

        SendMail - https://ninjatrader.com/support/help.../?sendmail.htm

        We look forward to assisting.

        Comment


          #64
          Dear Kate,
          I have 2 strategys. 1 for Long and 1 for Short.
          In both the "start" with:
          Code:
          if (State == State.SetDefaults)
                      {
                          Description                        = @"Geeft een kooporder als de indicator 2 of meer is";
                          Name                            = "ShortDax50TicksStrategyKopen2FUTS";
                          Calculate                        = Calculate.OnBarClose;
                          EntriesPerDirection                = 5;
                          EntryHandling                    = EntryHandling.AllEntries;
                          IsExitOnSessionCloseStrategy    = false;
                          ExitOnSessionCloseSeconds        = 30;
                          IsFillLimitOnTouch                = false;
                          MaximumBarsLookBack                = MaximumBarsLookBack.TwoHundredFiftySix;
                          OrderFillResolution                = OrderFillResolution.Standard;
                          Slippage                        = 2;
                          StartBehavior                    = StartBehavior.WaitUntilFlat;
                          TimeInForce                        = TimeInForce.Gtc;
                          TraceOrders                        = true;
                          RealtimeErrorHandling            = RealtimeErrorHandling.StopCancelClose;
                          StopTargetHandling                = StopTargetHandling.ByStrategyPosition;
                          BarsRequiredToTrade                = 20;
                          // Disable this property for performance gains in Strategy Analyzer optimizations
                          // See the Help Guide for additional information
                          IsInstantiatedOnEachOptimizationIteration    = true;
          
                      }
          //and also:
          if ((Times[0][0].TimeOfDay > new TimeSpan(2, 10, 0))
                           && (Times[0][0].TimeOfDay < new TimeSpan(20, 45, 0))
                           && (Position.Quantity == 0)
          But when I visualize this on the chart, it happens that when I am long (like 2 futs) the "short"strategy also sells 1 fut short allthough it is mentioned "Position.quantity==0"

          How is this possible and what can I do to prevent this?

          Kind regards,

          Ladis

          Comment


            #65
            Hello Pladjiske,

            Thank you for your reply.

            Position.Quantity refers only to the position of the individual strategy, not the entire account position. Strategies aren't aware of other strategies' positions. I would advise combining your short and long logic into a single strategy if you want them to be aware of the positions.

            Also, this thread is getting extremely lengthy and off the original topic. Please make new threads for any questions that are unrelated to the original forum topic.

            Please let us know if we may be of further assistance to you.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            116 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            61 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            40 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            43 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            82 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X