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 burtoninlondon, Today, 12:38 AM
                0 responses
                5 views
                0 likes
                Last Post burtoninlondon  
                Started by AaronKoRn, Yesterday, 09:49 PM
                0 responses
                12 views
                0 likes
                Last Post AaronKoRn  
                Started by carnitron, Yesterday, 08:42 PM
                0 responses
                11 views
                0 likes
                Last Post carnitron  
                Started by strategist007, Yesterday, 07:51 PM
                0 responses
                13 views
                0 likes
                Last Post strategist007  
                Started by StockTrader88, 03-06-2021, 08:58 AM
                44 responses
                3,982 views
                3 likes
                Last Post jhudas88  
                Working...
                X