Profile Picture

How to choose ATR parameter dynamically at runtime through an exposed method.

Posted By ChiTrader2000 9 Years Ago

How to choose ATR parameter dynamically at runtime through an exposed...

Posted Sunday May 31 2009

I am creating a backtesting system based on RightEdge that exposes RightEdge functionality via a very simple API that also hooks into our other IT systems.  I previously accomplished this with Ninja Trader, but am trying to duplicate the backtesting system with RightEdge.

In the NewBar() event of a Trading System, is traders need a simple C# method that they can call, with the ATR parameter of their choice, to determine of a price they pass to my custom method is "X ATRs Worse" from their passed price, like this:

double tradersChosenATRParameter1 = 10;

double tradersChosenATRParameter2 = (a number that the trader will chose when they develop their trading system...);

if(IsXATRsWorse(tradersCalculatedPrice, tradersChosenATRParameter1))


else if(IsXATRsWorse(tradersCalculatedPrice, tradersChosenATRParameter2))


In the indicator samples that I am finding, it looks like the trading system developer needs to decide at design time what the ATR parameter will be, but I need to allow the traders to call my "IsXATRsWorse()" method with many possible parameters in the same trading system. 

In Ninja Trader, the trading system developer could at any time ask for ATR(12), ATR(14), etc... without having to choose 12 and 14 at design time.  Is this possible in RightEdge?



Posted Monday June 01 2009
It is not possible in RightEdge without some extra work, however I think you will be able to get what you want. In RightEdge, the indicators you are going to use need to be created and initialized during system startup. The reason to do it this way instead of calculating indicators on the fly is that some indicators (such as the exponential moving average) depend on the entire history of their input series to calculate a value. We don't want to have to go back and redo all this calculation each bar when the system asks for the current value. Instead the indicators can calculate the value incrementally each time there is a new bar.

To achieve what you want, there are a few options:

1. Have the systems using your framework declare which ATR values they will use during startup (by calling a method on the base class most likely), and then create an ATR indicator for each of these values. It would be an error for them to request an ATR length that they hadn't specified in the startup.

2. Create ATRs for each possible length that may be requested during startup. This isn't a very attractive option because if the length could be between 1 and 100 bars you would have 100 ATR indicators being calculated even if you were only using 1 or 2.

3. Implement the ATR calculation yourself instead of using the ATR indicator that comes with RightEdge. Simply calculate the value on demand. Since the ATR formula is pretty simple, this may actually be the best choice. If you want to support more complex indicators, you may want to go with option 4.

4. Create ATR indicators on demand when asked, and call the NewBar/AppendBar method on them yourself as appropriate. Let me know if you are interested in this and I will explain how it would work in more detail.

Posted Monday June 08 2009

These are some pretty good options.

Thanks for giving me so many possibilities.


Posted Friday June 12 2009

could you please elaborate on your 4th point? I am also working on a better way to calculate and update my own indicators and I would like to know whether better ways exist vs what I am currently doing.


Similar Topics

Reading This Topic

2005-2018 © RightEdge Systems