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

Question about CalculationMode.Ticks

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

    Question about CalculationMode.Ticks

    Hello,

    I am trying to code a strategy for MNQ.

    I have a variable takeProfit. I set it to 60:

    Code:
    takeProfit = 60;
    I then set a profit target with CalculationMode.Ticks:

    Code:
    SetProfitTarget(CalculationMode.Ticks, takeProfit);

    If what I think is correct this strategy would close when the price is 60 ticks in profit. That would be $120 for MNQ since it's $2 per tick.

    But today in simulation it ran up to $511+

    I tried to google this and haven't found an answer. Please help me understand this. Thank you.


    Attached Files

    #2
    Hello Brevo,

    From the image that appears to be the positions tab which shows the currently unrealized PnL. Are you able to see in the orders tab or on a chart what the profit target price was set to? The positions tab pnl is based on the average entry price and current market price which gives you the unrealized PnL from the point of entry.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Nothing is set for the profit target in the order tab. Should that happened automatically? I didn't use the chart. The order tab screenshot is attached.
      Attached Files

      Comment


        #4
        Hello Brevo,

        The target should automatically be submitted when the entry fills, where did you put that code inside your script? The reason for the higher than expected pnl would be due to no target being active and that is just how much unrealized pnl the position currently has.
        JesseNinjaTrader Customer Service

        Comment


          #5
          I added the code in OnStateChange():


          Code:
          else if (State == State.Configure)
          {
          SetProfitTarget(CalculationMode.Ticks, takeProfit);
          SetStopLoss(CalculationMode.Ticks, stopLoss);
          }

          Comment


            #6
            Hello Brevo,

            That should be the correct placement. Did you compile the script and then remove/re apply it after making that change?

            JesseNinjaTrader Customer Service

            Comment


              #7
              The code has been there since the beginning and yes has been compiled and backtested. Recently added to a simulation account.


              Last edited by Brevo; 02-13-2024, 02:48 PM.

              Comment


                #8
                Hello Brevo,

                In that case I would suggest using TraceOrders and then re test the strategy in the same use case during realtime. If the order was not submitted for some reason traceorders should be able to let you know why that was.


                That information will go to the NinjaScript output window so you will need to have the output open when testing.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Taddypole, 04-26-2024, 02:47 PM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_Eduardo  
                Started by futtrader, 04-21-2024, 01:50 AM
                6 responses
                58 views
                0 likes
                Last Post futtrader  
                Started by sgordet, Today, 11:48 AM
                0 responses
                4 views
                0 likes
                Last Post sgordet
                by sgordet
                 
                Started by Trader146, Today, 11:41 AM
                0 responses
                5 views
                0 likes
                Last Post Trader146  
                Started by jpapa, 04-23-2024, 07:22 AM
                2 responses
                22 views
                0 likes
                Last Post rene69851  
                Working...
                X