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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          64 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          149 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          99 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X