NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 06-04-2009, 07:42 PM   #1
un$ane
Member
 
Join Date: Oct 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default CrossAbove Close & Close[0] different results

Anyone know why these expressions would evaluate differently?

CrossAbove(Close[0], EMA(m_FastPeriod), 1): False
CrossAbove(Close, EMA(m_FastPeriod), 1): True
6/4/2009 6:39:01 PM
Last edited by un$ane; 06-04-2009 at 08:47 PM.
un$ane is offline  
Reply With Quote
Old 06-05-2009, 06:26 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

Welcome to our forums, please check this link and try reversing the order when you compare a double and a dataseries in the CrossAbove / CrossBelow - http://www.ninjatrader-support.com/H...rossAbove.html
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-05-2009, 09:07 AM   #3
un$ane
Member
 
Join Date: Oct 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default

Does that mean this method is invalid?

public bool CrossAbove(double value, IDataSeries series2, int lookBackPeriod);

I can't seem to get either one of these to evaluate to True:
CrossAbove(EMA(m_FastPeriod), Close[0], 1);
CrossAbove(Close[0], EMA(m_FastPeriod), 1);

In my strategy I'm using:
CalculateOnBarClose = true;
if (BarsInProgress == 0 && FirstTickOfBar)

Thanks for the reply.
Last edited by un$ane; 06-05-2009 at 09:22 AM.
un$ane is offline  
Reply With Quote
Old 06-05-2009, 09:39 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

Please try using then and see if this evaluates to 'true' -

Code:
CrossAbove(Close, EMA(m_FastPeriod), 1);
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-05-2009, 09:44 AM   #5
un$ane
Member
 
Join Date: Oct 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default

It does...But I'm curious why the others don't. I'm now questioning my understanding of the concept and/or whether there's a bug.
un$ane is offline  
Reply With Quote
Old 06-05-2009, 09:54 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

If you submit a double, it has no history of values to compare so it would never cross.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-05-2009, 09:59 AM   #7
un$ane
Member
 
Join Date: Oct 2008
Posts: 68
Thanks: 0
Thanked 0 times in 0 posts
Default

oh...That makes sense!

Kinda weird why those methods exist, but at least I can sleep better tonight

Thxs Bertrand.
un$ane is offline  
Reply With Quote
Reply

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
Calculate On Bar Close - Unexpected Results r2kTrader Strategy Development 13 02-22-2011 11:03 AM
Sounds & position close w/strategy on nicknamed Suggestions And Feedback 2 05-20-2009 06:03 AM
Enter at Close, Exit next day Close tjendra Strategy Development 3 04-08-2009 11:33 AM
Why is Market Analyzer not even close to realized results? bluelou Market Analyzer 2 03-24-2009 08:09 AM
Charting high/low/close and open/close widths gluebunny Charting 11 09-29-2008 10:47 AM


All times are GMT -6. The time now is 09:27 PM.