• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help with Strategy syntax/coding...

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

    Need help with Strategy syntax/coding...

    Greetings,

    I am working on my first NT8 strategy and need some help with coding. I've built this strategy using the strategy builder wizard.

    The strategy would enter long if the value TrendSignalUp = 1 or short if TrendSignalDown = 1.

    It needs to enter on the open of the next bar if the previous bar was different than the one before it. That is, 2 bars ago is different.

    So, if TrendSignalDown[2] = 1 and TrendSignalUp[1] = 1 then enter long.

    The code below causes a trade to be entered on every bar.

    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (atsTrendFinder1.TrendSignalUp[0] == 1)
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }

    // Set 2
    if (atsTrendFinder1.TrendSignalDown[0] == 1)
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    }

    }

    What is the syntax to make this work?

    Thanks

    Andrew

    #2
    Hello ajadams,

    Thanks for your post.

    Your conditions are checking only if the current bar's TrendSignalUp is 1 and if the current bar's TrendSignalDown is 1 to trigger trades. If you would like to check if "TrendSignalDown[2] = 1 and TrendSignalUp[1] = 1" then I would suggest making your condition check both of these in the Strategy Builder. The screenshot attached shows a condition that checks two conditions using AND.

    If you have not already done so, I would recommend viewing the Strategy Builder 301 tutorial and the help guide items below for creating a complete strategy using the Builder.

    Strategy Builder 301 - https://www.youtube.com/watch?v=HCyt90GAs9k
    Conditions Tips - https://ninjatrader.com/support/help...on_builder.htm
    Actions Tips - https://ninjatrader.com/support/help...us/actions.htm

    After you are comfortable creating logic with the Builder, I would then suggest to create a duplicate strategy and click the View Code button with each addition to better observe the syntax created by the Builder. Our NinjaScript Editor 401 tutorial covers some basics behind creating logic with the Builder and creating your own unlocked copy of a strategy for manual code edits.

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

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Jim, thank you for your quick and helpful reply. I have studied the strategy builder support pages closely and now have a better understanding to how powerful the wizard is. Thanks.

      Drew

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NT-Roland, Today, 04:36 PM
      0 responses
      2 views
      0 likes
      Last Post NT-Roland  
      Started by Newtrader101, Today, 03:40 PM
      2 responses
      10 views
      0 likes
      Last Post Newtrader101  
      Started by Branpo, Today, 02:58 PM
      2 responses
      7 views
      0 likes
      Last Post Branpo
      by Branpo
       
      Started by sdauteuil, Today, 02:09 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by AMATX, Today, 02:19 PM
      2 responses
      11 views
      0 likes
      Last Post AMATX
      by AMATX
       
      Working...
      X