Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 -

    BertrandNinjaTrader Customer Service

    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:

      The best futures trading community on the planet: futures trading, market news, trading charts, trading platforms, trading strategies


      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 algospoke, Today, 06:40 PM
      0 responses
      2 views
      0 likes
      Last Post algospoke  
      Started by maybeimnotrader, Today, 05:46 PM
      0 responses
      6 views
      0 likes
      Last Post maybeimnotrader  
      Started by quantismo, Today, 05:13 PM
      0 responses
      6 views
      0 likes
      Last Post quantismo  
      Started by AttiM, 02-14-2024, 05:20 PM
      8 responses
      168 views
      0 likes
      Last Post jeronymite  
      Started by cre8able, Today, 04:22 PM
      0 responses
      8 views
      0 likes
      Last Post cre8able  
      Working...
      X