[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] FirstParamAttempt



PureBytes Links

Trading Reference Links

Although it's probably okay, I wouldn't put an assignment statement inside a plot function as you have done with:

Plot( ad = ADX(range5), ...

The purpose of the Param() statement is to allow the user control over the value of the parameter from the parameter window (right click on the chart, choose Parameters). You have correctly coded the param statement. What's happening is that you are assigning the ADX to the variable ad and plotting it. Then you reassign the ADX to the same variable a second time and plot it again. Thus your second group of plots is overriding the first group and your second group is set to a period of 14.

If you remove the ad = portion as I suggested above, then BOTH forms will plot.

However, what I think you really want is simply the standard function with no changes whatsoever since it already includes the Param statement. Just change the value in the Parameters box!

Terry

Code from standard AB function:

_SECTION_BEGIN("ADX");
range = Param("Periods", 14, 2, 200, 1 );
Plot( ADX(range), _DEFAULT_NAME(), ParamColor( "ADX color", colorBlue ), ParamStyle("ADX style", styleThick ) );
Plot( PDI(range), "+DI", ParamColor( "+DI color", colorGreen ), ParamStyle("+DI style") );
Plot( MDI(range), "-DI", ParamColor( "-DI color", colorRed ), ParamStyle("-DI style") );
_SECTION_END();


mrdavis9 wrote:

This is my first attempt to use Param.  

I made a custom version of the builtin ADX indicator. 

I left the built-in range set at 14, but I changed it from "range" to "range14". 

range14 = Param("Periods", 14, 2, 200, 1 );

 

I then made a second set of three ADX plot statements and designated the range to be  

range5 = Param("Periods", 5, 2, 200, 1 );

I then made the other apparently needed changes from 14 to 5 in the three plot lines, but it will not plot the three additional plots with the range of 5. 

I also played with  ParamStr( ''name'', ''default'' ) in an attempt to change the period  that shows "5", but that caused an error.

When I plot the 5 version alone, it does have the darker colors that I specified.   Also the name was "ADX(14)", and it is now "Unnamed 15(14)" and the values displayed are still equal to those of the 14 period.

 

range5 = Param("Periods", 5, 2, 200, 1 );

Plot( ad = ADX(range5), _DEFAULT_NAME(), ParamColor( "ADX color", colorBlue ), ParamStyle("ADX style", styleThick ) );

Plot( pd = PDI(range5), "+DI", ParamColor( "+DI color", colorGreen ), ParamStyle("+DI style") );

Plot( md = MDI(range5), "-DI", ParamColor( "-DI color", colorRed ), ParamStyle("-DI style") );

I would appreciate some help to learn the correct way to do this.  meanwhile, I will revert to using the ADX(), MDI() and PDI() functions till I learn how to use param.  Ron D


range14 = Param("Periods", 14, 2, 200, 1 );

Plot( ad = ADX(range14), _DEFAULT_NAME(), ParamColor( "ADX color", colorDarkBlue ), ParamStyle("ADX style", styleThick ) );

Plot( pd = PDI(range14), "+DI", ParamColor( "+DI color", colorDarkGreen ), ParamStyle("+DI style") );

Plot( md = MDI(range14), "-DI", ParamColor( "-DI color", colorDarkRed ), ParamStyle("-DI style") );

 

 

range5 = Param("Periods", 5, 2, 200, 1 );

Plot( ad = ADX(range5), _DEFAULT_NAME(), ParamColor( "ADX color", colorBlue ), ParamStyle("ADX style", styleThick ) );

Plot( pd = PDI(range5), "+DI", ParamColor( "+DI color", colorGreen ), ParamStyle("+DI style") );

Plot( md = MDI(range5), "-DI", ParamColor( "-DI color", colorRed ), ParamStyle("-DI style") );



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





Yahoo! Groups Links