Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Coding problem

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

    Coding problem

    I'm trying to exit a position if there is a increase in volume over the last two bars and the price goes below the lowest low of the last two bars. My code is below, I can't see anything wrong with this and it compiles ok but has no affect when back testing. 'Volnumber' is a variable interger everything esle is self explanatory.


    if (Volume[0] > Volnumber
    && Volume[1] > Volnumber
    && GetCurrentAsk() < MIN ((Low), 2)[0])

    {
    ExitLong();
    }
    Any ideas would be appreciated.

    Thanks

    Mark

    #2
    Mark, when backtesting GetCurrentAsk() will give the close of the bar. Please try this on a real-time test and see if the results are different. You can also add debugging statements to the code to ensure the conditions are being met, like this:
    Code:
    if (Volume[0] > Volnumber && Volume[1] > Volnumber)
    {
       Print("volume is getting big");
       
       if (GetCurrentAsk() < MIN(Low, 2)[0])
       {
          Print("ask is less than low, exit position");
          ExitLong();
        }
    }
    AustinNinjaTrader Customer Service

    Comment


      #3
      Sorry to intrude with a trivia question here, but where does the debugging statement 'print' when you do this? On the chart somewhere?

      Comment


        #4
        Print displays in the output window.

        Tools --> Output window.
        Once you have this window open, refresh the chart with the indicator on it that has the "Print" code.
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #5
          MrLogik, thank you for the clarification.

          Bill, Mark, if you have any other questions, please let us know.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Thanks mrlogik. You have been helpful in the past also.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            637 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            366 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            107 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            569 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            571 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X