Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cross Above/Below alternative?

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

    Cross Above/Below alternative?

    Hi! I'm wondering if there's another way to create a Cross Above/Below condition in the Strategy Builder? The issue is that the Cross Above/Below condition remains true for the entire bar once it has occurred. For example:

    IF CrossAbove(MFI (Close,(8)),10,1) then go Long.

    IF CrossBelow(Close,SMA (Close,(5),1) then Exit Long.

    So if the MFI(8) crosses above 10 we enter. In the same bar, if the current price climbs and then falls below the SMA(5) we exit. But if we're still in the same bar, then after the exit it will go in and out many times since both conditions continue to be met based on CrossAbove/Below lasting throughout the whole bar. Is there a way to create a condition for crossing that will not last the entire bar?

    Thanks!

    #2
    Hello Lance EI Camino,
    Ideally Strategy should be used OnBarClose so this problem is not there. So, the forming bar is not accounted for the strategy. Hope it helps!

    Comment


      #3
      Originally posted by Lance El Camino View Post
      Hi! I'm wondering if there's another way to create a Cross Above/Below condition in the Strategy Builder? The issue is that the Cross Above/Below condition remains true for the entire bar once it has occurred. For example:

      IF CrossAbove(MFI (Close,(8)),10,1) then go Long.
      IF CrossBelow(Close,SMA (Close,(5),1) then Exit Long.

      So if the MFI(8) crosses above 10 we enter. In the same bar, if the current price climbs and then falls below the SMA(5) we exit. But if we're still in the same bar, then after the exit it will go in and out many times since both conditions continue to be met based on CrossAbove/Below lasting throughout the whole bar. Is there a way to create a condition for crossing that will not last the entire bar?
      Hi Lance El Camino,
      Step 1: Add a bool "Cross Above/Below traded" or similar to your strategy. Per default, set it to "false".
      Step 2: Check if it is "false" in your entry conditions.
      Step 3: If yes and if your other entry conditions are met, set it to "true" immediately prior to entering the trade. This will block all further entries because trades are only allowed if the bool is "false".
      Step 4: As soon as the entry bar is over, reset the bool to "false" (if Bars Since Entry > 1, bool = false). "Bars Since Entry" can be found under "Misc".
      NT-Roland

      Comment


        #4
        Hello Lance El Camino,

        Thanks for your post.

        Based on your description it sounds like you are running the strategy with Calculate.OnPriceChange or Calculate.OnEachTick which means your strategy builder conditions are being tested many times within each bar as you have observed.

        Forum member NT-Roland has offered a solution using a bool variable.

        Here is another:

        To limit the entries to only once per bar you would need to add another condition to your entry set(s).

        You will need to create a variable in the Variables section of the "inputs and Variables" window of the Strategy Builder. It should be an integer (int) type you can name as you wish but for this example, I will call it Savedbar.
        Create the condition Misc>Current bar, Not equal, User variables> SavedBar

        In the "do the following section of the same set, create the action: Misc>Set SavedBar In the field of SavedBar, click "set", in the value pop-up window, select Misc>Current Bar.

        The condition and action should look like the example screenshot below, again these would be in the same set as your entry conditions and order.

        What happens is that the first time your entry conditions are true the current bar will be not equal to the saved bar and this will allow the entry to occur, in the do the following section, besides your entry order, the current bar is now saved in SavedBar making them equal, so on the next price change, the entry conditions will not be true because the current bar is equal to the saved bar.

        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by yodaler, Today, 06:12 PM
        0 responses
        4 views
        0 likes
        Last Post yodaler
        by yodaler
         
        Started by op1031, Today, 05:16 PM
        0 responses
        1 view
        0 likes
        Last Post op1031
        by op1031
         
        Started by fscabrera03, Today, 01:18 PM
        1 response
        12 views
        0 likes
        Last Post fscabrera03  
        Started by BottomShark77, Today, 12:20 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by bowling, Today, 06:16 AM
        3 responses
        30 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Working...
        X