• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Compiling error - "Cannot simplicity convert type..."

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Compiling error - "Cannot simplicity convert type..."

    I have two user input properties: _smooth to smoothen moving average and MovingAverageTypeLOV enum as the different moving average types a user can select.

    I want to add logic that if _smooth = 1, then there will NO smoothing regardless of the moving average type the user selects and _avg = Input. Input comes from the Indicator's Input Series - Price Type parameter.

    This is the code that I have in State == State.DataLoaded

    Code:
    else if (State == State.DataLoaded)
    
                {
    
    
                    //Initialize class level variable including custom Series<>
    
                    _trend = new Series<bool>(this);
    
                    _avg = new Series<double>(this);
    
    
    
                    if(_smooth == 1)
    
                    {
    
                        _avg = Input;
    
                    }
    
                    else
    
                    {
    
                        switch (_maType)
    
                        {
    
                            case MovingAverageTypeLOV.SMA:
    
                                _avg = SMA(Input, _smooth).Value;
    
                                break;
    
        //                        case MovingAverageType.SMMA:                // Not available at time of Beta 5
    
        //                            _avg = SMMA(Input, _smooth).Value;
    
        //                            break;
    
                            case MovingAverageTypeLOV.TMA:
    
                                _avg = TMA(Input, _smooth).Value;
    
                                break;
    
                            case MovingAverageTypeLOV.WMA:
    
                                _avg = WMA(Input, _smooth).Value;
    
                                break;
    
                            case MovingAverageTypeLOV.VWMA:
    
                                _avg = VWMA(Input, _smooth).Value;
    
                                break;
    
                            case MovingAverageTypeLOV.TEMA:
    
                                _avg = TEMA(Input, _smooth).Value;
    
                                break;
    
                            case MovingAverageTypeLOV.HMA:
    
                                _avg = HMA(Input, _smooth).Value;
    
                                break;
    
                            case MovingAverageTypeLOV.VMA:
    
                                _avg = VMA(Input, _smooth, _smooth).Value;
    
                                break;
    
                            default:
    
                                _avg = EMA(Input, _smooth).Value;
    
                                break;
    
                        }
    
                    }
    The error that I am getting is "Cannot simplicity convert type 'NinjaTrader.ninjaScript.ISeries<double>' to 'NinjaTrader.ninjaScript.Series<double>'. An explicit conversion exists (are you missing a cast?)".

    I know that this error is do to this line:

    Code:
    _avg = Input;
    It is got to be something simple that I am not seeing. Please help.

    Thanks.
    JG

    #2
    Hello [email protected],

    Thanks for your post.

    The error would be expected due to the separate type objects.

    You would want to assign in OnBarUpdate() with

    if (smooth == 1)
    {
    _avg[0] = Input[0];
    }


    You can keep your other assignments in State.DataLoaded, just change the conditional to account for smooth > 1

    Note: A new series will be limited to a look back a maximum of 256 from the current bar. If you need a larger lookback you can define the series with MaximumBarsLookBack.Infinite.

    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bchip, Today, 09:25 AM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Tomass, Today, 09:25 AM
    2 responses
    12 views
    0 likes
    Last Post Tomass
    by Tomass
     
    Started by hundert, Today, 08:37 AM
    3 responses
    18 views
    0 likes
    Last Post NinjaTrader_Melissa  
    Started by ronaldgreene828, Today, 08:16 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_PatrickG  
    Started by hir04068, Today, 01:36 AM
    1 response
    18 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Working...
    X