NexusFi: Find Your Edge


Home Menu

 





Plotting change. Easy?


Discussion in NinjaTrader

Updated
    1. trending_up 1,023 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

Plotting change. Easy?

  #1 (permalink)
 traderjh 
South Jordan UT
 
Experience: Intermediate
Platform: Ninjatrader
Trading: Forex
Posts: 15 since Jan 2013
Thanks Given: 6
Thanks Received: 1

Hello all,

I got PMA indicator from public domain and I like to try using this for strategy. I am trying to modify PMA indicator into a strategy. But it doesn't work for me. I know I have a lot to learn. It is a simple program and I am not familiar with the differences between indicator and strategy plottings.

Would it be possible if you could just modify those lines below? I hope it is not too big of a task and is really simple. Is it doable?

Let me know.

Many thanks,
-traderjh


 
Code
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    /// <summary>
    /// Predictive Moving Average (ehlers)
    /// </summary>
    [Description("Predictive Moving Average (ehlers)")]
    public class PMA : Indicator
    {
        #region Variables
    // declare the variables here
        double WMA2;
        double Trigger;
		
    // create the dataseries here
	private DataSeries WMA1;
	private DataSeries Predict;
        #endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
            // add the plots here
            Add(new Plot(new Pen(Color.Blue, 3), PlotStyle.Line, "Predict_Plot"));
            Add(new Plot(new Pen(Color.Red, 3), PlotStyle.Line, "Trigger_Plot"));
            CalculateOnBarClose    = true;
            Overlay                = false;
            PriceTypeSupported    = true;
			
	// initialize dataseries here
	   WMA1 = new DataSeries(this);
	   Predict = new DataSeries(this);
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
	// if there isn't enough data just set the variables to 0
            if (CurrentBar < 7) 
            {
                WMA1.Set(0);
                WMA2 = 0;
                Predict.Set(0);
                Trigger = 0;
            }
	// else set the variables to the real values
            else
            {
		WMA1.Set((7*Median[0] + 6*Median[1] + 5*Median[2] + 4*Median[3] + 3*Median[4] + 2*Median[5] + Median[6])/28);
		WMA2 = (7*WMA1[0] + 6*WMA1[1] + 5*WMA1[2] + 4*WMA1[3] + 3*WMA1[4] + 2*WMA1[5] + WMA1[6])/28;
		Predict.Set(2*WMA1[0] - WMA2);
		Trigger = (4*Predict[0] + 3*Predict[1] + 2*Predict[2] + Predict[3])/10;
	}
			
	    // set the plots
		Predict_Plot.Set(Predict[0]);
		Trigger_Plot.Set(Trigger); 
        }

        #region Properties;
		// create the dataseries for the plots
        [Browsable(false)]   // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]       // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries Predict_Plot
        {
        get { return Values[0]; }
        }
        [Browsable(false)]   // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]       // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries Trigger_Plot
        {
        get { return Values[1]; }
        }
        #endregion

    }
}

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Strategy stop orders partially filled
EasyLanguage Programming
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
ZombieSqueeze
Platforms and Indicators
What broker to use for trading palladium futures
Commodities
 




Last Updated on January 30, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts