i would like to calculate daily ATR in the strategy. I'm using the strategy for 60 min chart and I would like to calculate daily ATR.
Any help would be appreciated.
Thanks
{
#region Variables
// Wizard generated variables
private int fast = 20; // Default setting for Fast
private int slow = 55; // Default setting for Slow
private int indicator = 70; // Default setting for Indicator
private int stop = 150; // Default setting for Stop
private int atr = 20; // Default setting for Atr
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
SetStopLoss("LONG", CalculationMode.Ticks, Stop, false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(SMA(Fast), SMA(Slow), 1)
&& ATR(14)[0] < Atr)
{
EnterLong(DefaultQuantity, "LONG");
}
// Condition set 2
if (RSI(14, 3).Avg[0] > Indicator)
{
ExitLong("ExitLong", "LONG");
}
}

Comment