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 cmoran13, Yesterday, 01:02 PM
            0 responses
            27 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            18 views
            0 likes
            Last Post PaulMohn  
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            160 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            95 views
            1 like
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            148 views
            2 likes
            Last Post CaptainJack  
            Working...
            X