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 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
      43 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