Optimization

#1
I need to optimize this afl but when i am doing so it is showing 'You Haven't specified any variables for optimization'.


_SECTION_BEGIN("WMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( WMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

Buy=Cross(C, WMA(Close, 15));
Sell=Cross(WMA(Close, 15), C);

AlertIf( Buy, "", "Buy", 1 );
AlertIf( Sell, "", "Sell", 2 );

short=sell;
cover=buy;

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorBlue, 0,Low, Offset=-20);
PlotShapes(IIf(Sell==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-20);
 

manojborle

Well-Known Member
#2
I need to optimize this afl but when i am doing so it is showing 'You Haven't specified any variables for optimization'.


_SECTION_BEGIN("WMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( WMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

Buy=Cross(C, WMA(Close, 15));
Sell=Cross(WMA(Close, 15), C);

AlertIf( Buy, "", "Buy", 1 );
AlertIf( Sell, "", "Sell", 2 );

short=sell;
cover=buy;

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorBlue, 0,Low, Offset=-20);
PlotShapes(IIf(Sell==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-20);
You haven't specified any optimize function...
In your buy condition, the average mentioned is 15 which should be variable.
 

mcxinvest

Well-Known Member
#3
Try this :

_SECTION_BEGIN("WMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Per = Optimize("Per",15,2,300,1);
Plot( WMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

Buy=Cross(C, WMA(Close, Periods));
Sell=Cross(WMA(Close, Periods), C);

AlertIf( Buy, "", "Buy", 1 );
AlertIf( Sell, "", "Sell", 2 );

short=sell;
cover=buy;

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorBlue, 0,Low, Offset=-20);
PlotShapes(IIf(Sell==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-20);
 

amanfree

Active Member
#5
_SECTION_BEGIN("WMA");
P = ParamField("Price field",-1);
Periods = Optimize("Periods", 15, 2, 300, 1);
Per = Optimize("Per",15,2,300,1);
Plot( WMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

Buy=Cross(C, WMA(Close, Periods));
Sell=Cross(WMA(Close, Periods), C);

AlertIf( Buy, "", "Buy", 1 );
AlertIf( Sell, "", "Sell", 2 );

Short=Sell;
Cover=Buy;

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorBlue, 0,Low, Offset=-20);
PlotShapes(IIf(Sell==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-20);
 

mcxinvest

Well-Known Member
#6
_SECTION_BEGIN("WMA");
P = ParamField("Price field",-1);
Periods = Optimize("Periods", 15, 2, 300, 1);
Per = Optimize("Per",15,2,300,1);
Plot( WMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

Buy=Cross(C, WMA(Close, Periods));
Sell=Cross(WMA(Close, Periods), C);

AlertIf( Buy, "", "Buy", 1 );
AlertIf( Sell, "", "Sell", 2 );

Short=Sell;
Cover=Buy;

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorBlue, 0,Low, Offset=-20);
PlotShapes(IIf(Sell==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-20);
Bro,
I cannot see any changes in the AFL which i provided, with yours. Did you just copy/pasted ????
 

amanfree

Active Member
#8
_SECTION_BEGIN("WMA");
P = ParamField("Price field",-1);
Periods = Optimize("Periods", 15, 2, 300, 1);
Per = Optimize("Per",15,2,300,1);
Plot( WMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

Buy=Cross(C, WMA(Close, Periods));
Sell=Cross(WMA(Close, Periods), C);

AlertIf( Buy, "", "Buy", 1 );
AlertIf( Sell, "", "Sell", 2 );

Short=Sell;
Cover=Buy;

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorBlue, 0,Low, Offset=-20);
PlotShapes(IIf(Sell==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-20);
Bro,
I cannot see any changes in the AFL which i provided, with yours. Did you just copy/pasted ????
just use function optimize instead of param. Have u tried to run it or just glanced through the code?
 

Similar threads