Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy condition-Distance from a line

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

    Strategy condition-Distance from a line

    Hello,
    Can you please assist me as I'm trying to create a condition in strategy builder that requires the following to be true before the trade is taken.....The previous candles low (I use range bars in my data series) must be <= "X" number of ticks above the 40 period hull MA for a long or the previous candle's high must be <= "X" number of ticks below the 40 period hull MA for a short position.

    Thanks!

    #2
    Hello bsbisme,

    Thank you for your post.

    Unfortunately, this would not be possible in the Strategy Builder as it is not designed for math. Further, the TickSize property is not available in the Strategy Builder.

    This would require unlocking the script and coding this by hand.

    To check if the Low of the previous bar is less than or equal to x number of ticks above the current value of a 40 period HMA:

    if (Low[1] <= HMA(40)[0] + (x * TickSize))

    To check if the High of the previous bar is less than or equal to x number of ticks below the current value of a 40-period HMA
    if (High[1] <= HMA(40)[0] - (x * TickSize))

    Please let us know if you have any further questions.

    Comment


      #3
      OK,
      Thanks. Without unlocking the code as I'm not a coder, I'm trying to find a way to avoid entering after short price spikes (squeezes) using strategy builder.

      Please remember I'm using range bars.

      Can either one of these 2 distinct ways to express this condition be coded in strategy builder?

      1. If price close(0) <= X number of ticks from the low of (Y) bars ago, system can enter long

      OR another idea

      2. If last X number of range bars in a row closed on their high, system CAN'T take the trade

      Thanks....Any other ideas welcome.

      Comment


        #4
        Hello bsbisme,

        Thank you for your response.

        1. This would not be possible in the Builder since it requires more complex math to calculate the distance, as well as the usage of TickSize which is not available in the Strategy Builder.

        2. This would be possible using the Strategy Builder. We have an example of a bar counter in the Strategy Builder at the following link (ExampleBarCounter):



        You could count the number of bars in a row closed on their high. Then, use a bool to limit trading. If your counter reaches its limit, set the bool to false. Require the bool to be true to enter a trade. You will need to come up with your own logic that would reset the bool back to true to resume trading.

        The Strategy Builder is meant for simple logic, so if you had a definite amount of times you wanted to check the condition it would be simpler to set up the conditions since you already know how many bars need to be counted. However, if you are using a variable that may change the x amount of bars to check, this will require more complex logic like the ExampleBarCounter.

        Please let us know if you have any further questions.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        51 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        127 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        69 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X