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

Higher t.f. MACD problem

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

    Higher t.f. MACD problem

    Hi,
    Need help with the higher time frame indicator please that seems not very accurate...
    I'm using 2 charts - 300 and 900 volume, where 900 is higher time frame chart.There is a regular MACD (with colored plots) attached to the 900 vol. chart. I'm using the following parameters for all my MACD indicators on all charts - 5,20,30 accordingly.

    I have custom built indicator that returns the values of higher time frame MACD (and other indicators), e.g. if MACD is neutral then return 0, 1-rising and -1 - falling. This indicator is attached to the 300 vol. chart - my lower term chart.
    To test this I'm comparing it to the regular MACD and it seems that the custom higher time frame MACD (attached to 300 vol chart) is behind the regular one (on 900 vol. chart).

    I'm attaching the screen capture where you can see that the custom MACD returns -1 (minus one) or falling at the time when the regular 900 vol. chart MACD seems rising, at least visually. Just in case I'm attaching the colored version of MACD which is regular MACD with colored plots.
    No one can help/fix the problem. Maybe Ninja can. Maybe you see what I and others do not see or understand...

    Here's the short version of the code I'm using to return the values of higher time frame MACD ind. - OnBarUpdate() - 300 vol chart:
    ....
    double macd1;
    double macd2;
    int macd_p1dir = 0; // period 1 - 900 volume
    ....
    // get higher time frame values - 900 volume chart
    if (BarsInProgress == 1) ...
    {
    macd1 = MACD(_MACDfast,_MACDslow,_MACDsmooth)[0];
    macd2 = MACD(_MACDfast,_MACDslow,_MACDsmooth)[1];

    if (macd1 > macd2)
    macd_p1dir = 1;
    else if (macd1 < macd2)
    macd_p1dir = -1;
    else macd_p1dir = 0;

    DrawText(...macd_p1dir...); // print 0 - neutral, -1 - falling, 1 - rising on the lower term chart - 300 vol.
    }

    Is there anything missed or incorrect in above code please? If you need a full version then I can email it to you directly.
    Thank you very much.
    Regards, Art.
    Attached Files
    Last edited by Art09; 04-12-2011, 01:13 PM.

    #2
    Hello Art,

    Thank you for your post.

    When you are checking BarsInProgress == 1, calling MACD() without a dataseries specified will run on BarsArray[BarsInProgress]. In your case this is the second data series.

    If you want to have macd1 be assigned the MACD of your first, 300vol data series while in BarsInProgress==1, you will need to specify the DataSeries input:

    macd1 = MACD(BarsArray[0], _MACDfast,_MACDslow,_MACDsmooth)[0];

    For more information on using BarsArray as input for indicators please see this helpguide link:


    Please give this a try and see if that solves your issue. Otherwise, I'll need you to clarify what the issue is and post the full code for your indicator.
    Last edited by NinjaTrader_Dexter; 04-12-2011, 02:01 PM.
    DexterNinjaTrader Customer Service

    Comment


      #3
      Hi Dexter,
      I still need some help please. I sent email with attachments to Ninja support with Attn to you in the subject... Adding BarsArray... did not help.
      Thank you very much.
      Art.
      Last edited by Art09; 04-13-2011, 11:57 AM.

      Comment


        #4
        Hi Dexter,
        I followed your advice and see that curr. value of the MACD is less then prior value, e.g. macd[0] < macd[1]. But then why do I see rising colors on MACD indicator? The MACD histigram (diff) is clearly showing higher low, the MACD plot seems neutral to rising... I'm asking about regular, Ninja supplied MACD indicator.
        Thank you very much.
        Art.

        Comment


          #5
          Hello Art,

          Thank you for your post.

          In your attached screenshot, you are comparing the MACD calculating from a 300 volume chart to a custom MACD indicator calculating on 900 volume chart, so differences should be expected. If you want to compare them, make sure the MACD_HistColorsV7 is set to plot from 300 volume as well, or change the top chart to 900 volume.

          If you still see discrepancies, let us know and we can take a look at it further then.
          DexterNinjaTrader Customer Service

          Comment


            #6
            Thank you, Dexter.
            I'm using two separate charts for each time frame in my for now sim trading. I tried replacing MACD plot with Diff plot in my code. Maybe this will work for me-need more testing. At least the DIff plot seems returning the correct (rising in my latest test) case value unlike the MACD plot...
            It is still a mystery for me why Diff plot is up but MACD plot is down (macd[0] < macd[1]) at the same time, although visually it looks neutral to rising as in the screen capture attached.
            Thank you very much for your help.
            Regards, Art.

            Comment


              #7
              Hi Art,

              Sure thing, you are welcome for the help. Not a bad idea to simplify until you have everything working before adding more complexity. Thick lines on plots can make it hard to tell what precise values actually are, this is when printing values with Print() really shines.

              Just let me know if I can assist any further.
              DexterNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by wzgy0920, 04-20-2024, 06:09 PM
              2 responses
              27 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 02-22-2024, 01:11 AM
              5 responses
              32 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 04-23-2024, 09:53 PM
              2 responses
              49 views
              0 likes
              Last Post wzgy0920  
              Started by Kensonprib, 04-28-2021, 10:11 AM
              5 responses
              193 views
              0 likes
              Last Post Hasadafa  
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,235 views
              0 likes
              Last Post xiinteractive  
              Working...
              X