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

Composite momentum

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

    Composite momentum

    Hi all!
    I am really interested in an indicator named "composite momentum".
    It has been developed by an italian technical analyst. I have the code for metastock and prorealtime:

    -COMPOSITE MOMENTUM PER METASTOCK-

    Key
    FORMULA

    MOM:=Mov((Mov(C,3,S)-Mov(C,9,S)),1,E) / Mov(C,3,S) *100;
    Mov(
    ((Ref(Sum(If(MOM>Ref(MOM,-1),MOM-Ref(MOM,-1),0),5),-1)-
    (Ref(Sum(If(MOM>Ref(MOM,-1),MOM-Ref(MOM,-1),0),5),-1)/5)+ If(MOM>Ref(MOM,-1),MOM-Ref(MOM,-1),0)) /
    (Ref(Sum(Abs(MOM-Ref(MOM,-1)),5),-1) -
    (Ref(Sum(Abs(MOM-Ref(MOM,-1)),5),-1)/5) + Abs(MOM-Ref(MOM,-1)))*100) -
    Abs(
    ((Ref(Sum(If(MOM<Ref(MOM,-1),MOM-Ref(MOM,-1),0),5),-1)-
    (Ref(Sum(If(MOM<Ref(MOM,-1),MOM-Ref(MOM,-1),0),5),-1)/5)+ If(MOM<Ref(MOM,-1),MOM-Ref(MOM,-1),0)) /
    (Ref(Sum(Abs(MOM-Ref(MOM,-1)),5),-1) -
    (Ref(Sum(Abs(MOM-Ref(MOM,-1)),5),-1)/5) + Abs(MOM-Ref(MOM,-1)))*100))
    , 3, E)

    XTL quarterly expl
    FORMULA
    (Mov( Stoch(5,3),3,S))*2-100

    Composite momentum
    FORMULA
    Mov((Fml( "Key") + Fml( "XTL quarterly expl"))/2,2,W)


    -COMPOSITE MOMENTUM PROREALTIME-

    ////////////////////////////////////////////////////////////
    //////////////COMPOSITE MOMENTUM///////////////////
    ////////////////////////////////////////////////////////////

    rem Key formula

    media3=average[3](Close)
    media9=average[9](close)
    Mom=exponentialaverage[1]((media3-media9)/media3)*100
    diffMOM=MOM-MOM[1]
    If MOM>MOM[1] then
    temp1=diffMOM
    else
    temp1=0
    endif
    If MOM<MOM[1] then
    temp2=diffMOM
    else
    temp2=0
    endif
    sumtemp1=summation[5](temp1)
    sumtemp2=summation[5](temp2)
    abssumdiff=summation[5](abs(diffMOM))

    aa=((sumtemp1[1]-(sumtemp1[1]/5)+temp1)/(abssumdiff[1]-(abssumdiff/5)+abs(diffmom))*100)
    bb=((sumtemp2[1]-(sumtemp2[1]/5)+temp2)/(abssumdiff[1]-(abssumdiff/5)+abs(diffmom))*100)
    cc=aa-abs(bb)
    key=exponentialaverage[3](cc)

    rem XTL quarterly expl

    stoco=Stochastic[5,3](close)
    xtl=average[3](stoco)*2-100

    rem Composite momentum
    Composite=WeightedAverage[2]((key+xtl)/2)

    return Composite

    ------------------------------------------
    ------------------------------------------

    Anyone can translate for ninja?? If not can you give me the name of a consultant??

    many thanks

    #2
    kantkant2, if no one is willing to translate it for you, a list of our 3rd party NinjaScript consultants can be found here - http://www.ninjatrader.com/partners#...pt-Consultants
    AustinNinjaTrader Customer Service

    Comment


      #3
      composite momentum

      this is a picture of this oscillator....it seems really clear:
      Attached Files

      Comment


        #4
        Thanks for sharing kantkant2, hopefully this would trigger interest in the conversion process - you could also give the Derivative Osc I've posted from Constance Brown in the sharing, it should be coming close and it's pretty smooth as well while keeping lag low.

        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi KantKant2,

          Would you please post a link describing in words what this indicator does?

          Thanks
          Marc

          Comment


            #6
            Dear all,

            I built my first indicator for NT and, if possible, I would like someone looked at it as I have two problems.
            I wouldnt know which thread to use so I picked the momentum.

            This indicator should give the Weakness Index as given by Willain in his book. The problems are:
            1) I did apply it to a chart and it plotted and then it stopped plotting. I attach the ES's from yesterday.
            2) It would only plot the (Close[0]-Close[1])/Volume[0] , which is the inverse of the Weakness Index, but not the Volume[0]/(Close[0]-Close[1]).
            Can anyone shed some light and help me?

            I attach the .cs and the charts of yesterday's ES with the "inverse" Weakness Index plotted together with a volume and another chart where the Weakness does not plot anymore.
            Given my very low programming skills, I do apologise in advance if I make anyone's brows raise.

            Regards

            Comment


              #7
              Sorry, here are the attachments!
              Attached Files

              Comment


                #8
                Good morning Michael, it looks like you're missing this check here in your script :



                You would see a log tab error on the Control Center likely too, this is always a good first place to check if you run into anything unexpected...
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Good morning to you Bertrand and thank you for your reply

                  I paste the bit which is confusing me

                  protected override void OnBarUpdate()
                  {if(CurrentBar==0)
                  {
                  difference.Set(Input[0]);
                  volume.Set(Input[0]);
                  Value.Set(Input[0]);
                  }
                  else
                  {
                  difference.Set((Close[0] - Close[1])*1000000);
                  volume.Set(Volume[0]);
                  double weak = difference[0]/volume[0];
                  Value.Set(weak);
                  }}

                  I added the extra bit. The point is that this indicator plots if I set
                  double weak = difference[0]/volume[0]

                  but it doesnt if I set
                  double weak = volume[0]/difference[0]

                  and it was doing this already. If it was a problem of missing bar count shouldnt it matter whichever way I use the indicator?

                  I attach the 6E

                  Regards
                  Attached Files

                  Comment


                    #10
                    Michael, what error are you then seeing if you set it to the second option? It could be a different issue you encounter then, like a division by zero for example.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Thats the thing! there is no error at all. It compiles just fine, without any error, both version. But one plot the other doesnt. If it was a division by zero then one should be 0/something and the other should be something/0, that is inifinity. U see the riddle (at least to me)?

                      Comment


                        #12
                        Hi Michael, I was not referring to a compile error shown in the editor, but a error seen at runtime of the script, those would be shown in the Control Center > right most Log tab. Would you spot anything there as the variation giving your issues is applied to the chart?
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Ah, I see! sorry!

                          yep, just checked it. The one that does plot, difference/volume, doesnt show any error whereas the volume/difference shows a "Value outside range", like u originally said: most likely is some range value not available. but why does it do for one and not for the other? If the value is outside some range should be for both calculations? So the fix I added is not working then.

                          Comment


                            #14
                            The fix you added works - there's a plot now and no issues on CurrentBar == 0 as you would not reference one bar back here.

                            But another issue came up, which is generating a plot value outside of the valid range...I suspect your division 'blowing up' here. You would need to debug the value generated here via Prints, they should still go to the output window in such cases as they are only non suitable for the Plot() method.

                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              Thank you very much Bertrand!

                              I will check this debugging thing.

                              Regards

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,610 views
                              0 likes
                              Last Post aligator  
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              19 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              16 views
                              0 likes
                              Last Post Javierw.ok  
                              Working...
                              X