MC.net: (Multi-Timeframe) EMA @ Weekly Data on Daily Chart [SOLVED]
MC.net: (Multi-Timeframe) EMA @ Weekly Data on Daily Chart
QQQ @ daily
QQQ @ weekly (invisible candle)
I have created a default EMA (Mov_Avg_Exponetial) with same period on both QQQ_daily and QQQ_weekly data series
EMA_daily = CYAN
EMA_weekly = RED
I have created the same EMA using ToS. (attached image).
As you can see, the EMA_weekly_RED from ToS has a sort of "stepped line" instead of the "smoothed line" in MC. Why is that?
I think other trading platforms also generated this kind of "stepped line" when imposing higher timeframe lines onto lower timeframe chart.
Is there anyway we can make the MC's EMA to generate the same "stepped line" as in ToS?
Last edited by rc76 on 12 Jun 2021, edited 1 time in total.
- Vlada MultiCharts
- Posts: 293
- Joined: 22 Apr 2020
- Has thanked: 8 times
- Been thanked: 76 times
Re: (Multi-Timeframe) EMA @ Weekly Data on Daily Chart
Hello rc76,
You can use the code of a pre-built indicator Mov Avg 1 Line and add Data 2 in its calculation, like this:
Here is the example provided by our Engineering Team:
You can apply this indicator to Data 1.
You can use the code of a pre-built indicator Mov Avg 1 Line and add Data 2 in its calculation, like this:
Code: Select all
var0 = AverageFC( Price, Length ) data2 ;
Code: Select all
inputs: Price( Close ), Length( 9 ), Displace( 0 ) ;
variables: var0( 0 ) ;
var0 = AverageFC( Price, Length ) data2 ; //<---- Data2
condition1 = Displace >= 0 or CurrentBar > AbsValue( Displace ) ;
if condition1 then
begin
Plot1[Displace]( var0, "Avg" ) ;
if Displace <= 0 then
begin
condition1 = Price crosses over var0 ;
if condition1 then
Alert( "Price crossing over average" )
else
begin
condition1 = Price crosses under var0 ;
if condition1 then
Alert( "Price crossing under average" ) ;
end ;
end;
end ;
Re: (Multi-Timeframe) EMA @ Weekly Data on Daily Chart
Thank you so much Vlada. Apology I didn't indicate it earlier, I am using MC.net. Any chance there is a MC.net sample code can be provided by engineering team? Thank you!
Re: MC.net: (Multi-Timeframe) EMA @ Weekly Data on Daily Chart
The code I used to create Thinkscript is as follow:
Code: Select all
def EMA9_d = ExpAverage(close(period = AggregationPeriod.DAY), 9);
def EMA9_w = ExpAverage(close(period = AggregationPeriod.WEEK), 9);
plot graph_EMA9_d = EMA9_d;
graph_EMA9_d.SetDefaultColor(Color.CYAN);
graph_EMA9_d.HideBubble();
plot graph_EMA9_w = EMA9_w;
graph_EMA9_w.SetDefaultColor(Color.RED);
graph_EMA9_w.HideBubble();
- Vlada MultiCharts
- Posts: 293
- Joined: 22 Apr 2020
- Has thanked: 8 times
- Been thanked: 76 times
Re: MC.net: (Multi-Timeframe) EMA @ Weekly Data on Daily Chart [SOLVED]
Hello rc76,
You can check the basics in MultiCharts. NET FAQ.
Also I can recommend going through this thread.
Here is a modified Mov_Avg_Exponential code sample for data 2:
You can check the basics in MultiCharts. NET FAQ.
Also I can recommend going through this thread.
Here is a modified Mov_Avg_Exponential code sample for data 2:
Code: Select all
using System;
using System.Drawing;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator
{
[SameAsSymbol(true)]
public class Mov_Avg_Exponential_Data2 : IndicatorObject
{
private XAverage m_xaverage1;
private VariableSeries<Double> m_avgexp;
private IPlotObject Plot1;
public Mov_Avg_Exponential_Data2(object ctx): base(ctx)
{
length = 9;
}
private ISeries<double> price { get; set; }
[Input]
public int length { get; set; }
[Input]
public int displace { get; set; }
protected override void Create()
{
m_xaverage1 = new XAverage(this, 2);
m_avgexp = new VariableSeries<Double>(this, 0, 2);
Plot1 = AddPlot(new PlotAttributes("AvgExp", 0, Color.Blue, Color.Empty, 0, 0, true));
}
protected override void StartCalc()
{
price = BarsOfData(2).Close;// Bars.Close;
m_xaverage1.Price = price;
m_xaverage1.Length = length;
}
protected override void CalcBar()
{
m_avgexp.Value = m_xaverage1[0];
if (((displace >= 0) || Bars.CurrentBar > Math.Abs(displace)))
{
Plot1.Set(displace, m_avgexp.Value);
if ((displace <= 0))
{
if (((PublicFunctions.DoubleGreater(price[0], m_avgexp.Value) && PublicFunctions.DoubleGreater(m_avgexp.Value, m_avgexp[1])) && PublicFunctions.DoubleLessEquals(m_avgexp[1], m_avgexp[2])))
{
Alerts.Alert("Indicator turning up");
}
else{if (((PublicFunctions.DoubleLess(price[0], m_avgexp.Value) && PublicFunctions.DoubleLess(m_avgexp.Value, m_avgexp[1])) && PublicFunctions.DoubleGreaterEquals(m_avgexp[1], m_avgexp[2])))
{
Alerts.Alert("Indicator turning down");
}
}
}
}
}
}
}
- Attachments
-
- MultiCharts__Mov_Avg_Exponential Sample.png
- (68.1 KiB) Not downloaded yet