Announcement

Collapse
No announcement yet.

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

    Comment


      #3
      Thank you very much

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      89 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      135 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X