Error while dragging custom indication created from custom function

Hi

I developed a custom function to easily reuse whether Plotting as a custom indicator into a chart or calling it as Buy/Sell signal in BackTest or Filtering in Exploration.

The below is my custom function for reuse in many times in AB.
1

I can completely apply it in both backtest and exploration.

2
But in custom indicator , I create custom indicator from calling the custom function like earlier mentioned backtest.

#include<ATRForTralingStop.afl>

_SECTION_BEGIN("ATRTRail");
vPeriod =  Param( "Volatility Period", 50 );
XFactor = Param( "X Factor" , 3.4 );


xtrail=ATRForTralingStop(vPeriod,XFactor);
Plot(xtrail,"LossLine", ParamColor( "Color", colorRed ), ParamStyle("Style",styleLine|styleThick|styleDashed) );

_SECTION_END();

However, once I drag my newly created custom indication into a chart in the second time, The Error was thrown as the figure below.
1

2

I am assuming that .the error may result from double statatement of #include<ATRForTralingStop.afl> in code.
3|690a x423

How to deal with this problem if I would like to create a custom indicator from the custom function and a custom indicator must include custom function inevitably.

Using #include_once instead of #include prevents such syntax errors on repeated drag&drops.

#include_once <ATRForTralingStop.afl>
1 Like

Many thank for prompt reply.
2 4