MultiTimeFrame getting wierd backtest results - futures io
futures io



MultiTimeFrame getting wierd backtest results


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one rymonroe with 3 posts (0 thanks)
    2. looks_two vvhg with 1 posts (0 thanks)
    3. looks_3 kconradbell with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 1,139 views
    2. thumb_up 0 thanks given
    3. group 5 followers
    1. forum 5 posts
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

MultiTimeFrame getting wierd backtest results

(login for full post details)
  #1 (permalink)
 rymonroe 
Los Angeles, CA
 
Experience: Beginner
Platform: NT
Trading: ES, ZN
 
rymonroe's Avatar
 
Posts: 15 since Nov 2012
Thanks: 5 given, 4 received

I am creating a multi time-frame strategy with four time frames and two indicators
 
Code
                        Add(PeriodType.Minute,15);
			Add(PeriodType.Minute,30);
			Add(PeriodType.Minute,60);
			Add(PeriodType.Day, 1);
			Add(LongIndicator());
			Add(ShortIndicator);
In the onBarUpdate, I check for the primary bars (barsinprogress==0 return) and ignore it. When I backtest in 1 min ticks, I only get long trades. When I switch to 15 min, I get both. My questions is, are there 4 instances of each indicator running (5 if you count primary bars) when my strategy is active? I'm missing something but I just don't know what it is?

[NOTE]The Long and Short Indicators are not optimized in any way for multi-time frames. They were meant to be run in one time frame[/NOTE]

Started this thread Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(82 thanks from 10 posts)
looks_twoDeetee’s DAX Trading Journal (time based)by Deetee
(25 thanks from 9 posts)
looks_3Salao's Journalby Salao
(23 thanks from 6 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(12 thanks from 7 posts)
looks_5Maybe a little bit different journalby Malykubo
(3 thanks from 2 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
futures io site changelog and issues/problem reporting
73 thanks
The Crude Dude Oil Trading System
73 thanks
Would You Sell Your System?
71 thanks
FIO Journal Challenge - April 2021 w/Jigsaw Trading
32 thanks
Big Mike in Ecuador
25 thanks
 
(login for full post details)
  #3 (permalink)
 vvhg 
Northern Germany
 
Experience: Intermediate
Platform: NT
Trading: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,816 received



rymonroe View Post
I am creating a multi time-frame strategy with four time frames and two indicators
 
Code
                        Add(PeriodType.Minute,15);
			Add(PeriodType.Minute,30);
			Add(PeriodType.Minute,60);
			Add(PeriodType.Day, 1);
			Add(LongIndicator());
			Add(ShortIndicator);
In the onBarUpdate, I check for the primary bars (barsinprogress==0 return) and ignore it. When I backtest in 1 min ticks, I only get long trades. When I switch to 15 min, I get both. My questions is, are there 4 instances of each indicator running (5 if you count primary bars) when my strategy is active? I'm missing something but I just don't know what it is?

[NOTE]The Long and Short Indicators are not optimized in any way for multi-time frames. They were meant to be run in one time frame[/NOTE]

There will only be one instance, this method of adding indicators will just display them on the chart afaik.

vvhg

Hic Rhodos, hic salta.
Reply With Quote
 
(login for full post details)
  #4 (permalink)
 rymonroe 
Los Angeles, CA
 
Experience: Beginner
Platform: NT
Trading: ES, ZN
 
rymonroe's Avatar
 
Posts: 15 since Nov 2012
Thanks: 5 given, 4 received


vvhg View Post
There will only be one instance, this method of adding indicators will just display them on the chart afaik.

vvhg

I don't think this is the case because when I call

 
Code
LongIndicator().BarsPeriod.Value
I get different results depending on what BarsInProgress is.

Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
 rymonroe 
Los Angeles, CA
 
Experience: Beginner
Platform: NT
Trading: ES, ZN
 
rymonroe's Avatar
 
Posts: 15 since Nov 2012
Thanks: 5 given, 4 received

I have found and solved the problem. I was setting avariable in the Short indicator, as seen below...

 
Code
                        Add(PeriodType.Minute,15);
			Add(PeriodType.Minute,30);
			Add(PeriodType.Minute,60);
			Add(PeriodType.Day, 1);
			Add(LongIndicator());
			Add(ShortIndicator());

                        ShortIndicator().shortVal = true;

From what I gather by debugging it, there were 5 instances of LongIndicator and 5 instances of ShortIndicator running in my strategy at any given time. The code you see above is from the Initialize method method and it turns out that I was changing the value of shortVal in only the primary bars (which is what called the Initialize method) and not the 15/30/60/day bars. This was causing my unexpected results and once I changed the default value of shortVal to true, everything worked fine.

Started this thread Reply With Quote
 
(login for full post details)
  #6 (permalink)
kconradbell
Dallas Texas United States
 
 
Posts: 5 since Apr 2014
Thanks: 1 given, 0 received

Clearly I'm screwing something up. The code below works partially. It appears to do everything except account for the EMA positions on the primary bars [0]. EMA 21 > EMA 34 for example.

It also freaks out and floods with placing and cancelling orders when I change the EnterLong or EnterShort to a limit order. The limit order is to be placed at the 13 MA, if that makes any difference.

/// <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(PeriodType.Tick, 2584);
Add(PeriodType.Second, 30);
Add(Swing(SwingStrength));

CalculateOnBarClose = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired)
return;
if(BarsInProgress !=0)
return;
if (EMA(BarsArray[1],8)[0] > EMA(BarsArray[1],13)[0] + 1 * TickSize && Stochastics(BarsArray[2],7, 23, 2).K[0] < 80)
{
if (EMA(21)[0] > EMA(34)[0]
&& ToTime(Time[0]) >= ToTime(7, 00, 0)
&& ToTime(Time[0]) < ToTime(15, 00, 0)
&& Close[0] > Swing(SwingStrength).SwingHigh[0] + 3 * TickSize)
EnterLong(OrderQty, "MA1");
DrawTriangleUp("My triangle up" + CurrentBar, false, 0, EMA(13)[0], Color.Green);
}

if(EMA(BarsArray[1],8)[0] < EMA(BarsArray[1],13)[0] + -1 * TickSize && Stochastics(BarsArray[2],7, 23, 2).K[0] > 20)
{
if (EMA(21)[0] < EMA(34)[0]
&& ToTime(Time[0]) >= ToTime(7, 00, 0)
&& ToTime(Time[0]) < ToTime(15, 00, 0)
&& Close[0] < Swing(SwingStrength).SwingLow[0] + -3 * TickSize);
EnterShort(OrderQty, "MA1");
DrawTriangleDown("My triangle down" + CurrentBar, false, 0, EMA(13)[0], Color.Crimson);
}

The flood of cancels also occurs when I attempt to add more exit and entry commands below the preceding script.

if (Position.MarketPosition == MarketPosition.Long
&& CrossBelow(Stochastics(BarsArray[2],7, 23, 2).K, 21, 1))
{
DrawTriangleUp("My triangle up" + CurrentBar, false, 0, Low[0] + -1 * TickSize, Color.Lime);
EnterLong(OrderQty, "O1");

Thank you in advance for any help.

Conrad
Skype: kconradbell

Attached Thumbnails
Click image for larger version

Name:	NinjaScriptCapture.PNG
Views:	37
Size:	38.9 KB
ID:	160818  
Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > MultiTimeFrame getting wierd backtest results


Last Updated on October 9, 2014


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April
 

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts