convert eld to MC.Net

Questions about MultiCharts .NET and user contributed studies.
O66
Posts: 146
Joined: 28 Nov 2006
Location: Netherlands
Has thanked: 2 times
Been thanked: 3 times

convert eld to MC.Net

Postby O66 » 29 Jul 2016

Hi,

I have 2 indicators that i like to convert to MC.net c#
Unfortunately i don't have programming skills.

Not sure how much work it is. Is there anyone that can help?

Thanks!

Indicator 1:

{
***** Study name: 'EFV Stoch3x'
}
{ ***** DLLs Section ***** }
{ ***** INPUTs Section *****}
INputs: PriceH(HIGH), PriceL(LOW), PriceC(CLOSE), SmoothingType(2.0);
{ ***** VARs Section ***** }
VAriables: Var1(0.0), Var2(0.0), Var3(0.0), Var4(0.0);
VAriables: Var5(0.0), Var6(0.0), Var7(0.0), Var8(0.0);
VAriables: Var9(21.0), Var10(9.0), Var11(18.0), Var12(0.0);
{ ***** ARRAYs Section *****}
{ ***** CODE Section ***** }
#EVENTS OnDestroy = EasyLanguageRtlOnDestroy ;
#END ;
Var12 = Stochastic (PriceH, PriceL, PriceC, Var9, Var10, Var11, SmoothingType, Var1, Var2, Var3, Var4) ;
PLOT1 (Var4, "SlowDa") ;
if Var4 < Var4[1.0] then SETPLOTCOLOR (1.0, 1.67117e+07) ;
{
*
}

Indicator 2:

{
***** Study name: 'EFV Stoch'
}
{ ***** DLLs Section ***** }
{ ***** INPUTs Section *****}
INputs: PriceH(HIGH), PriceL(LOW), PriceC(CLOSE);
{ ***** VARs Section ***** }
VAriables: Var1(0.0), Var2(0.0), Var3(0.0), Var4(0.0);
VAriables: Var5(0.0), Var6(0.0), Var7(0.0), Var8(0.0);
VAriables: Var9(7.0), Var10(3.0), Var11(3.0), Var12(21.0);
VAriables: Var13(10.0), Var14(4.0), Var15(2.0);
VAriables: Var16(20.0), Var17(80.0), Var18(0.0);
VAriables: Var19(0.0);
{ ***** ARRAYs Section *****}
{ ***** CODE Section ***** }
#EVENTS OnDestroy = EasyLanguageRtlOnDestroy ;
#END ;
Var18 = Stochastic (PriceH, PriceL, PriceC, Var9, Var10, Var11, Var15, Var1, Var2, Var3, Var4) ;
Var19 = Stochastic (PriceH, PriceL, PriceC, Var12, Var13, Var14, Var15, Var5, Var6, Var7, Var8) ;
PLOT1 (Var4, "SlowDa") ;
PLOT2 (Var8, "SlowDb") ;
PLOT3 (Var17, "OverBot") ;
PLOT4 (Var16, "OverSld") ;
if Var4 < Var4[1.0] then SETPLOTCOLOR (1.0, red) ;
if Var8 < Var8[1.0] then SETPLOTCOLOR (2.0, blue) ;
{
*
}

eroleyikan
Posts: 22
Joined: 01 Jun 2016
Has thanked: 4 times
Been thanked: 6 times

Re: convert eld to MC.Net

Postby eroleyikan » 03 Aug 2016

Hi,
I would suggest with an existing Stochastic indicator and modify it based on your needs.
Below is an example code. It is not doing what your indicators were doing but I think it would be good starting point for you to understand how the .net version works.
I hope this helps.

Code: Select all

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

namespace PowerLanguage.Indicator
{
public class Stochastic_Slow : IndicatorObject
{
private Stochastic m_stochastic1;

private VariableSeries<Double> m_ofastk;

private VariableSeries<Double> m_ofastd;

private VariableSeries<Double> m_oslowk;

private VariableSeries<Double> m_oslowd;

private IPlotObject Plot1;

private IPlotObject Plot2;

private IPlotObject Plot3;

private IPlotObject Plot4;

public Stochastic_Slow(object ctx) :
base(ctx){
overbought = 80;
oversold = 20;
smoothingtype = 1;
smoothinglength2 = 3;
smoothinglength1 = 3;
stochlength = 14;
}

private ISeries<double> priceh { get; set; }

private ISeries<double> pricel { get; set; }

private ISeries<double> pricec { get; set; }

[Input]
public int stochlength { get; set; }

[Input]
public int smoothinglength1 { get; set; }

[Input]
public int smoothinglength2 { get; set; }

[Input]
public int smoothingtype { get; set; }

[Input]
public double oversold { get; set; }

[Input]
public double overbought { get; set; }

protected override void Create(){
m_stochastic1 = new Stochastic(this);
m_ofastk = new VariableSeries<Double>(this);
m_ofastd = new VariableSeries<Double>(this);
m_oslowk = new VariableSeries<Double>(this);
m_oslowd = new VariableSeries<Double>(this);
Plot1 =
AddPlot(new PlotAttributes("SlowK", 0, Color.Yellow,
Color.Empty, 0, 0, true));
Plot2 =
AddPlot(new PlotAttributes("SlowD", 0, Color.Blue,
Color.Empty, 0, 0, true));
Plot3 =
AddPlot(new PlotAttributes("OverBot", 0, Color.Green,
Color.Empty, 0, 0, true));
Plot4 =
AddPlot(new PlotAttributes("OverSld", 0, Color.Green,
Color.Empty, 0, 0, true));
}

protected override void StartCalc(){
priceh = Bars.High;
pricel = Bars.Low;
pricec = Bars.Close;
m_stochastic1.priceh = priceh;
m_stochastic1.pricel = pricel;
m_stochastic1.pricec = pricec;
m_stochastic1.stochlength = stochlength;
m_stochastic1.length1 = smoothinglength1;
m_stochastic1.length2 = smoothinglength2;
m_stochastic1.smoothingtype = smoothingtype;
m_stochastic1.ofastk = m_ofastk;
m_stochastic1.ofastd = m_ofastd;
m_stochastic1.oslowk = m_oslowk;
m_stochastic1.oslowd = m_oslowd;
}


protected override void CalcBar(){
m_stochastic1.Call();
Plot1.Set(0, m_oslowk.Value);
Plot2.Set(0, m_oslowd.Value);
Plot3.Set(0, overbought);
Plot4.Set(0, oversold);
if (Bars.CurrentBar > 2){
if ((this.CrossesOver(m_oslowk, m_oslowd) &&
PublicFunctions.DoubleLess(m_oslowk.Value, oversold))){
Alerts.Alert("SlowK crossing over SlowD");
}
else{
if ((this.CrossesUnder(m_oslowk, m_oslowd) &&
PublicFunctions.DoubleGreater(m_oslowk.Value, overbought))){
Alerts.Alert("SlowK crossing under SlowD");
}
}
}
}
}
}


Return to “MultiCharts .NET”