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

Normalising the Output of the MACD

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

    #31
    That's what I did so far, but how can I get around the inherent issue that arises when comparing a string (the instrument) to a bool (the multiplier)?

    protected override void OnBarUpdate()
    {

    if (Instrument.MasterInstrument.Name = "FDAX")
    {
    Multiplier1 = 1;
    }

    if (Instrument.MasterInstrument.Name = "6E")
    {
    Multiplier1 = 10000;
    }

    Sorry to bother you again with this, but I'm confident that this is the last thing I'll have to ask you.

    Comment


      #32
      You miss an equal sign comparing for equality in your Instrument check -

      Code:
      if (Instrument.MasterInstrument.Name == "FDAX")
      			{
      				Multiplier = 1;
      			}
      
      if (Instrument.MasterInstrument.Name == "6E")
      			{
      				Multiplier = 10000; 
      			}
      BertrandNinjaTrader Customer Service

      Comment


        #33
        Sorry for that, I should have seen it.
        Thanks a lot for your help & have a nice evening.

        Comment


          #34
          Hi Bertrand,

          Thanks to your help I now have a SINGLE MACDUpDown Indicator ("MACDUpDownDefault") that works in all markets I trade, using a multiplier ("multiplier1") to normalise the output values. This is great.

          This morning I integated it into my strategy but when I call it, I get a "No Overload for Method 'MACDUpDownDefault' takes 3 arguments" error message. This is probably due to the fact that the multiplier is now part of the MACD. The Intellisense mouse-over message says: (int fast, int multiplier1, int slow, int smooth) (+1 overload). How can I correct this issue?

          This is the code snippet:

          if(MACDUpDownDefault(12, 26, 9)[0] <15)
          {
          MACDBoundaryLong = true;
          }
          else
          {
          MACDBoundaryLong = false;
          }

          Thanks a lot.

          Comment


            #35
            Correct, you added a new parameter, thus this needs to be reflected in the way you call it - Intellisense is your guide here...after the fast input, it would expect now the mulitplier input.
            BertrandNinjaTrader Customer Service

            Comment


              #36
              I understand that and the error message disappears when I add the multiplier, but this is where the problem lies: the multiplier is dependent on the chart the strategy is applied to ("1" for Dax, "1000" for Euro etc, so I should not put it in manually.

              When I do, it seems to work but when I hit F5 to refresh the strategy and reflect the change, it takes 10 seconds before the chart appears again and the system almost crashes. (It usually takes 1-2 seconds for a strategy to refresh).

              Code snippet:
              if(MACDUpDownDefault(12, 1, 26, 9)[0] <15).

              The value of 1 should not be put in manually in my opinion, because it is automatically assigned by the MACDUpDownDefault indicator depending on which market the strategy is applied to.

              Comment


                #37
                Well, if those were two different routes to your goal - to make the indicator more flexible. Either you pass in the value you need for your multiplier based on what instrument you run the strategy on (then you need the user input) or you hardcode this in the indicator itself.
                BertrandNinjaTrader Customer Service

                Comment


                  #38
                  I did hardcode it into the indicator (by following what you kindly suggested yesterday), the problem is that when I call the indicator from a generic strategy I'm getting an error message unless I enter a value for the multiplier, which is precisely what I want to avoid since the multilier is assigned automatically by the indicator based on what market it is applied to in combination with the generic strategy.

                  What I'm trying to achieve is to find the right syntax to be able to call the indicator from a generic strategy WITHOUT having to enter a value for the multiplier.

                  Thanks

                  Comment


                    #39
                    laocoon, to avoid having to enter the multiplier input you would need to rework your custom indicator then and remove the added user defined input.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #40
                      OK, well thank you very much for your patience in assisting me so far.
                      I'm obviously stuck because removing the added user defined input from the indicator is not an option since it is precisely this input that normalises the indicator.

                      The line if(MACDUpDownDefault(12, 1, 26, 9)[0] <10) is not a good option because even if it is working it almost makes the system crash every time I reload it.

                      I need to find another solution I guess.

                      Thanks

                      Comment


                        #41
                        No worries - you can also simply pass in the input needed in the strategy directly and then don't code it into the indicator at all, just leave the user input for the multiplier in place, pseudo code for ideas -

                        if (Instrument == FDAX)
                        scaleMult = x;

                        if (Instrument == EURUSD)
                        scaleMult = y;

                        .....

                        Then you can later call the indicator by passing the scaleMult in -

                        oscValue = myMACD(Close, scaleMult, fast, slow, smooth)[0];
                        BertrandNinjaTrader Customer Service

                        Comment


                          #42
                          Bertrand, this sounds very promising.

                          The first part of your suggested solution is absolutely clear to me.
                          Regarding the second part, could you tell me what "oscValue" is? Is it an "int" ?

                          Currently I call the standard (non-normalised) indicator like this in the strategy:

                          if((MACDUpDown(12, 26, 9) [0] <10, ....)

                          Where does the "oscValue" fit in here?

                          Thanks again.
                          Last edited by laocoon; 09-22-2010, 10:27 AM.

                          Comment


                            #43
                            This is just a variable holding the actual value of your custom MACD oscillator you want to use then to trigger your trades, more of exemplary nature...you can also directly call your indicator with the scaleMult parameter in the if statement.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #44
                              Got it. It works perfectly!

                              Thanks again.

                              Comment


                                #45
                                Hello, I know there is an indicator called Normalized macd that indicates overbought and oversold, can somebody help me to get it? Thank you

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by GwFutures1988, Today, 02:48 PM
                                1 response
                                3 views
                                0 likes
                                Last Post NinjaTrader_Clayton  
                                Started by ScottWalsh, 04-16-2024, 04:29 PM
                                6 responses
                                27 views
                                0 likes
                                Last Post ScottWalsh  
                                Started by frankthearm, Today, 09:08 AM
                                10 responses
                                36 views
                                0 likes
                                Last Post frankthearm  
                                Started by mmenigma, Today, 02:22 PM
                                1 response
                                3 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Started by NRITV, Today, 01:15 PM
                                2 responses
                                9 views
                                0 likes
                                Last Post NRITV
                                by NRITV
                                 
                                Working...
                                X