Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limitation of Strategy Builder in comparing prices

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

    Limitation of Strategy Builder in comparing prices

    How can I calculate the "Range" (High Minus Low) of the last 3 bars and then divide by 3 and compare that average to the last bar using strategy builder?

    I can subtract all of the Lows from all of the Highs but without the benefit of parentheses, I can't divide by 3 or it will only divide the last number by 3.

    Thanks

    Sam

    #2
    Hello Sam,

    Thanks for your post.

    The Strategy Builder is designed to build simple strategies. It is not robust enough to perform complex mathematical operations. The code will need to be unlocked to perform the calculation.

    I would suggest to write your strategy as much as you can in the Strategy Builder, and then to make a copy that you can unlock and edit in the NinjaScript Editor. You can go to the Welcome page of the Strategy Builder, and then place your mouse over your strategy in the Strategy Selector and click Save As to make a copy. Once the copy is made, you can unlock the code and edit the code manually to add your mathematical calculations.

    Something like the following could calculate the average range:

    Code:
    if (CurrentBar < 3)
        return;
    
    double myAvg = ((High[0] - Low[0]) + (High[1] - Low[1]) + (High[2] - Low[2])) / 3;
    The NinjaScript Editor tutorial gives a good transition from using the Strategy Builder to generate code, and using that generated code in an unlocked strategy.

    NinjaScript Editor 401 (publicly available) - https://www.youtube.com/watch?v=BA0W4ECyVdc

    We look forward to assisting.

    Comment


      #3
      Thanks Jim. I had a feeling.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      89 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      152 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      80 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      53 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      63 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X