Implictl convert 'Double' Error - Calc Avg - EasyLanguage Programming | futures io social trading
futures io futures trading


Implictl convert 'Double' Error - Calc Avg
Updated: Views / Replies:248 / 4
Created: by JoeyZaza Attachments:0

Welcome to futures io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.


You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Reply
 
Thread Tools Search this Thread
 

Implictl convert 'Double' Error - Calc Avg

  #1 (permalink)
Trading Apprentice
acton ma
 
Futures Experience: Intermediate
Platform: amp
Favorite Futures: emini es
 
Posts: 3 since Oct 2015
Thanks: 0 given, 0 received

Implictl convert 'Double' Error - Calc Avg

Hi Traders,

I am using Multicharts .NET64. Unfortunately or fortunately, MC.NET supports C# and VB. The .NET version does not support easy language so I am forced to use the OO construct.

I understand programming and a bit of OO, but by far not a hard core programmer (although I pretend to be one during the day).

I am having a bit of trouble with some of the errors being thrown. Looks like a type mismatch in my coding, but I just "don't get it"..

Getting error "Cannot Implicitly convert type 'DOUBLE' to PowerLanguage.ISeries<double>'...

My intent with the signal is to create an Avg of an already calculated value.

The entire code is here with the line in question highlights in RED.

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator{
public class ZJZ_OpenCloseTrend_Avg_001 : IndicatorObject {
private AverageFC m_AverageFC;

public ZJZ_OpenCloseTrend_Avg_001(object _ctx):base(_ctx)
{
// assign default values to inputs
length = 8;
}

// define the inputs
[Input]
public int length { get; set; }


private IPlotObject Open_Close_Trend;

public interface IAlert
{
bool CheckAlertLastBar { get; } // true if it is the last bar now
bool Enabled { get; } // true - if alerts are on
void Alert(); // to generate Alert with an empty text
void Alert(string Format, params object[] _args); // generate alert with message.
void Cancel(); // finish Alert generation on this bar.
}

private double SumOpenVal( int length )
{
double sumoval = 0.0;
sumoval = Bars.Open.Summation(length);
return sumoval;
}

private double SumCloseVal( int length )
{
double sumcval = 0.0;

sumcval = Bars.Close.Summation(length);
return sumcval;
}


protected override void Create() {
// create variable objects, function objects, plot objects etc.
// instantiated once
m_AverageFC = new AverageFC(this);

Open_Close_Trend = AddPlot(new PlotAttributes("OCTrend", EPlotShapes.Line, Color.Blue));

// create the ema of the trend
Open_Close_Trend = AddPlot(new PlotAttributes("AvgTrend", EPlotShapes.Line, Color.Yellow));
}
protected override void StartCalc() {
// assign inputs
}
protected override void CalcBar(){
// Avg of trend


// indicator logic
double sumopen = SumOpenVal(length);
double sumclose = SumCloseVal(length);
double trend = sumclose - sumopen;

m_AverageFC.price = trend;
m_AverageFC.length = length;
double m_avg = m_AverageFC[0];

Open_Close_Trend.Set(trend);
// dim m_trenddir string;
Open_Close_Trend.Set(m_avg);
}
}
}

TIA
JoeyZaza


Last edited by JoeyZaza; September 15th, 2016 at 10:42 PM. Reason: added missing code
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Trading Apprentice
acton ma
 
Futures Experience: Intermediate
Platform: amp
Favorite Futures: emini es
 
Posts: 3 since Oct 2015
Thanks: 0 given, 0 received


reviewing other sample codes from other indicators.. Looks like if I just eliminate the Double Type definitions, that will keep the types and assignments consistent... A bit of rework is in order..

Reply With Quote
 
  #4 (permalink)
 Vendor: tradingcode.net 
The Netherlands
 
Futures Experience: None
Platform: MultiCharts, TradingView
Favorite Futures: -
 
Jura's Avatar
 
Posts: 766 since Apr 2010
Thanks: 2,347 given, 653 received


JoeyZaza View Post
I am having a bit of trouble with some of the errors being thrown. Looks like a type mismatch in my coding, but I just "don't get it"..

Getting error "Cannot Implicitly convert type 'DOUBLE' to PowerLanguage.ISeries<double>'...

You're setting the `price` property of your `AverageFC` instance to a double value:

 
Code
double trend = sumclose - sumopen;

m_AverageFC.price = trend;
That `price` property, however, requires a series of a values to compute on, and not a single double value. This kind of makes sense when we think about what the `AverageFC` function does: computing the average from a range of different values. And to do that, it needs at least two different values to calculate the average of.

In normal English, what you're trying to do here is calculating the 8-bar average value of a single value (like 103.05, or whichever value `trend` has).

Reply With Quote
The following user says Thank You to Jura for this post:
 
  #5 (permalink)
Trading Apprentice
acton ma
 
Futures Experience: Intermediate
Platform: amp
Favorite Futures: emini es
 
Posts: 3 since Oct 2015
Thanks: 0 given, 0 received

Hi Jura,

Yes, I understand what you are saying. I am having a hard time discerning what applies to double series, etc. and the correct syntax. I have tried several permutations. As well as tried to use the same approach as the standard Mov_Avg_1_Line study. In that follows the same construct of taking multiple individual values and then average them:

....
protected override void StartCalc(){
price = Bars.Close;
m_averagefc1.price = price;
m_averagefc1.length = length;
}

protected override void CalcBar(){
m_avg.Value = m_averagefc1[0];
if (displace >= 0 || Bars.CurrentBar > Math.Abs(displace)){
Plot1.Set(displace, m_avg.Value);
if (displace <= 0){
if (this.CrossesOver(price, m_avg)){
Alerts.Alert("Price crossing over average");
}
....

Technically the Price should not care what value is given it, no? Wouldn't I be able to just pass 'trend' and 'length' to m_averagefc1.price and m_averagefc1.length respectively. Or just assign 'trend' to m_avg.Value...

Reply With Quote

Reply



futures io > > > > > Implictl convert 'Double' Error - Calc Avg

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

FIO Journal Challenge featuring NinjaTrader ($2,000+ of prizes)

May
 

An overview of volumetric analytical tools w/Artem Topol @ PTMC

Elite only
 

Finding Success in Futures Trading w/John Hoagland

Jun 6
 

FuturesTrader71 Extended Ask Me Anything (AMA)

Elite only
 

Diving Into Order Flow w/Alex Haywood & Jigsaw Trading

Jun 8

John @ No BS Day Trading (TBA)

Elite only

An Afternoon with FIO member Softsoap (being rescheduled)

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Double top/Double bottom intraday in YM market AJAdio Emini Index Futures Trading 2 November 24th, 2014 08:22 PM
Convert String to double westsider NinjaTrader Programming 5 December 6th, 2013 02:01 AM
Double stop results error fineyfam Elite Automated Trading 1 December 20th, 2012 11:19 AM
Double Top / Double Bottom indicator for Multicharts / Tradestation, one available? PositiveDeviant MultiCharts 12 February 15th, 2012 01:10 AM
Double bottom and Double top with DIV benbrooke NinjaTrader Programming 36 December 6th, 2011 12:29 PM


All times are GMT -4. The time now is 03:39 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-05-30 in 0.10 seconds with 19 queries on phoenix via your IP 54.162.168.187