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 WHICKED, Today, 12:45 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by samish18, Today, 01:01 PM
      0 responses
      5 views
      0 likes
      Last Post samish18  
      Started by WHICKED, Today, 12:56 PM
      0 responses
      7 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Started by Spiderbird, Today, 12:15 PM
      2 responses
      11 views
      0 likes
      Last Post Spiderbird  
      Started by FrazMann, Today, 11:21 AM
      2 responses
      8 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Working...
      X