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

Stop adjusting

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

    Stop adjusting

    Hi

    I've got a problem with adjusting the stop. For example, when I enter a long position, I generate a stop at 5 ticks below (SetStopLoss(CalculationMode.Ticks, 5)). Now, when it didn't get touched during this bar, I want to adjust it to 5 points below the new open. The only possibility to do that would be with using the close of the old bar, but I don't want to do that because of gaps. So, is there any possibility to adjust the stop on each bar open 5 points below the bar's open?

    Regards,

    Sepp

    #2
    Hi Sepp, please try:
    Code:
    SetStopLoss(CalculationMode.Price, Open[0] - 5 * TickSize);
    AustinNinjaTrader Customer Service

    Comment


      #3
      But I don't think that this will work in backtesting because therefore Open[0] is used as the open of the last bar...
      So any possibility to get this in backtesting?

      Regards,

      Sepp

      Comment


        #4
        Sepp, Open[0] will always refer to the open of the current bar. Are you experiencing something else? You can add intrabar granularity to your backtests to help make it work.
        AustinNinjaTrader Customer Service

        Comment


          #5
          When I backtest it, Open[0] refers to the open of the last bar, not the one of the current bar. That's what I was asking. But it looks like I have to solve it with an intrabar solution. If you have other ideas, please let me know.

          Regards,

          Sepp

          Comment


            #6
            Ok, it seems like it works now, when I'm using Open[-1]. Then it uses indeed the current open. This will be good enough for me I think.

            Regards,

            Sepp

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Segwin, 05-07-2018, 02:15 PM
            10 responses
            1,769 views
            0 likes
            Last Post Leafcutter  
            Started by Rapine Heihei, 04-23-2024, 07:51 PM
            2 responses
            30 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by Shansen, 08-30-2019, 10:18 PM
            24 responses
            943 views
            0 likes
            Last Post spwizard  
            Started by Max238, Today, 01:28 AM
            0 responses
            10 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by rocketman7, Today, 01:00 AM
            0 responses
            7 views
            0 likes
            Last Post rocketman7  
            Working...
            X