NexusFi: Find Your Edge


Home Menu

 





Strategy Indicator Communication / Market Replay


Discussion in NinjaTrader

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




 
Search this Thread

Strategy Indicator Communication / Market Replay

  #1 (permalink)
 
rymonroe's Avatar
 rymonroe 
Los Angeles, CA
 
Experience: Beginner
Platform: NT
Trading: ES, ZN
Posts: 15 since Nov 2012
Thanks Given: 5
Thanks Received: 4

I have a muli time frame strategy that communicates with an indicator. When I back test it, it communicates with the indicator just fine executes trades as expected. I just tried using the Market Replay feature and I am getting some unexpected results. I was wondering if someone could take a look at my code to see if this is the correct way of implementing the communication between strategy and Indicator or if anyone has had trouble testing there strategy with market replay.


In Indicators (both are similar)
 
Code
private BoolSeries bullIndication;
...
bullIndication= new BoolSeries(this);
...
[Browsable(false)]
 [XmlIgnore()]
 public BoolSeries BullIndication
 {
      get { return bullIndication; }
  }
...
if (goLong()) bullIndication.Set(true);

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

...
if (LongIndicator().BullIndication[0] && !strategyHalt) EnterLongTrade();
if (ShortIndicator().BearIndication[0] && !strategyHalt) EnterLongTrade();

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 
MrYou's Avatar
 MrYou 
NC, USA
 
Experience: None
Platform: None Yet
Trading: Guitar
Posts: 403 since Jun 2011
Thanks Given: 618
Thanks Received: 196


First off just so you're aware, the first two Add(Indicator()) statements are only needed if you want the [visual] indicator to be displayed on the performance results chart.

But your odd behavior is possibly because your if conditions are being applied to each time frame instead of one.

Meaning you'll want to do something like this:
 
Code
if (BarsInProgress != 0)
   return;
BarsInProgress == 0 or BarsArray[0] is the primary time frame which is set from the NT GUI. You would reference those other time frames individually using BarsArray[] "from within" this primary time frame if using the code above or you would need to reference them using BarsInProgress/BarsArray.

Its been suggested to set your trade execution time frame to 1 second for backtesting purposes or a minimum of 1 minute if you only have minute data and not tick data.

Hopefully this makes sense, its late.

Reply With Quote
  #4 (permalink)
 
rymonroe's Avatar
 rymonroe 
Los Angeles, CA
 
Experience: Beginner
Platform: NT
Trading: ES, ZN
Posts: 15 since Nov 2012
Thanks Given: 5
Thanks Received: 4

Thanks for the reply MrYou. I am currently checking for BarsInProgress including returning on BarsInProgress==0. The problem I am seeing is at around 5:30am on the ES, I should be getting a buy signal from my indicators and go long. When I backtest, this is what happens. When I use market replay, I get a short signal and I go short. This is very confusing and frustrating for me. My only conclusion is that there is something wrong with Market Replay as my code I believe is sound.

Started this thread Reply With Quote




Last Updated on January 30, 2013


© 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