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

JTHMA indicator

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

    JTHMA indicator

    Hi there

    Wonder if the programmers here can help me?

    I have the following JTHMA from a Tradestation indicator:

    Code:
     
    Type : Function, Name : jtHMA
    {jtHMA - Hull Moving Average Function}
    {Author: Atavachron}
    {May 2005} 
    
    Inputs: price(NumericSeries), length(NumericSimple);
    Vars: halvedLength(0), sqrRootLength(0);
    {
    Original equation is:
    ---------------------
    waverage(2*waverage(close,period/2)-waverage(close,period), SquareRoot(Period)
    Implementation below is more efficient with lengthy Weighted Moving Averages.
    In addition, the length needs to be converted to an integer value after it is halved and
    its square root is obtained in order for this to work with Weighted Moving Averaging
    }
    if ((ceiling(length / 2) - (length / 2)) <= 0.5) then
    halvedLength = ceiling(length / 2)
    else
    halvedLength = floor(length / 2);
    if ((ceiling(SquareRoot(length)) - SquareRoot(length)) <= 0.5) then
    sqrRootLength = ceiling(SquareRoot(length))
    else
    sqrRootLength = floor(SquareRoot(length));
    Value1 = 2 * WAverage(price, halvedLength);
    Value2 = WAverage(price, length);
    Value3 = WAverage((Value1 - Value2), sqrRootLength);
    jtHMA = Value3;
    Code:
     
    Type : Indicator, Name : jtHMA
    {jtHMA - Hull Moving Average Indicator}
    {Author: Atavachron}
    {May 2005}
    
    {
    Inputs:
    -------
    price: the time series being smoothed, usually Close, High, etc,
    but could be RSI(Close, 25) for example.
    length: the length of the MA, pretty meaningless in the normal sense
    of moving averages, as this quantity is heavily modified
    in the code. You need to experiment, do not just use a setting
    of 20 because that is what works for you with Simple Moving Averages.
    zeroLine: if you are using this in an indicator pane, you might
    want to display a centre line of some sort, ths allows
    one to set its value
    zeroVisible: boolean variable, determines whether the centre line
    (zeroLine) is plotted.
    upColour: If you wish to differentiate upward movements by colour coding.
    downColour: If you wish to differentiate downward movements by colour coding.
    colourDeltaBar: Set this to 1 if you wish the colour change to be effective on
    the actual bar where the direction change occurred.
    Set this to 0 for default behaviour. All other values
    are pretty meaningless.
    } 
    Inputs: price(Close), length(21),
    zeroLine(0.0), zeroVisible(false),
    upColour(Blue), downColour(Red), colourDeltaBar(1);
    Value1 = jtHMA(price, length);
    Plot1(Value1, "jtHMA");
    If ZeroVisible = true then
    Plot2(zeroLine, "Zero");
    { Color criteria }
    if (Value1 > Value1[1]) then 
    SetPlotColor[colourDeltaBar](1, upColour)
    else if (Value1 < Value1[1]) then 
    SetPlotColor[colourDeltaBar](1, downColour);
    Can someone please help me in translating that to a Ninja C# Code

    Thankyou

    #2
    Hi ninjamouse, the Hull MA is already available in NinjaTrader - http://www.ninjatrader-support.com/H...verageHMA.html

    You can find it also under HMA in the 'Indicators' selection list.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Coolm OK, do you think the code can be changed so that it displays a green/red line depending on if its a up/down trend. Just like this:





      Thanks

      Comment


        #4
        Sure, please check into this reference sample for this - http://www.ninjatrader-support2.com/...ead.php?t=3227
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ghoul, Today, 06:02 PM
        2 responses
        12 views
        0 likes
        Last Post ghoul
        by ghoul
         
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        44 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        180 views
        0 likes
        Last Post jeronymite  
        Started by DanielSanMartin, Yesterday, 02:37 PM
        2 responses
        13 views
        0 likes
        Last Post DanielSanMartin  
        Working...
        X