NexusFi: Find Your Edge


Home Menu

 





Multi Time Frame Indicator within Strategy


Discussion in NinjaTrader

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




 
Search this Thread

Multi Time Frame Indicator within Strategy

  #1 (permalink)
CableTrade
London, Ontario
 
Posts: 2 since Nov 2017
Thanks Given: 0
Thanks Received: 0

First post here so bear with me...although there is some great info on multitimeframe stuff I can't seem to get indicators that I code to show up on my charts within a strategy:

I want the base chart to be a minute chart

Indicators I am trying to add:

(EMA, 15, 1 minute) – RED (this one works fine)
(EMA, 15, 1 hour) – DARKGOLDENROD (doesn’t appear on chart)
(EMA, 15, 1 day) - BLUE (doesn’t appear on chart)

Here is the code:


protected override void Initialize()
{
CalculateOnBarClose = true;

//add 15 EMA to base chart (1 minute)
Add(EMA(15));
EMA(15).Plots[0].Pen.Color = Color.Red;


// Add a hourly bars object to the strategy
Add(PeriodType.Minute, 60); // BarsArray[1]

// Add a daily bars object to the strategy
Add(PeriodType.Day, 1); // BarsArray[2]

// Add 1 hour 15 period EMA indicator on the chart
Add(EMA(BarsArray[1], 15));
EMA(BarsArray[1], 15).Plots[0].Pen.Color = Color.DarkGoldenrod;


// Add daily 15 period EMA indicator on the chart
Add(EMA(BarsArray[2], 15));
EMA(BarsArray[2], 15).Plots[0].Pen.Color = Color.Blue;


}

protected override void OnBarUpdate()
{

}

Thanks,

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
What broker to use for trading palladium futures
Commodities
 
  #3 (permalink)
CableTrade
London, Ontario
 
Posts: 2 since Nov 2017
Thanks Given: 0
Thanks Received: 0


First off I should note that I am trying to develop code for forex pairs (in case that might make a difference as there seem to be some coding nuances associated with forex)...

I seem to have found another solution here:

ninjatrader.com/support/forum/showthread.php?t=54442


but when I compile the sample script posted below I get a host of errors (which I have included as comments below the line):

protected override void Initialize()
{
Add("$USDCAD", PeriodType.Minute, 120); // BarsArray [1]
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "KAMALine"));

//Error with *new* on above line of code:
//Argument '1': cannot convert from 'NinjaTrader.Gui.Chart.Plot' to 'NinjaTrader.Indicator.IndicatorBase'

CalculateOnBarClose = true;
}

protected override void OnBarUpdate()
{
KAMALine.Set(KAMA(BarsArray[1], 2, periodKAMA, 30));

//3 Errors associated with above line of code:
//Error 1: The name 'periodKAMA' does not exist in the current context
//Error 2: The best overloaded method match for 'NinjaTrader.Data.DataSeries.Set(double)' has some invalid arguments
//Error 3: Argument '1': cannot convert from 'NinjaTrader.Indicator.KAMA' to 'double'

}

#region Properties
[Description("")]
[GridCategory("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}

//this region needed for custom line that was added
[Browsable(false)]
[XmlIgnore()]
public DataSeries KAMALine
{
get { return Values[0]; }
}


#endregion
}
}


Thanks,

Reply With Quote




Last Updated on November 12, 2017


© 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