Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Elliot oscillator from Thinkorswim to Ninjatrader 8

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

    Elliot oscillator from Thinkorswim to Ninjatrader 8

    Hi, Does anyone know how to convert a ThinkOrSwim technical indicator code to NinjtaScript?

    The code is quite simple but I can't manage to make it work on NT8. The indicator is a price oscillator with breakout lines:

    # --- Price Oscillator w/ breakout lines 10/31/2018 ----

    declare lower;
    input price = hl2;
    input HistoType = {default STD};
    input SmoothLength = 5;

    def valueDiff;
    def value;
    def showBands;

    switch (HistoType) {
    case STD:
    value = Double.NaN;
    valueDiff = 100 * (ExpAverage(price, 5) - ExpAverage(price, 9)) / ExpAverage(price, 9);
    showBands = 1;
    }

    #------------BREAKOUT LINES-----------------------------

    def coeff_num = 2;
    def coeff_denom = 40;

    def barNum = if IsNaN( close ) then Double.NaN else BarNumber();
    def coeff = coeff_num / ( coeff_denom );


    rec _upLine = if barNum == 1 then
    if Valuediff >= 0 then
    Valuediff * coeff + Valuediff * ( 1 - coeff )
    else
    0
    else
    if Valuediff >= 0 then
    Valuediff * coeff + _upLine[1] * ( 1 - coeff )
    else
    _upLine[1];
    rec _dnLine = if barNum == 1 then
    if Valuediff < 0 then
    Valuediff * coeff + Valuediff * ( 1 - coeff )
    else
    0
    else
    if Valuediff < 0 then
    Valuediff * coeff + _dnLine[1] * ( 1 - coeff )
    else
    _dnLine[1];

    plot UpLine = if showBands then _upLine else Double.NaN;
    plot DownLine = if showBands then _dnLine else Double.NaN;

    UpLine.SetDefaultColor(GetColor(9));
    UpLine.SetLineWeight(1);
    DownLine.SetDefaultColor(GetColor(9));
    DownLine.SetLineWeight(1);

    #---------------------PLOTS------------------------------

    plot Osc = valueDiff;
    Osc.SetDefaultColor(GetColor(5));
    Osc.SetPaintingStrategy(PaintingStrategy.HISTOGRAM );
    Osc.SetLineWeight(3);
    Osc.DefineColor("Positive and Up", Color.GREEN);
    Osc.DefineColor("Positive and Down", Color.DARK_GREEN);
    Osc.DefineColor("Negative and Down", Color.RED);
    Osc.DefineColor("Negative and Up", Color.DARK_RED);

    Osc.AssignValueColor(if Osc > 0 then if Osc >= UpLine then Osc.Color("Positive and Up") else Osc.Color("Positive and Down") else if Osc <= DownLine then Osc.Color("Negative and Down") else Osc.Color("Negative and Up"));

    plot ZeroLine = 0;
    ZeroLine.SetDefaultColor(GetColor(7));

    ---------------------------------------------------------------END----------------------------------------------------------------------------------------------------------------------------------------------

    Thanks!


    #2
    Hello bogan01,

    Below I am providing a link to a forum post with helpful information about getting started with NinjaScript.


    I am happy to answer any questions you may have about NinjaScript if you decide to code this yourself.

    This thread will remain open for any community members that would like to create this script as a convenience to you.

    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by bogan01 View Post
      Hi, Does anyone know how to convert a ThinkOrSwim technical indicator code to NinjtaScript?

      The code is quite simple but I can't manage to make it work on NT8. The indicator is a price oscillator with breakout lines:

      # --- Price Oscillator w/ breakout lines 10/31/2018 ----

      declare lower;
      input price = hl2;
      input HistoType = {default STD};
      input SmoothLength = 5;

      def valueDiff;
      def value;
      def showBands;

      switch (HistoType) {
      case STD:
      value = Double.NaN;
      valueDiff = 100 * (ExpAverage(price, 5) - ExpAverage(price, 9)) / ExpAverage(price, 9);
      showBands = 1;
      }

      #------------BREAKOUT LINES-----------------------------

      def coeff_num = 2;
      def coeff_denom = 40;

      def barNum = if IsNaN( close ) then Double.NaN else BarNumber();
      def coeff = coeff_num / ( coeff_denom );


      rec _upLine = if barNum == 1 then
      if Valuediff >= 0 then
      Valuediff * coeff + Valuediff * ( 1 - coeff )
      else
      0
      else
      if Valuediff >= 0 then
      Valuediff * coeff + _upLine[1] * ( 1 - coeff )
      else
      _upLine[1];
      rec _dnLine = if barNum == 1 then
      if Valuediff < 0 then
      Valuediff * coeff + Valuediff * ( 1 - coeff )
      else
      0
      else
      if Valuediff < 0 then
      Valuediff * coeff + _dnLine[1] * ( 1 - coeff )
      else
      _dnLine[1];

      plot UpLine = if showBands then _upLine else Double.NaN;
      plot DownLine = if showBands then _dnLine else Double.NaN;

      UpLine.SetDefaultColor(GetColor(9));
      UpLine.SetLineWeight(1);
      DownLine.SetDefaultColor(GetColor(9));
      DownLine.SetLineWeight(1);

      #---------------------PLOTS------------------------------

      plot Osc = valueDiff;
      Osc.SetDefaultColor(GetColor(5));
      Osc.SetPaintingStrategy(PaintingStrategy.HISTOGRAM );
      Osc.SetLineWeight(3);
      Osc.DefineColor("Positive and Up", Color.GREEN);
      Osc.DefineColor("Positive and Down", Color.DARK_GREEN);
      Osc.DefineColor("Negative and Down", Color.RED);
      Osc.DefineColor("Negative and Up", Color.DARK_RED);

      Osc.AssignValueColor(if Osc > 0 then if Osc >= UpLine then Osc.Color("Positive and Up") else Osc.Color("Positive and Down") else if Osc <= DownLine then Osc.Color("Negative and Down") else Osc.Color("Negative and Up"));

      plot ZeroLine = 0;
      ZeroLine.SetDefaultColor(GetColor(7));

      ---------------------------------------------------------------END----------------------------------------------------------------------------------------------------------------------------------------------

      Thanks!
      How would the calculation of the breakdown bands be .. ?? but that is understandable .. it is to calculate in excel ...

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      577 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