A newbie question

1.What is the difference between "apply" and "apply indicator ' in the AFL writing area ?
2. in the setchartoptions fucntion, what is the real and practical use of the " mode " parameter ?

Thanks a lot for replying

Quoting from Release Notes 4.65.0 (as compared to 4.64.3):

Formula Editor now features "Apply indicator" button that works like old "Apply"
(i.e. checks syntax, saves and inserts ONCE) as well as "Insert indicator" (available from submenu) that allows to insert multiple chart panes linked to the same formula.

So, there is no difference between "Apply" and "Apply Indicator", rest is self-explanatory.

The note in the User Manual is self-explanatory. Do you have any specific doubt?

1 Like

Thanks . When i edit a code , sometimes the new settings are not reflected in the chart window and I have to use " apply indicator"

regarding the user manual of setchartoptionns , its pretty clear and explained nicely , but the usage of mode is not clear to me . I tried to change the mode in my sample codes but nothing noticeable happened

You should always be using "Apply indicator" (not "Save"). Apply indicator already saves the code plus makes sure that everything ELSE what is needed is done. As written in documentation Apply is much more than just saving. It does

  • syntax check
  • save
  • applying changed parameter values / removing unused ones
  • inserting indicator when it is NOT already present
1 Like

Quoting from SetChartOptions Guide for you to read:

0 - set only the DEFAULT values for new chart. Defaults are applied only once when chart is inserted in a new pane, so later you can modify any option using Indicator Builder

1 - overwrite - the values specified in 2nd and 3rd argument overwrite any previously set values

Below is a simple code example, upon loading it to a chart you will find two CheckBoxes, namely, MA1 & MA2. Play with those and notice what happens to:

image
Also observe whether you are able to change the chart's scale by clicking on that LOG button or not for each CheckBox.

PerMA1 = 20;
PerMA2 = 50;

ChkBxIdMA1 = 1;
ChkBxIdMA2 = ChkBxIdMA1 + 1;

GuiCheckBox( "MA1", ChkBxIdMA1, 50, 50, 40, 20, notifyClicked );
GuiCheckBox( "MA2", ChkBxIdMA2, 50, 70, 40, 20, notifyClicked );

GuiSetColors(
ChkBxIdMA1, ChkBxIdMA2, border = 1,
clrText = colorWhite, clrbk = colorDefault, clrBor = colorDefault
);

Plot( C, "Price", colorDefault, styleBar | styleThick );

if( GuiGetCheck( ChkBxIdMA1 ) ) {
	 //When Mode = 0 it does not overwite the previous state (or flag) and allows the user to make changes
	 SetChartOptions( 0, chartLogarithmic );
	 
	 MA1 = MA( C, PerMA1 );
	 Plot( MA1, "MA1( C, " + PerMA1 + " )", ColorRGB( 70, 160, 255 ), styleNoRescale | styleNoLabel );
}

if( GuiGetCheck( ChkBxIdMA2 ) ) {
	 //When Mode = 1 it overwites the previous state (or flag) with the specified flag and does not allow the user to make further changes
	 SetChartOptions( 1, chartLogarithmic );

	 MA2 = MA( C, PerMA2 );
	 Plot( MA2, "MA2( C, " + PerMA2+ " )", colorLightOrange, styleNoRescale | styleNoLabel );
}

Quoting again from SetChartOptions Guide for you to read:

2 - set flag - flags specified in 2nd and 3rd parameter are binary-ORed with the current values, so effectively these options are set while remaining are unchanged

3 - reset flag - flags specified in 2nd and 3rd parameter are cleared while the others remain unchanged.

Load the below code example to a Chart and play with Parameters > ParamToggle (namely, "Chart Scale Type") and notice what happens to the same LOG Button.

ChartScale = ParamToggle( "Chart Scale Type", "Linear|Logarithmic", 1 );

SetChartOptions( 0, chartShowDates );

//A logic presented by Edward Pottasch
if( ChartScale ) SetChartOptions( 2, chartLogarithmic, chartGridMiddle | chartGridMargins );
else SetChartOptions( 3, chartLogarithmic, !( chartGridMiddle | chartGridMargins ) );

Plot( C, "Price", colorDefault, styleBar | styleThick );
3 Likes