Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Executes only one direction

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

    Executes only one direction

    Greetings! I can't understand why simple code doesn't work properly Can you tell me where I made a mistake. The problem - NT8 choose the only one direction and opens only sell or only buy orders. I want it to execute both ways.

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (Delta11.Sells[0] > Zero+20)
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "1");
    }

    // Set 2
    if (Delta11.Sells[0] < Zero-20)
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "1");
    }

    #2
    Hello Svasud,

    Thanks for your post and welcome to the forums!

    Based on your posted code it would be difficult to say. We suggest adding print statements to your code to print out the values of the variables Delta11.Sells[0] and Zero (I assume Zero is a variable). By printing out the values on a bar by bar basis you will see what these variable values are and can then see why the logic is or is not working and when. The output of Print statements goes to New>Ninjascript output window.

    Here is a link to tips on debugging: https://ninjatrader.com/support/help...script_cod.htm

    If you are using the Strategy Builder then here is a short video that will help walk through constructing a print statement: https://paul-ninjatrader.tinytake.co...NV8xMDk5MDc5Nw

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you very much

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by chbruno, 04-24-2024, 04:10 PM
      4 responses
      50 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      10 responses
      398 views
      1 like
      Last Post beobast
      by beobast
       
      Started by lorem, Yesterday, 09:18 AM
      5 responses
      20 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by WHICKED, Today, 12:56 PM
      2 responses
      15 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Started by Felix Reichert, Today, 02:12 PM
      0 responses
      4 views
      0 likes
      Last Post Felix Reichert  
      Working...
      X