• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

where to close to cover my previous losses

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

    where to close to cover my previous losses

    Hello,

    I would like to create an indicator which would show me where would it be possible to close my actual position to cover my previous losses (realized PnL < 0). So let´s say that it would draw a line above my entry when in a long position. The line would be placed on "daily breakeven" (entry price + realized PnL defined in tics). Could you advise me how to start?

    Thank you
    emuns

    #2
    Hello emuns,

    Thanks for your post.

    You could do this through your strategy using the Draw.Line() method, or by using a plot via AddPlot().
    References:
    https://ninjatrader.com/support/help...?draw_line.htm
    https://ninjatrader.com/support/help...s/?addplot.htm

    Using Position.MarketPosition to detect when you are in a position you can then pull the Position.AveragePrice for the entry price and from there add (or subtract) the difference of the Realized PNL in ticks (if the realized PNL is less than 0). You can convert the price to ticks using TickSize.
    References:
    https://ninjatrader.com/support/help.../?position.htm
    https://ninjatrader.com/support/help.../?ticksize.htm

    Here is a link to an example strategy that works with cumulative profit: https://ninjatrader.com/support/help...nce_statis.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello PaulH,

      thank you for your answer. I´m trying to create an indicator not strategy. But I think that it should be similar…?

      Now I struggle with problem, how to say:
      if (the current open position is long)
      do something;

      Comment


        #4
        Hello emuns,

        Thanks for your reply.

        An indicator would not typically have access to account/strategy information that your strategy would have.

        The links I previously provide all list various methods and properties that you can click on to see further along with examples.

        In the case of "the current open position is long", this would be known as the market position, please see MarketPosition: https://ninjatrader.com/support/help...etposition.htm

        Alternatively if you would like this created for you, we can provide references to 3rd party programmers skilled in Ninjascript.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hello Paul,

          because you wrote that strategy would be easier, i tried to create one (see below). I compiled it successfully, but it doesn´t work as expected.

          I created some trades manually, these trades were losing trades, so my CumProfit is now in a loss. Than I take another trade manually on one chart (with chart trader) and I expect that the strategy will show me (on another chart) where to close this trade to cover my prior losses.

          Is my strategy incorrect or is my expectation incorrect?

          Thank you
          Attached Files

          Comment


            #6
            Hello emuns,

            Thanks for your reply.

            A strategy would in general only be aware of trades that the strategy itself initiated. Strategies are unaware of manual trades or trades of other strategies. The suggestions I provided would only be for a strategy to meet your initial query (on my incorrect assumption that the strategy was the only trading being performed).

            We should probably start over in understanding what you wish to do. Can you confirm that you are looking to create indication, on a specific chart, of where your entire accounts daily PNL (regardless of instrument) is relative to the current trades entry price? Would this be irrespective or inclusive of any current strategy trades?


            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Hello Paul,

              thank you for clarification.

              Yes, i can confirm that. I make only manual trades, so there are no strategy trades.

              I thought that it could be easy, but it was probably incorrect assumption… I went through the Help guide and I wonder what is the difference between "Position" and "PositionAccount"?
              I was also thinking what about to use this indicator as an inspiration: https://ninjatraderecosystem.com/use...lay-indicator/

              Thank you
              emuns
              Last edited by emuns; 08-01-2019, 08:57 AM.

              Comment


                #8
                Hello emuns,

                Thanks for your post.

                The help guide advises that Position.Account "Represents position related information that pertains to real-world account (live or simulation)."
                The help guide advises that Position "Represents position related information that pertains to an instance of a strategy. "

                I agree, the indicator your referenced contain many of the methods I was going to point to as a way to get account information into an indicator and work from there, so indeed yes.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Paul,

                  so, if I understand it correctly, it means that Position.Account is for indicators and Position is for strategies?

                  Comment


                    #10
                    Hello emuns,

                    Position as previously advised would only pull data relevant to the strategy code it is running in.

                    PositionAccount provides what the actual account position is. For example if one strategy on an instrument was long and another strategy on the same instrument and same account was Short, the PositionAccount for that account would be reporting that the account position is flat.

                    Paul H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by TazoTodua, Today, 09:06 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post TazoTodua  
                    Started by sambo81, Yesterday, 06:57 PM
                    1 response
                    18 views
                    0 likes
                    Last Post NinjaTrader_ThomasC  
                    Started by tgn55, Today, 08:34 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post tgn55
                    by tgn55
                     
                    Started by TazoTodua, Today, 06:00 AM
                    0 responses
                    9 views
                    0 likes
                    Last Post TazoTodua  
                    Started by gbux11, Today, 02:36 AM
                    0 responses
                    8 views
                    0 likes
                    Last Post gbux11
                    by gbux11
                     
                    Working...
                    X