Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Possibility to Develop through Strategy Builder

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

    Possibility to Develop through Strategy Builder

    Hello

    I am new to Ninjatrader and want to know whether following scenario is possible using Strategy Builder UI ?

    Scenario1:

    PreviousBar is Green and LengthOfPreviousBar >= ATR() * 2


    PreviousBar is Red and LengthOfPreviousBar >= ATR() * 2



    Scenario2:
    User Provide input
    LookBackBar = N
    assume N = 5

    Low[1] >= Low[2] >= Low[3] >= Low[4] >= Low[5] to check 5 consecutive Bar is have Higher Low to check Uptrend

    Similarly

    High[1] <= High[2] <= High[3] <= High[4] <= High[5] to check 5 consecutive Bar is have Lower High to Check Downtrend

    Here use will decide value of N
    Last edited by futtrader; 12-07-2023, 05:29 PM.

    #2
    Hello futtrader,

    Thank you for your post.

    For scenario 1:

    You can determine is the previous bar was green by checking if the Close price was greater than the Open price for that bar. The previous bar was red if it's Close price was less than its Open price.

    You can calculate the 'length' of a bar by subtracting the Open price from the High price, then dividing that by the TickSize. Due to the limitations of the Strategy Builder this can be complex. You will need 2 additional custom series to calculate this in order to use Offset math. Please see the attached screenshot.

    Save this value to a variable in a separate condition set, then you can use this saved value to the value of the ATR offset by * 2 in another set. You can create variables from the 'Inputs and Variables' screen.


    For scenario two:

    You can define user inputs in the 'Inputs and Variables' tab, and give each one a default value.

    You can add to each condition set that the input variable has to have a specific value in order for the conditions to evaluate as true, to turn some conditions off an some on.

    For example, in one set you check if your user input N == 5, then your conditions can check if Low[1] >= Low[2] >= Low[3] >= Low[4] >= Low[5]. If N is not 5, this condition set will not be evaluated.

    In another set check if N == 4, then also check if Low[1] >= Low[2] >= Low[3] >= Low[4]. Similar logic can be implemented for other sets checking if N = 3 or 2.


    Please check out this forum post on Getting Started with NinjaScript:
    https://forum.ninjatrader.com/forum/ninjatrader-8/indicator-development/97575-sample-scripts?_gl=1*1eto9gf*_gcl_au*NzE2MTM0Nzc3LjE2OTYy NDU0NTU.#post7860400

    Here is a video on using Offset math:


    Builder Screens - https://ninjatrader.com/support/help...er_screens.htm
    Condition Builder - https://ninjatrader.com/support/help...on_builder.htm
    How to offset an item value - https://ninjatrader.com/support/help...setAnItemValue


    Please let me know if you have any other questions.
    Attached Files

    Comment


      #3
      Originally posted by NinjaTrader_Gaby View Post
      Hello futtrader,

      Thank you for your post.

      For scenario 1:

      You can determine is the previous bar was green by checking if the Close price was greater than the Open price for that bar. The previous bar was red if it's Close price was less than its Open price.

      You can calculate the 'length' of a bar by subtracting the Open price from the High price, then dividing that by the TickSize. Due to the limitations of the Strategy Builder this can be complex. You will need 2 additional custom series to calculate this in order to use Offset math. Please see the attached screenshot.

      Save this value to a variable in a separate condition set, then you can use this saved value to the value of the ATR offset by * 2 in another set. You can create variables from the 'Inputs and Variables' screen.


      For scenario two:

      You can define user inputs in the 'Inputs and Variables' tab, and give each one a default value.

      You can add to each condition set that the input variable has to have a specific value in order for the conditions to evaluate as true, to turn some conditions off an some on.

      For example, in one set you check if your user input N == 5, then your conditions can check if Low[1] >= Low[2] >= Low[3] >= Low[4] >= Low[5]. If N is not 5, this condition set will not be evaluated.

      In another set check if N == 4, then also check if Low[1] >= Low[2] >= Low[3] >= Low[4]. Similar logic can be implemented for other sets checking if N = 3 or 2.


      Please check out this forum post on Getting Started with NinjaScript:
      https://forum.ninjatrader.com/forum/ninjatrader-8/indicator-development/97575-sample-scripts?_gl=1*1eto9gf*_gcl_au*NzE2MTM0Nzc3LjE2OTYy NDU0NTU.#post7860400

      Here is a video on using Offset math:


      Builder Screens - https://ninjatrader.com/support/help...er_screens.htm
      Condition Builder - https://ninjatrader.com/support/help...on_builder.htm
      How to offset an item value - https://ninjatrader.com/support/help...setAnItemValue


      Please let me know if you have any other questions.
      thanks but for the second scenario, it still kinda hard coding --if I want to keep range of N from 1 to 100 it's too much work to create 100 set for the N.

      Comment


        #4
        Hello,

        Unfortunately, it may be necessary to unlock the code using the 'Unlock Code' button and code this by hand in order to achieve the logic you're looking for. The Strategy Builder is meant for simple logic and has limitations.

        If you unlock the script, you could use a for loop to accomplish your logic.

        Please let us know if you have any other questions.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        52 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        48 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X