Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

convert EasyLanguage to NinjaScript

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

    convert EasyLanguage to NinjaScript

    I have the following simple code that I use for multicharts. it's an EMA that changes color based on how much it changes direction. I want to use it in Ninja as well but don't know how to program ninjascript yet. how hard would it be to do this?

    Code:
    inputs:       Length(12), BiasVar(.5), TicVal(.0001), 
                     PlotTrue(true), PlotRnd(false), BuyColor(Green), SellColor(Red);
     
    variables:   EMAval(0), TestVal(0), TVal(0), PlotColor(Green);
     
    EMAval = XAverage(Close, Length);
     
    If CurrentBar = 1 then begin
         TestVal = EMAval;
         TVal = 1;
         PlotColor = Green;
    end;
     
    If TVal = 1 then begin 
         If EMAval <= (TestVal - BiasVar) then begin
              TVal = -1;
              TestVal = EMAval;
              PlotColor = Red;
         end else begin 
              TestVal = maxlist(TestVal, EMAval);
         end;
    end else 
    If TVal = -1 then begin
         If EMAval >= (TestVal + BiasVar) then begin 
              TVal = 1;
              TestVal = EMAval;
              PlotColor = Green;
         end else begin 
              TestVal = minlist(TestVal, EMAval);
         end;
    end;
     
    If EMAval <> 0 then begin 
         If PlotTrue then Plot1(EMAval, "AvgExp", PlotColor);
         If PlotRnd then Plot2( (round((EMAval/TicVal),0)*TicVal), "ExpRnd", PlotColor);
    end;

    #2
    If you're not very familiar with coding in our NinjaScript yet, I would suggest checking into shared indicators already on the same topic, especially the MA Slope Box - http://www.ninjatrader.com/support/f...h=Slope&desc=1

    To get started creating your own scripts, these tutorials here would be a great start -

    Comment


      #3
      There are many indicators available for NinjaTrader that are colored according to slope.

      One example is the Keltner Universal Indicator. The midband can be selected from a median and 27 different moving averages. There are three colors for the slope. The colors represent a rising, falling and flat moving average. The range of "flat slopes" can be adjusted.

      There is an option not to display the Keltner Channel and you will have a moving average. The channels can be colored according to midband or channel slope.

      If you wish to color the moving average according to the second derivative instad of the first, you can do this by modifying the indicator, which can be found here:



      Membership is required to download the indicators (you will get a couple of hundred NinjaTrader indicators for a low one-time membership fee). I have no financial links with Big Mike, who is running the forum. You can also send me a private message with your e-mail, and I will send you the (open source) indicator.
      Attached Files

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      164 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      318 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      246 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      350 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      179 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X