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

Strategy Condition Not Working

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

    Strategy Condition Not Working

    Hi


    The strategy that I'm trying to build and that I have attached is when a bar open is above the previous bar open go long and when a bar open is bellow the previous bar open go short.

    The condition that I would like to be verified in a given bar when the condition is met and then let it run (the position) till a stop loss or opposite condition happen, instead of that, the condition is being applied to every single bar.

    I have tried to include a stop loss and a trailing stop but I don't know how to, on trailing stop, to use the previous bar open + or - x ticks (+ if short and - if long)


    Honestly I don't get what I may be doing wrong here


    Thank you
    Last edited by ampf27; 09-01-2021, 08:44 AM.

    #2
    Hello ampf27,

    Thanks for your post.

    How are you testing the strategy? On Live data, or in the Strategy analyzer on historical data, or on the Playback connection with Market replay data?

    Are you experiencing multiple entries per bar?

    You are using both a trailing stop and a set stop loss, in the strategy builder only one or the other should be used as when both are used the trailing stop is ignored. Both are set to the currency mode and your default values are 1. I would suggest that you decide which one you want to use and then change from CalculationMode.Currency to CalculationMode.Tick (This is for the stoploss or the trailstop). I would also set your default values to be larger than 1. When using CalculationMode.Ticks you will only need to specify the number of ticks to be away from the entry, the method will automatically add or subtract for you, depending on the entry direction.

    Note: You cannot set either the StopLoss or the TrailingStop to a value of a previous bar, these methods can only be set once and then are applied to every entry after that based in the initial value provided.

    In case you have not reviewed the reference materials, here are links:
    Free live webinar every other Thursday at 4:00 PM EST, through this link to all webinars: https://ninjatrader.com/PlatformTraining
    Previous recording of the Strategy Builder 301 webinar: https://youtu.be/HCyt90GAs9k?list=PL...auWXkWe0Nf&t=2
    Help guide for the strategy builder: https://ninjatrader.com/support/help...gy_builder.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply


      Hi have apllied your recommendations and only used a trailing stop but I still get the same result as shown in the attached image. Attached are also the attempts made in the Price2 the trailingstop is called thorugh the user input and on Price3 is used a fixed value, but in both of tem the output is the same.


      Thank you

      Last edited by ampf27; 09-01-2021, 08:45 AM.

      Comment


        #4
        Hello ampf27,

        Thanks for your reply.

        How are you testing the strategy? On Live data, or in the Strategy analyzer on historical data, or on the Playback connection with Market replay data?

        In your screenshot were those trades made on live data or are these on the historical data on the chart?

        What is the bar type you are using, it looks like UniRenko.

        Your entry conditions appear to be true for each bar, you may want to add other entry conditions to only enter when you wish.

        A trailing stop of only 2 ticks is likely going to get hit a lot, you may want to lengthen that out or you should expect to get a lot of losses. I would suggest a larger value that you can adjust down until you find the best level that works for you. This will also prevent placing so many orders.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Im testing in a sim account

          you may want to add other entry conditions to only enter when you wish.
          what condition could be put here can you provide an example?

          Even if trailing stop would be hit it should wait until next entry condition be verified and not entering in every single bar

          Comment


            #6
            Hello ampf27,

            Thanks for your reply.

            "what condition could be put here can you provide an example?" It is your strategy, from what I can tell it is performing as you programmed it. How do you want the strategy to perform?

            "Even if trailing stop would be hit it should wait until next entry condition be verified and not entering in every single bar" I will guess that you are using Unirenko bars (please confirm) and Unirenko bars provide a false open, so your singular entry condition will be true on every (historical) bar. Once the trade is over and the entry condition is true, thus a new entry.

            If you are using Unirenko bars I would suggest not using just the open of the bar as an entry condition. UniRenko is a trend indicator bar type, you may want to consider entering once per trend direction change, when it changes from uptrend to downtrend and vice versa. A trend change could be defined as the previous bar was green Close[1] > Open[1] and the current bar is red (Close[0] < Open[0], or vice versa.

            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Thnak you


              That suggestion helped me to achieve the result I was looking for.



              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by LawrenHom, Today, 10:45 PM
              0 responses
              3 views
              0 likes
              Last Post LawrenHom  
              Started by love2code2trade, Yesterday, 01:45 PM
              4 responses
              28 views
              0 likes
              Last Post love2code2trade  
              Started by funk10101, Today, 09:43 PM
              0 responses
              7 views
              0 likes
              Last Post funk10101  
              Started by pkefal, 04-11-2024, 07:39 AM
              11 responses
              37 views
              0 likes
              Last Post jeronymite  
              Started by bill2023, Yesterday, 08:51 AM
              8 responses
              44 views
              0 likes
              Last Post bill2023  
              Working...
              X