Announcement

Collapse
No announcement yet.

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.

    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.

        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?

            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.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                62 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                134 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                75 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                45 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                50 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X