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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      576 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X