• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

long timeframes vs. trailing stop loss

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

    long timeframes vs. trailing stop loss

    I have my trailing stop loss defined at time of trade entry in OnBarUpdate function. When I run my strategy for 15-min timeframe, i get stopped out on really great entries. Apparently, because the trail stop-loss checks at end of bar or something.

    i set a profit target of only 5 ticks in same place as trail stop-loss, and the 15-min bar goes like 30 ticks. i want it to exit when i hit profit of 5 ticks. it works ok on short timeframes.

    should i be putting my trail stop loss outside of OnBarUpdate, and if so, where? I'm new to scripting, and the only functions i have in the samples i'm using are Initialize and OnBarUpdate.

    #2
    Yes SetTrailStop() will update the stop based on the close of the bar.

    Based on your description am I right to assume this is over historical data? When looking at historical data the system will not know the order in which prices were hit on the bar and will default to the stop loss being hit first if it's unsure. In real time it would fill the target first.
    For more details on this: http://www.ninjatrader.com/support/h...ime_vs_bac.htm

    If you wanted to be able to backtest with this sort of trail you would need to add intrabar granularity. so that the stop could be placed on the smaller time frame.
    http://www.ninjatrader.com/support/f...ead.php?t=6652
    http://www.ninjatrader.com/support/h...nstruments.htm

    Let me know if I can further assist.
    LanceNinjaTrader Customer Service

    Comment


      #3
      Thanks Lance, that is great info. yes, i'm just backtesting my newly minted ninjascripts & wizard strategies before trying them live.

      i will turn it on in my sim acct tomorrow when there's more volatility and see if the 15-min will trigger both an entry and profitable exit in same bar.

      Comment


        #4
        No problem, let me know if you have further questions.
        LanceNinjaTrader Customer Service

        Comment


          #5
          i changed it to SetStopLoss and now it's triggering the exit at 5 ticks within the same 15-min bar. this is what i want. i may make copy of strategy with trailstoploss test both in SIM during live market data.

          Comment


            #6
            You could use SetStopLoss() to update it manually in the OnBarUpdate()

            Typically SetTrailStop() isn't needed if you're coding yourself. I find it's more common to use with the wizard, but it can also be more convenient depending on the sort of trailing rule you want to use.
            LanceNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by superkolleech, Today, 12:46 AM
            1 response
            10 views
            0 likes
            Last Post MojoJojo  
            Started by davidwade, Today, 02:51 AM
            0 responses
            2 views
            0 likes
            Last Post davidwade  
            Started by aviat72, 04-26-2020, 09:41 PM
            10 responses
            91 views
            0 likes
            Last Post kissandfly  
            Started by healthooa, Today, 01:28 AM
            0 responses
            7 views
            0 likes
            Last Post healthooa  
            Started by harjinderjit, Yesterday, 08:24 PM
            0 responses
            20 views
            0 likes
            Last Post harjinderjit  
            Working...
            X