Error while dragging custom indication created from custom function


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.

I can completely apply it in both backtest and exploration.

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


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

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


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


I am assuming that .the error may result from double statatement of #include<> 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 <>
1 Like

Many thank for prompt reply.
2 4