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

looking for an ema based on min bars to run on volume chart

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

    looking for an ema based on min bars to run on volume chart

    not even sure how i would search for such a thing - haven't had any luck...
    but i'm looking for or would like to know how to write or setup an EMA that is based on a 2min calculation overlaid on my current volume based bar charts...
    thanks,
    wes

    i do have rudimentary C# skills

    #2
    Hello stafe,

    All links below are publicly available.

    Below is a link to a video that demonstrates using a secondary series for the input series of an indicator.



    Also, below is a link to the help guide on AddDataSeries().


    And a link to the SMA in the help guide.


    As well as a link to an example script that demonstrates using a secondary series.
    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      thanks for the reply Chelsea... i tried adding a 2min data series to my volume chart like the video tutorial and it made all my hull moving averages ripply like ruffles potato chips.... odd... gonna have to figure something else out.... more reading to do.... /w

      Comment


        #4
        Hello stafe,

        When using multiple series, this will disable the equidistant bar spacing and attempt to show each bar for both series at the correct time.

        Adding a data series to a custom indicator and using this as the input series for a call to the SMA would not cause this behavior.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          oh, i'm a little stuck...
          i'm trying to get this indicator to plot a 2min hull with bollinger bands on a volume based chart...


          do i call the second data series (2min) in OnBarUpdate by using the following 2 lines in place of the first two lines in OnBarUpdate?
          double hma0 = hma(Inputs[1][0];
          double stdDev0 = stdDev(Inputs[1][0];



          it just seems like i should be calling the 2nd data series (2min) earlier - like before State = = State.DataLoaded



          thanks/sf




          namespace NinjaTrader.NinjaScript.Indicators
          {
          public class BollingerHMA2minute : Indicator
          {
          private HMA hma;
          private StdDev stdDev;

          private int plot0Width = 2;
          private PlotStyle plot0Style = PlotStyle.Line;
          private DashStyleHelper dash0Style = DashStyleHelper.Solid;
          private int plot1Width = 4;
          private PlotStyle plot1Style = PlotStyle.Line;
          private DashStyleHelper dash1Style = DashStyleHelper.DashDot;


          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Description = @"";
          Name = "BollingerHMA2minute";
          IsOverlay = true;
          IsSuspendedWhileInactive = true;
          ArePlotsConfigurable = false;
          IsAutoScale = false;
          Calculate = Calculate.OnPriceChange;

          BarsRequiredToPlot = (Period * 2);
          NumStdDev = 1.0;
          Period = 100;
          ChannelOpacity = 0;

          AddPlot(Brushes.Gray, "upper");
          AddPlot(Brushes.Gray, "middle");
          AddPlot(Brushes.Gray, "lower");

          UpBrush = Brushes.Green;
          DownBrush = Brushes.Red;
          NeutralBrush = Brushes.Yellow;
          }

          else if (State == State.Configure)
          {

          ------------------ AddDataSeries (BarsPeriodType.Minute, 2);

          Plots[0].PlotStyle = plot0Style;
          Plots[0].DashStyleHelper = dash0Style;
          Plots[0].Width = plot0Width;
          Plots[1].PlotStyle = plot1Style;
          Plots[1].DashStyleHelper = dash1Style;
          Plots[1].Width = plot1Width;
          Plots[2].PlotStyle = plot0Style;
          Plots[2].DashStyleHelper = dash0Style;
          Plots[2].Width = plot0Width;

          }
          else if (State == State.DataLoaded)
          {
          hma = HMA(Period);
          stdDev = StdDev(Period);
          }
          }

          protected override void OnBarUpdate()
          {



          ---------------- double hma0 = hma[0];
          ---------------- double stdDev0 = stdDev[0];

          Upper[0] = hma0 + NumStdDev * stdDev0;
          Middle[0] = hma0;
          Lower[0] = hma0 - NumStdDev * stdDev0;


          }

          Comment


            #6
            i tried everything... Inputs[1] and BarsArray [1] in every permutation i could think of based on all the examples and question i read through on the forum


            several "versions" i could get to compile but they wouldn't plot and the message in the log kept repeating : You are accessing an index with a value that is invalid since it is out of range....


            i decided to start over and add each argument that i could and compile and see what happens and as soon as i add the 2min data series in State.Configure:
            AddDataSeries(BarsPeriodType.Minute, 2):
            i get the out of range error after compiling and trying to plot...


            my final guess after reading everything i could find was to make the switch to the 2nd data series (2minute) under State.DataLoaded by changing the inputs on the HMA and StdDev to this:


            hma = HMA(BarsArray[1], Period);
            stDev = StdDev(BarsArray[1], Period);


            shouldn't that be all i need to have made the entire indicator plot only the 2min 2nd data series ?


            but nothing plots because there's some out of range thing gonig on that i can't comprehend that seems to be introduced just by adding the 2nd Bars series...

            Comment


              #7
              Hello stafe,

              You will need to ensure that each series has a bar.

              Below is a public link to a reference sample that demonstrates using a added series for the input of an indicator call.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Aviram Y, Today, 05:29 AM
              0 responses
              1 view
              0 likes
              Last Post Aviram Y  
              Started by quantismo, 04-17-2024, 05:13 PM
              3 responses
              25 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by ScottWalsh, 04-16-2024, 04:29 PM
              7 responses
              34 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by cls71, Today, 04:45 AM
              0 responses
              6 views
              0 likes
              Last Post cls71
              by cls71
               
              Started by mjairg, 07-20-2023, 11:57 PM
              3 responses
              216 views
              1 like
              Last Post PaulMohn  
              Working...
              X