Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Erratic behaviour

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

    Erratic behaviour

    I'm sick and tired of C#,
    I wish that I could sell it,
    it never does just what I want,
    but only what I tell it

    But anyway,

    I have an indicator that I wrote and it works fine and all outputs of a method within the indicator are fine. However, when I call the method from within my strategy, every now and again, I get a previous/incorrect result (I have attached 2 outputs, one for the indicator at 2030 and one for the strategy at 2030).

    Any ideas why I would get one set of results for the indicator and an "almost" identical set of results for the strategy?
    entryA should only change when all the conditions are met and this works perfectly as an indicator, but call entryA from the strategy and the results differ? Any ideas/thoughts?

    Here is a piece of the indicator ... entryA is methodized later

    if((High[0] > BullCa() - cTolerance) //BullCa Check
    && (High[0] < BullCb() + cTolerance)
    && ((aValue - xValue) > XAMin)
    && (bBar < aBar)
    &&(aBar < xBar)
    && (Low[bBar] > BullB() - bTolerance)
    //BullB Check
    && (Low[bBar] < BullB() + bTolerance)
    //double value = MIN(Low, 20)[0];
    && (MIN(Low,xBar)[0] >= xValue)
    && (MAX(High,xBar)[
    0] <= aValue)
    && (fireC ==
    0)) //BullB Check
    {
    AXDiff = High[aBar] - Low[xBar];
    Plot0.Set(BullX());
    Plot1.Set(BullA()); //
    Plot2.Set(BullB()); //
    Plot3.Set(BullCa()); //

    Plot4.Set(BullDa());
    //
    Plot5.Set(BullDb()); //
    Plot6.Set(BullTa()); //
    Plot7.Set(BullTb()); //
    Plot8.Set(BullTc()); //
    Plot9.Set(BullTd()); //
    entryA = BullDa();
    fireC =
    1;
    }
    ...in the properties section...
    [Browsable(false)]
    [XmlIgnore()]
    publicdouble EntryA
    {
    get { Update(); return entryA; }
    }


    Now for the strategy ...

    Print(Time + " : " + storeValue + " : " + GartleyRobotBull(5, 2, 65).EntryA);
    if(storeValue != GartleyRobotBull(5, 2, 65).EntryA)
    {
    storeValue = GartleyRobotBull(
    5, 2, 65).EntryA;
    longCount =
    0;
    }

    //if ((Lows[1][1] > storeValue)
    if ((Low[1] > storeValue)
    //&& (Lows[1][0] <= storeValue)
    && (Low[0] <= storeValue)
    && (longCount ==
    0))
    {
    //EnterLong(1, 1, "Long: 1min");
    EnterLong();
    longCount=
    1;
    //Print(Time + " : " + storeValue + " : " + Low[0] + " : " + longCount);

    }


    Attached Files

    #2
    Hi traderT,

    From your indicator do you have a CalculateOnBarClose line? If so, please remove this line. There is a bug related to this.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I still hate C#

      I think I did change it to false, but I have now remmed it out and things are looking good. Thanks again.

      Comment


        #4
        Debug update

        Could that sort of bug be incorporated into the debugger for strategies so that things like this come up as an error when trying to compile?

        Comment


          #5
          Not possible. This is a runtime error.
          Josh P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          566 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          330 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          547 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          548 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X