Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Returning ticks from entry

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

    Returning ticks from entry

    Is it possible to return ticks from entry withou having to convert from price to ticks? I.e. can I accomplish the following statement without the "50*TickSize"?

    if (Close[0] > Position.AvgPrice + 50 * TickSize)

    I'd like simply to know when I am X ticks from the entry price.

    Thanks
    Ron

    #2
    Hi rsi77, not sure why you want to do this, as using 'TickSize' will allow you to run your code on various markets with different ticksizes which would be very convenient.

    To get the open position profit you can use GetProfitLoss() - http://www.ninjatrader-support.com/H...rofitLoss.html

    Comment


      #3
      Well that was exactly what I was after. So "TickSize" doesn't have to be entered for each market, rather it's a reserved word which will automatically give me the ticksize for whatever market I'm in?

      Please confirm if this is true.

      Thanks

      Comment


        #4
        And another related question: does the term "points" in the context of "getprofitloss" refer to ticks?

        Comment


          #5
          Hi rsi77, yes 'TickSize' is a reserved word giving to you the ticksize for each market as entered in the Instrument Manager - http://www.ninjatrader-support.com/H.../TickSize.html

          Points refers to full points, so for example 4 ticks on the ES or 10 on the TF.

          Comment


            #6
            Hello,

            I'm still having problems. The stop is not being moved to b/e even though my first tartet is hit and the trigger stop value has been surpassed. Can you tell me what is wrong with the following code?
            Thanks, [note: it seems the brackets do not paste properly--they are correct in my code]


            protectedoverridevoid OnBarUpdate()
            {
            // Here we reset the stop to its original value in the case we trailed during the last trade.
            if (Position.MarketPosition==MarketPosition.Flat)
            {
            SetStopLoss(CalculationMode.Ticks, Stop);
            }
            //Here we will move the stoploss to b/e if the market has moved enough in our direction
            elseif (Position.MarketPosition==MarketPosition.Long)
            {
            if (Close[0]>Position.AvgPrice + TrlTrigger*TickSize)
            {
            SetStopLoss(CalculationMode.Price, Position.AvgPrice);
            }
            }
            elseif (Position.MarketPosition==MarketPosition.Short)
            {
            if (Close[0]<Position.AvgPrice-TrlTrigger*TickSize)
            {
            SetStopLoss(CalculationMode.Price, Position.AvgPrice);

            Comment


              #7
              Do you get any errors in the Log tab of the Control Center?

              Which trigger tick values do you use for which markets?

              Since they are not in your sample code : are you sure there is a position present?

              Comment


                #8
                I'm running backtest on EURUSD. I enter 2 contracts at entry trigger. The first contract is indeed sold at my first target (T1) price. If the market then moves above my TrlTrigger (which is 6 pips/ticks in this case) the stop should be moved to b/e for the 2nd contract. But in fact it is not.

                I see no errors and the original stop works as normal.

                Thanks.

                Comment


                  #9
                  Are you scaling in first, so you can scale out later they way you mention it?

                  Here is a reference sample for this topic - http://www.ninjatrader-support2.com/...ead.php?t=3751

                  Comment


                    #10
                    I've already implemented this code in my strategy. I'm not scaling in, I'm buying two lots at the trigger, then if the first lot reaches target I move my stop loss to b/e for the 2nd (remaining) lot and exit either at the 2nd target or at b/e. Is this clear?....All other aspects of the strategy seem to be working so I don't understand why this portion is not. Is there an easy way to print values out to a table so I can see in side the code while the strategy is running?
                    Thanks.

                    Comment


                      #11
                      You need to scale in first with two different entry orders, then you can scale out later the way you mentioned in your previous posts.

                      Here's a helpful tip on debugging your code by using the Print() statement - http://www.ninjatrader-support2.com/...ead.php?t=3418

                      Comment


                        #12
                        I am scaling in with 2 distinct orders. The first one hits the first target and leaves one contract "on the table" . This contract is the only one present when the code sees that I've exceeded the TrlTrigger number of ticks from the entry. Is the code I originally posted correct?
                        I assume that "Position.AvgPrice" returns the average price for only a position which is still open--correct. And that TickSize for EURUSD will be 0.0001, correct?
                        I'm going to hard code the TrgtTrigger value and see if it works...I'll keep you posted.
                        Ron

                        Comment


                          #13
                          Ron,

                          It will do that if you have your "Stop & Target submission" set to PerEntryExecution. This option is available when you are first running the strategy from the dialogue window.

                          Position.AvgPrice gives you the average price of your remaining position.

                          TickSize gives you the tick size of your instrument as defined in the Instrument Manager.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            OK, I hardcoded the new stop into the strategy and it pays no attention to it. I set the stoploss in the first place in the "Initialize" section. I assumed that those lines are only used at the beginning of the strategy, and not on every tick or bar. Is this correct?

                            It seems that the stop is being reset after I change it to b/e, or it never changes in the first place. Or, do I need to name the specific entry in order to change it's stop? How would this be done in the context of the code I sent you? Thanks.

                            Comment


                              #15
                              rsi77,

                              Please post your latest changes.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              647 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              369 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              572 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              573 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X