NexusFi: Find Your Edge


Home Menu

 





Multi Time Frame Clarification


Discussion in NinjaTrader

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




 
Search this Thread

Multi Time Frame Clarification

  #1 (permalink)
 resirca52009 
Indianapolis, Indiana/ USA
 
Experience: Advanced
Platform: MT4, Ninjatrader
Broker: AMP / CQG
Trading: Futures
Posts: 64 since Oct 2012
Thanks Given: 112
Thanks Received: 35

Can someone clarify the following for me. See my text annotations scattered throughout :

Below is the code from the NT 7 Sample Multi Time Frame

public class SampleMultiTimeFrame : Strategy
{
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
#endregion

/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
// Add a 5 minute Bars object to the strategy
Add(PeriodType.Minute, 5);

// Add a 15 minute Bars object to the strategy
Add(PeriodType.Minute, 15);

// Note: Bars are added to the BarsArray and can be accessed via an index value
// E.G. BarsArray[1] ---> Accesses the 5 minute Bars object added above

// Add simple moving averages to the chart for display
// This only displays the SMA's for the primary Bars object on the chart
Add(SMA(5));
Add(SMA(50));

CalculateOnBarClose = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// OnBarUpdate() will be called on incoming tick events on all Bars objects added to the strategy
// We only want to process events on our primary Bars object (index = 0) which is set when adding
// the strategy to a chart
if (BarsInProgress != 0)
return; //So I set the strategy on a 30 minute chart; this becomes the primary series.

// Checks if the 5 period SMA is above the 50 period SMA on both the 5 and 15 minute time frames
if (SMA(BarsArray[1], 5)[0] > SMA(BarsArray[1], 50)[0] && SMA(BarsArray[2], 5)[0] > SMA(BarsArray[2], 50)[0])
{
// Checks for a cross above condition of the 5 and 50 period SMA on the primary Bars object and enters long
if (CrossAbove(SMA(5), SMA(50), 1))
EnterLong(1000, "SMA");
}
// This states below that the 5 and 15 period SMA on the 15 minute time frame but the code says 5 and 50 period SMA
//on the 15 minute time frame, minor typo, the code appears legitimate.
// Checks for a cross below condition of the 5 and 15 period SMA on the 15 minute time frame and exits long
if (CrossBelow(SMA(BarsArray[2], 5), SMA(BarsArray[2], 50), 1))
ExitLong(1000);
}

#region Properties
#endregion

See my screen shots below which highlight my confusion :

I could not get my multi time frame code to work so I decided to go back and
test the Sample Multi Frame code in NT from which I drew my inspiration.
Here a trade is fired off on 12/18 @ 6pm on the primary series ( 30 min ).
All code seems correct for the entry -
Inline image 1


// Checks if the 5 period SMA is above the 50 period SMA on both the 5 and 15 minute time frames
if (SMA(BarsArray[1], 5)[0] > SMA(BarsArray[1], 50)[0] && SMA(BarsArray[2], 5)[0] > SMA(BarsArray[2], 50)[0])

The prior code statement is validated by the next two screen shots :
5 minute - 12/18 @ 6 pm
Inline image 2


15 minute - 12/18 @ 6 pm
Inline image 3

What I am confused about is the exit.According to the following code :

// Checks for a cross below condition of the 5 and 15 ( supposed to say 50 ) period SMA on the 15 minute time frame and exits long
if (CrossBelow(SMA(BarsArray[2], 5), SMA(BarsArray[2], 50), 1))
ExitLong(1000);

This should exit when the 5 SMA crosses below the 50 SMA on the 15 minute
time frame. You can see below on the primary series chart it runs for several days.

Inline image 4


In the following screenshot the 5 SMA color has been changed to Fuschia
for clarity. You can see that the 5 SMA crosses below the 50 SMA on the
15 minute time frame at approx 5:15 am on the 19th and not the 21st as
shown on the primary series ( 30 min ). Am I misinterpreting something here
or is there another issue ?



Inline image 5

Thanks for your time and help,
Richard

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Quantum physics & Trading dynamics
The Elite Circle
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
About a successful futures trader who didnt know anythin …
Psychology and Money Management
 
  #2 (permalink)
 resirca52009 
Indianapolis, Indiana/ USA
 
Experience: Advanced
Platform: MT4, Ninjatrader
Broker: AMP / CQG
Trading: Futures
Posts: 64 since Oct 2012
Thanks Given: 112
Thanks Received: 35






Started this thread Reply With Quote




Last Updated on February 9, 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