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 sjsj2732, Yesterday, 04:31 AM
      0 responses
      28 views
      0 likes
      Last Post sjsj2732  
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      284 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      281 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      132 views
      1 like
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      90 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Working...
      X