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

help with coding please, compiled but didn't appear as an indicator

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

    help with coding please, compiled but didn't appear as an indicator

    public class JFZX : Indicator
    {
    #region Variables
    private DataSeries Var1;
    private DataSeries Var2;
    #endregion

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Plot1"));
    Add(new Line(Color.FromKnownColor(KnownColor.DarkOliveGree n), 50, "FiftyLine"));

    Var1= new DataSeries(this);
    Var2 = new DataSeries(this);

    CalculateOnBarClose = true;
    Overlay = false;
    PriceTypeSupported = false;
    }

    protected override void OnBarUpdate()
    {


    if (CurrentBar < 30) return;

    if(Close[0] > Open[0])
    {
    //the sum of the volume of the last 30 bars
    Var1.Set(SUM(Volume,30)[0]);
    }
    else
    {
    //minus the currentbar's volume that are false
    Var1.Set(SUM(Volume, 30)[0] - Volume[0]);
    }

    //difine Var2
    Var2.Set((Var1[0]/SUM(Volume, 30)[0])*100);


    // draw the line according to the calculation
    Plot1.Set( Var2[0]);
    }

    #2
    zhaofang8898,

    You need to include all the indicator wrappers generated from the Indicator Wizard for it to work. Please ensure they are intact.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      thanks for your reply, logic question please

      trying to convert the code from another language to NINJA script, but couldn't follow the logic. the codes are:
      // period = 30, if the current bar ' closing price > opening price, set the current bar's volume = 0
      sum(if(close[0]>open[0], vol, 0), 30) / sum(vol, 30)

      Comment


        #4
        Not sure I follow what you are asking exactly. Don't know what you mean by setting a bar's volume. It will take on whatever volume is provided by the data provider.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          what i mean was that i wanted to add the Volumes with the Closing price > Opeing price for a 30 bars period. during the past 30 bars, if the closing price < opening price, set the volume = 0 instead of the real volume. Can we do it in a loop method, or? not very sure about the how to write the logic in Ninja script language

          Comment


            #6
            zhaofang8898,

            You cannot change the volume of a bar. You can only create your own DataSeries or plot and track the "fake volume" that you want in it.

            You can create yourself a loop if you wanted. Please see this: http://www.ninjatrader-support.com/H...gCommands.html
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rtwave, 04-12-2024, 09:30 AM
            5 responses
            37 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by funk10101, Today, 12:02 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by GLFX005, Today, 03:23 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by nandhumca, Yesterday, 03:41 PM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by The_Sec, Yesterday, 03:37 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X