PDA

View Full Version : Barsince and valuewhen function


zoltran
04-03-2007, 06:00 PM
Amibroker has a nice 'BarsSince' function that returns the number of 'Bars Since' an event was true.
What would be a way of doing this in Ninjascript?

For example, the number of bars since macd was over 0 etc. ?

NinjaTrader_Dierk
04-03-2007, 09:53 PM
I'm not familiar with AmiBroker but likely there is no direct equivalent.

However, you always could go back in any time series an inspect conditions X bars ago, something like:
if (CurrentBar < X) // make sure you have X bars or more
return;

if (SMA(14)[X] > Close[X]) // SMA above Close X bars ago
// trigger your action

zoltran
04-04-2007, 01:13 AM
Thanks !

And when do you sleep ? ;-)

NinjaTrader_Ray
04-04-2007, 01:23 AM
One of the great things about our company is that we are spread across the globe. Primary development is in Bamberg, Germany while headquarters is in Denver, CO. That way we are able to provide excellent levels of service across two major time zones.

Ray