Plotting two custom indicators of same AFL into two different panes

Hi,
If I write an AFL code where I write two custom indicators and then I plot them in new pane.
Then, it plots both of the custom indicators in same pane. And it leads to confusion interpreting them.
How both indicators can be plotted in two separate panes.

Hi Puneet

You can do it one of two ways.

You can write them in separate AFL files, then insert them individually to the chart pane, which will put them in separate panes.

The other way is to have them in the same AFL, but use a conditional statement and a parameter to determine which one is displayed.
Eg

``````ChartType = ParamList("Chart Type", "Price Chart|Indicator"); //

if (ChartType == "Price Chart")  // Price Chart
{
Plot(C,"C",colorBlack,styleCandle);
}

if (ChartType == "Indicator")  //
{
Plot(MyIndicator, "MyIndicator", colorBlack, styleThick  );
}
``````

Then insert this code twice to the chart (where they will at first both show the first plot), then right-click on the second pane, chose Parameters, and change the Chart Type to the other indicator.

6 Likes

a1=HHV(H,20)-LLV(L,20);
a2=HHV(H,100)-LLV(L,100);

ChartType = ParamList("Chart Type", "Price Chart|Indicator"); //

if (ChartType == "Price Chart") // Price Chart
{
Plot(C,"C",colorBlack,styleCandle);
}

if (ChartType == "Indicator") //
{
Plot(a1, "MyIndicator1", colorRed, styleThick );
Plot(a2, "MyIndicator2", colorGreen, styleThick );
}
I tried above way of plotting two indicators a1 and a2 in seperate two panes of charts using above method, but not getting desired result. Both indicators are showing in same pane.I am also uploading result of above code.

Puneet, there is a chart window with two panes on your screenshot. You need to go to the Parameters of one of the panes and change the “Chart Type”. HelixTrader has shown you two ways of acomplishing the desired result and they work. The simplest one is of course the first one. Also take a look here:

Hi, Thanks for your reply. First method is working. But as per second method, when we go in one of pane and then change parameter of that pane "chart type", still problem is not solved. as It shows both indicators simultaneously in both the panes. I am attaching image of it. I request, if you could provide this solution with an example including image.
regards
Puneet

Hi Puneet

Your code works fine. Try changing the Chart Type parameter in one of the panes to Price Chart.

Please use one indicator in one parameter and the other indicator inside to other parameter.
Otherwise ParamList ChartType has two incicators inside in One of those 2 parameter

Panos

3 Likes

Puneet

As @Panos says, you'll need to put the indicators in separate if statements, then select them separately on the chart. Also remember all the values for the parameter must be in the ParamList statement.

Try this:

``````a1=HHV(H,20)-LLV(L,20);
a2=HHV(H,100)-LLV(L,100);

ChartType = ParamList("Chart Type", "Price Chart|Indicator1|Indicator2"); //

if (ChartType == "Price Chart") // Price Chart
{
Plot(C,"C",colorBlack,styleCandle);
}

if (ChartType == "Indicator1") //
{
Plot(a1, "MyIndicator1", colorRed, styleThick );
}

if (ChartType == "Indicator2") //
{
Plot(a2, "MyIndicator2", colorGreen, styleThick );
}
``````

1 Like

To be honest for the beginners is better to watch this video.

STEP1 = The easiest way is go to Chart window, mouse right click /insert indicator
You can repeat this as many times you like the step one

1 Like

just searched and used the code. works awesome

I noticed that the ParamList function allows us to choose which indicators shown in the pane, but I'm wondering is there any AFL function or formula that could insert new pane in one single AFL sheet or provide option to turn on/off the pane using parameter?

For example, I would like to use moving average and oscillator indicators in my chart, but the oscillator is located in the new pane and we could choose the oscillator, e.g., between stochastic or RSI.

Thank you.
Alfyan

Hi,

You can't insert panes from formula but there are two ways you can do it.

If you are not familiar with coding, then create all the different types of combinations on different chart sheets. Then all you need to do is switch between them. Even the entire layout can be switched in a couple of clicks.

If you are ok with code, then you can write your logic in the oscillator pane to plot which indicator based on your conditions.
Like if 1H chart, plot stochastic else RSI etc.
Or you can even set a variable in one pane and use it to plot something in other panes etc.
The second way gives you a lot of freedom to customize it in countless ways.

Hi @nsm51,

Well noted. I think I will try the latest for exercise.