Can't set timeframe parameter for this indicator
            
                 28 Feb 2016, 16:48
            
                    
Hi, having problems with this code.
I need to be able to select the timeframe for this indicator.
When I do reference the parameter no trades are made at all.
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None, ScalePrecision = 0)]
    [Levels(0, 10, 15, 20, 25, 30, 35, 40, 45, 50,
    55, 60, 70, 80, 90, 100, 200, 300)]
    public class PipsATRIndicator : Indicator
    {
        #region Indicator parameters
        [Parameter("Atr TimeFrame")]
        public TimeFrame AtrTimeFrame { get; set; }
        [Parameter("ATR Period", DefaultValue = 20)]
        public int AtrPeriod { get; set; }
        [Parameter("ATR MAType")]
        public MovingAverageType AtrMaType { get; set; }
        [Output("Pips ATR", Color = Colors.SteelBlue)]
        public IndicatorDataSeries Result { get; set; }
        #endregion
        private AverageTrueRange atr;
        protected override void Initialize()
        {
            atr = Indicators.AverageTrueRange(MarketData.GetSeries(AtrTimeFrame), AtrPeriod, AtrMaType);
        }
        public override void Calculate(int index)
        {
            Result[index] = atr.Result[index] / Symbol.PipSize;
        }
    }
}
When I set the following in cBot no trades are made.
[Parameter()]
        public TimeFrame AtrTimeFrame{ get; set; }
The indicator is working with the following in onstart()
pipsATR = Indicators.GetIndicator<PipsATRIndicator>(TimeFrame, AtrPeriod, AtrMaType);
But when I set it to
pipsATR = Indicators.GetIndicator<PipsATRIndicator>(AtrTimeFrame, AtrPeriod, AtrMaType);
Positions don't open.
I'm sure its simple, but I just cant seem to get it to work.
Thanks for any advice
Replies
                     ColossusFX
                     06 Mar 2016, 17:41
                                    
Thanks for the help.
It works, but optimization went from 2hrs to 12hrs!
Thanks again
@ColossusFX

croucrou
29 Feb 2016, 20:31
RE:
I think you have defined "TimeFrame" as a type of "AtrTimeFrame" and not as a value.
Default parameter seems to be the actual value. Try to set its default parameter as e.g. "TimeFrame.Hour" and see if that works.
@croucrou