Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Momentum Script.

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

    Momentum Script.

    Tried my best to convert this TOS script. Seems simple but still learning NT. Any help please?

    input length = 14;
    input calcLength = 5;
    input smoothLength = 3;

    def o = open;
    def c = close;
    def data = fold i = 0 to length
    with s
    do s + (if c > getValue(o, i)
    then 1
    else if c < getValue(o, i)
    then - 1
    else 0);
    def EMA5 = ExpAverage(data, calcLength);
    plot Main = ExpAverage(EMA5, smoothLength);
    plot Signal = ExpAverage(Main, smoothLength);




    Main.AssignValueColor(if Main > Signal
    then color.green
    else color.red);
    Signal.AssignValueColor(if Main > Signal
    then color.green
    else color.red);
    Signal.HideBubble();
    Signal.HideTitle();
    addCloud(Main, Signal, color.green, color.red);
    plot zero = if isNaN(c) then double.nan else 0;
    zero.SetDefaultColor(Color.gray);
    zero.hideBubble();
    zero.hideTitle();
    plot ob = if isNaN(c) then double.nan else round(length * .7);
    ob.SetDefaultColor(Color.gray);
    ob.HideBubble();
    ob.HideTitle();
    plot os = if isNaN(c) then double.nan else -round(length * .7);
    os.SetDefaultColor(Color.gray);
    os.HideBubble();
    os.HideTitle();
    addCloud(ob, length, color.light_red, color.light_red, no);
    addCloud(-length, os, color.light_green, color.light_green);

    #2
    Hi, thanks for posting.

    I will not be able to convert this, unfortunately. We do have a "Momentum" indicator in the platform by default that you can view the source code of through New>NinjaScript Editor.

    Kind regards,
    -ChrisL

    Comment


      #3
      Thank you!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      80 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X