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


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

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • 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.

-- Big Mike, Site Administrator

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: 772 since Apr 2010
Thanks: 2,347 given, 659 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)

Battlestations: Show us your trading desks and win $750 in prizes

August
 

Ask Me Anything (AMA) w/Rod Casilli @ Collective2

Aug 23
 

Prototyping Python Strategies (part 3, Live Trading) w/Ran Aroussi [1PM ET]

Elite only
 

Develop Strategies and Perfect Execution w/Brannigan Barrett @ Axia Futures

Elite only

Introduction to Phillip Capital futures brokerage services

Aug TBD

How Monte Carlo Analysis Can Help Your Trading w/Kevin Davey

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 11:40 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-08-23 in 0.10 seconds with 19 queries on phoenix via your IP 54.167.231.97