Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Signal code blanks indi

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

    Signal code blanks indi

    i combined two MFIs to make an MFI crossover indi
    and for some reason this one is kicking my a__

    every other indicator that i've added signals to works fine
    i'm adding signals to this one just like all the others
    but after compiling successfully, with a signal condition, the indicator won't show at all ???

    if i remove the signal condition the indicator displays in its sub-panel just fine

    what is up with this - i just can't figure out what i'm doing wrong

    i attached the problem child....

    this is the code that kills the indi (blanks the display panel):

    if ( MFIF[1] < MFIS[1] && MFIF[0] > MFIS[0] )
    {
    Print ("fast cross above slow");
    Print ("Current Bar=" + Bars.CurrentBar);
    }

    i had originally set the condition to draw a verticle line
    and i've dumbed it down to a Print command - which still doesn't work
    Last edited by stafe; 03-26-2014, 10:01 PM.

    #2
    Hello Stafe,

    Thank you for your post.

    Are you receiving any errors from your Log Tab in the Control Center?

    I see that you do have a CurrentBar check but are not returning the method.

    Try putting in return; after you set the MFIF
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      totally forgot to check the LOG...
      i'm getting an error on bar 0 because of the condition check trying to access bar -1
      forgot to insert a wait loop to gather enough bars before running the condition check
      duh...

      thanks !
      i'll add that then see what happens

      Comment


        #4
        you mentioned that i "wasn't returning the method"
        this is something i don't quite understand yet about C# programing in general
        when i use a series of if() statements i've been ok in some instances without using "return;"
        you mentioned i might need a "return;" after i set MFIF
        but in the past i've Set multiple Values[ ] without using a "return;" in-between
        when do i really need a return and what does it actually do ??
        i'm a very elementary programer (if you could even call me that)...
        thanks,
        wes

        protected override void OnBarUpdate()
        {
        if (CurrentBar == 0)
        {
        MFIF.Set (50);
        MFIS.Set (50);
        }
        else
        {
        negativeF.Set(Typical[0] < Typical[1] ? Typical[0] * Volume[0] : 0);
        positiveF.Set(Typical[0] > Typical[1] ? Typical[0] * Volume[0] : 0);

        MFIF.Set(SUM(negativeF, PeriodF)[0] == 0 ? 50 : 100.0 - (100.0 / (1 + SUM(positiveF, PeriodF)[0] / SUM(negativeF, PeriodF)[0])));

        negativeS.Set(Typical[0] < Typical[1] ? Typical[0] * Volume[0] : 0);
        positiveS.Set(Typical[0] > Typical[1] ? Typical[0] * Volume[0] : 0);

        MFIS.Set(SUM(negativeS, PeriodS)[0] == 0 ? 50 : 100.0 - (100.0 / (1 + SUM(positiveS, PeriodS)[0] / SUM(negativeS, PeriodS)[0])));


        }

        if ( MFIF[1] < MFIS[1] && MFIF[0] > MFIS[0] )
        {
        Print ("fast cross above slow");
        Print ("Current Bar=" + Bars.CurrentBar);
        }
        Last edited by stafe; 03-26-2014, 10:09 PM.

        Comment


          #5
          Stafe,

          The return is only being used for a current bar check. Since, you have instances where you are requesting to look a 1 bar ago, [1]. The script will start at the very first on the chart which is considered 0 at that time in the index. Since, you are requesting to look back an additional bar when there is only one bar in the index, it will cause an error.

          The link below will explain this in more detail -
          http://www.ninjatrader.com/support/f...ead.php?t=3170
          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
          579 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 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
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X