Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 andrewtrades, Today, 04:57 PM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by chbruno, Today, 04:10 PM
          0 responses
          3 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          436 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          6 views
          0 likes
          Last Post FAQtrader  
          Started by rocketman7, Today, 09:41 AM
          5 responses
          19 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X