NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > Application Technical Support > Miscellaneous Support > Historical Version 7 Beta Threads > Version 7 Beta General Questions & Bug Reports

Version 7 Beta General Questions & Bug Reports Ask questions here and post bug reports.

 
 
Thread Tools Display Modes
Old 06-27-2010, 10:29 PM   #1
MXASJ
Senior Member
 
Join Date: May 2009
Location: Asia
Posts: 304
Thanks: 0
Thanked 9 times in 5 posts
Default Strategy COBC=false, Indicator COBC=true?

Hi Ninja Team,

This is probably a simple thing but has me scratching my head. I have a simple MA cross strategy with an entry and trail stop running on five min bars, CalculateOnBarClose = false so that it enters and trails on every tick.

The thing is I want the indicators (the MAs) to be CalculateOnBarClose=true.

I've tried Add(PeriodType.Tick, 1) with the Strategy COBC set to true, then moved the SetStopLoss() logic from Initialize() to OnBarUpdate like this;

...OnBarUpdate()
if(BarsInProgress ==1)// 1 tick series
{
SetTrailStop(etc etc);
}

DoSomethingElse at close of bar;

But that still seems to only fire at close of bar.

Am I missing something simple?

Thanks!
MXASJ is offline  
Old 06-28-2010, 02:49 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

Quote:
Originally Posted by MXASJ View Post
Hi Ninja Team,

This is probably a simple thing but has me scratching my head. I have a simple MA cross strategy with an entry and trail stop running on five min bars, CalculateOnBarClose = false so that it enters and trails on every tick.

The thing is I want the indicators (the MAs) to be CalculateOnBarClose=true.

I've tried Add(PeriodType.Tick, 1) with the Strategy COBC set to true, then moved the SetStopLoss() logic from Initialize() to OnBarUpdate like this;

...OnBarUpdate()
if(BarsInProgress ==1)// 1 tick series
{
SetTrailStop(etc etc);
}

DoSomethingElse at close of bar;

But that still seems to only fire at close of bar.

Am I missing something simple?

Thanks!
Hi MXASJ, did you already check into this sample here?

http://www.ninjatrader.com/support/f...ad.php?t=19387

This would allow you to combine OnBarClose and OnEachTick calcs in the strategy using one frame only.
NinjaTrader_Bertrand is offline  
Old 06-28-2010, 05:35 AM   #3
MXASJ
Senior Member
 
Join Date: May 2009
Location: Asia
Posts: 304
Thanks: 0
Thanked 9 times in 5 posts
Default

Forgot about that one!

In the mean time, adding a line to reset my trail stops when flat seems to have solved my issue.

In OnBarUpdate() before the trade logic:

PHP Code:
if (BarsInProgress == || Position.MarketPosition == MarketPosition.Flat
{
if(
useTrailStopSetTrailStop(CalculationMode.TicksStopLoss);

MXASJ is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strategy.CalculateOnBarClose=true vs. Indicator.CalculateOnBarClose=false karimatka Strategy Development 7 05-23-2011 03:39 AM
CalculateOnBarClose = false\true nkonkov Strategy Development 3 06-17-2010 03:28 AM
CalculateOnBarClose=true; but then false stephenszpak Strategy Development 1 01-02-2010 01:42 AM
Statements if/true/false skikg General Programming 2 12-09-2009 01:45 PM
Simulation, true or false? RVRoman General Programming 1 09-02-2008 02:34 AM


All times are GMT -6. The time now is 08:59 AM.