Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Min

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

    Min

    I have a strategy with two time frames. I'm using the MIN() statement on the primary data series and am getting unexpected results. The majority of my code is based upon the primary data series, the other part that refers to the secondary data series and uses the following;

    if(BarsInProgress == 1)
    {
    }


    The rest of my code responds properly in except for the MIN() statement. It is being used like this; MIN(Low,3)[0], but it always returns the low of the previous bar. By the way, my strategy is being run with CalculateOnBarClose = false.

    Because I'm using two time-frames, is there additional, or different syntax to get the MIN() statement to work properly?

    Thanks for your time.

    Safetrading

    #2
    Hi Safetrading,

    Thank you for posting.

    Can you please provide a sample of the code that you are using in script for the MIN
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      this line is one of the qualifying conditions for my entry;

      && MIN(Low,LongHammer)[0] >= Low[LongHammer]

      the "LongHammer" variable is an integer that ranges between 0 and 5. the right portion of the code, Low[LongHammer] returns the correct value, but the MIN(Low,LongHammer)[0] does not.

      Comment


        #4
        In case the above wasn't enough, I believe this is the pertinent code and structure you will need to look at;

        protected override void Initialize()
        {
        Add(PeriodType.Second, 20);
        SetStopLoss("Long Stat5", CalculationMode.Ticks, 6, false);
        SetStopLoss("Short Stat5", CalculationMode.Ticks,6, false);
        SetProfitTarget("Long Stat5", CalculationMode.Ticks, 30);
        SetProfitTarget("Short Stat5", CalculationMode.Ticks, 30);

        TraceOrders = true;
        EntriesPerDirection = 1;
        CalculateOnBarClose = false;

        }
        protected override void OnBarUpdate()
        {
        if(CurrentBar < 100)return;
        if (Historical) return;

        LongSignal = Math.Min(LongHammer,LongBreak); // default values in variable section
        ShortSignal = Math.Min(ShortHammer,ShortBreak); // default values in variable section

        if(BarsInProgress == 1)
        {
        if(SellerAgression(1).Sells[0] > MAX(SellerAgression(1).Sells,14)[1] && LongSignal < 5 && LongSignal < ShortSignal)PreUp3 = 1;
        if(FirstTickOfBar && PreUp3 == 1)
        {
        UpCount = UpCount+1;
        if(UpCount >= 3)
        {
        UpCount = 0;
        PreUp3 = 0;
        }
        }

        PreUp4 = 0;
        PreDown4 = 0;
        if(Volume[0] < VolumeSpeed(1).Plot0[0] && Bars.PercentComplete >= 0.67)
        {
        PreUp4 = 1;
        PreDown4 = 1;
        }


        if(BuyerAgression(1).Buys[0] > MAX(BuyerAgression(1).Buys,14)[1] && ShortSignal < 5 && ShortSignal < LongSignal)PreDown3 = 1;
        if(FirstTickOfBar && PreDown3 == 1)
        {
        DownCount = DownCount+1;
        if(DownCount >=3)
        {
        DownCount = 0;
        PreDown3 = 0;
        }

        }




        }


        if(BarsInProgress == 1)return;




        // ******************* stat code

        // code to describe PreceBreakOut



        // code to describe LongHammer
        // code to describe ShortHammer




        if(LongHammer > 0 && LongHammer < 5
        && PriceBreakOut >= LongHammer
        && LongHammer < ShortHammer
        && LongHammer < ShortBreak
        && Close[0] <= StatisticalAnalysisEntryExitLines2(1).LongTarget[1] - (5*TickSize)
        && Close[0] >= Low[LongHammer]
        // test line
        && MIN(Low,LongHammer)[0] >= Low[LongHammer]
        && MyLongTrades < 2
        && Report == 0
        //&& DailyTarget == 0
        //&& DailyLossLimit == 0
        && LongOK == 1
        && PreUp == 1
        && PreUp3 == 1
        && PreUp4 == 1)
        {
        EnterLong("Long Stat5");
        Long1 = 1;
        MyLongTrades = MyLongTrades + 1;
        }



        } // OnBarUpdate bracket

        Comment


          #5
          Safetrading,

          I recommend you try printing out the value of the MIN() to see what value is being printed and if that relates to your code and charts.

          Code:
          Print(MIN(Low,LongHammer)[0]);
          http://www.ninjatrader.com/support/h...html?print.htm
          Cal H.NinjaTrader Customer Service

          Comment


            #6
            I have done that and the MIN() value is always the low of the previous bar while running my strategy on CalculateOnBarClose. At the same time I printed the "LongHammer" variable and is would show a number greater than 1.

            Comment


              #7
              Safetrading,

              Can you please send me a request to support[at]ninjatrader[dot]com with ATTN Cal in the subject line and a reference to this post.
              Cal H.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              656 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              371 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              109 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              574 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              579 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X