tradepunt
please try the following
_SECTION_BEGIN("MTF MA");
SetChartOptions(2,chartShowDates);
GraphXSpace=5;
Plot(C,"",1,64);
PP = 0;
WDH = ParamList("TF", "Hourly,Daily,Weekly" );
if( WDH == "Daily" ) PP= inDaily;
if( WDH == "Weekly" ) PP= inWeekly;
if( WDH == "Hourly" ) PP= inHourly;
TimeFrameSet(PP);
P=ParamField("Price");
Per=Param("MA Period",20,1,200,1);
x=MA(P,Per);
TimeFrameRestore();
aa=TimeFrameExpand(x,PP);
Plot(aa,"",colorBlue,styleThick);
_SECTION_END();
Vidyasagar
please try the following
_SECTION_BEGIN("MTF MA");
SetChartOptions(2,chartShowDates);
GraphXSpace=5;
Plot(C,"",1,64);
PP = 0;
WDH = ParamList("TF", "Hourly,Daily,Weekly" );
if( WDH == "Daily" ) PP= inDaily;
if( WDH == "Weekly" ) PP= inWeekly;
if( WDH == "Hourly" ) PP= inHourly;
TimeFrameSet(PP);
P=ParamField("Price");
Per=Param("MA Period",20,1,200,1);
x=MA(P,Per);
TimeFrameRestore();
aa=TimeFrameExpand(x,PP);
Plot(aa,"",colorBlue,styleThick);
_SECTION_END();
Vidyasagar
The code is working for all 3 time frames :thumb:
Adding different MA types and Displacement parameters
Code:
_SECTION_BEGIN("MTF MA");
SetChartOptions(2,chartShowDates);
GraphXSpace=5;
Plot(C,"",1,64);
PP = 0;
WDH = ParamList("TF", "Hourly,Daily,Weekly" );
if( WDH == "Daily" ) PP= inDaily;
if( WDH == "Weekly" ) PP= inWeekly;
if( WDH == "Hourly" ) PP= inHourly;
P = ParamField("Field");
Type = ParamList("Type", "Simple,Exponential,Double Exponential,Tripple Exponential,Wilders,Weighted");
Periods = Param("Periods", 20, 2, 300 );
Displacement = Param("Displacement", 0, -50, 50 );
m = 0;
TimeFrameSet(PP);
if( Type == "Simple" ) m = MA( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Weighted" ) m = WMA( P, Periods );
TimeFrameRestore();
aa=TimeFrameExpand(m,PP);
Plot(aa, _DEFAULT_NAME(), ParamColor("Color", ColorCycle), ParamStyle("Style"), 0, 0, Displacement );
_SECTION_END();
Last edited: