How to do Simple Moving Average on Indicator?

Is there anyone who can program the moving average of the indicator? (Example: SMA on StdDev and others)?

Thanks.
Attachments
No attachments
  • Votes +1
  • Project StrategyQuant X
  • Type Feature
  • Status Moved
  • Priority Normal
  • Assignee None

History

FC
#1

Kenzo105

08.03.2020 19:19

Task created

FC
#2

Kenzo105

08.03.2020 19:55

i have try with this code,

what am I doing wrong?

package SQ.Blocks.Indicators.StdMedia; import SQ.Calculators.StdDevCalculator; import com.strategyquant.datalib.DataSeries; import com.strategyquant.datalib.TradingException; import com.strategyquant.tradinglib.BuildingBlock; import com.strategyquant.tradinglib.Colors; import com.strategyquant.tradinglib.Help; import com.strategyquant.tradinglib.Output; import com.strategyquant.tradinglib.Parameter; import com.strategyquant.tradinglib.ParameterSet; import com.strategyquant.tradinglib.ReturnTypes; import SQ.Calculators.AverageCalculator; import SQ.Internal.IndicatorBlock; @BuildingBlock(name="(StdMedia) StdMedia", display="SDM(#Period#)[#Shift#]", returnType = ReturnTypes.Price) @Help("StdMedia") @ParameterSet(set="Period=14") @ParameterSet(set="Period=20") @ParameterSet(set="Period=30") @ParameterSet(set="Period=40") @ParameterSet(set="Period=50") @ParameterSet(set="Period=14,ComputedFrom=0") @ParameterSet(set="Period=20,ComputedFrom=0") @ParameterSet(set="Period=30,ComputedFrom=0") @ParameterSet(set="Period=40,ComputedFrom=0") @ParameterSet(set="Period=50,ComputedFrom=0") public class StdMedia extends IndicatorBlock { @Parameter public DataSeries Input; @Parameter(defaultValue="14") public int Period; @Output(name = "StdMedia", color = Colors.Red) public DataSeries Value; private AverageCalculator averageCalculator; //------------------------------------------------------------------------ //------------------------------------------------------------------------ //------------------------------------------------------------------------ @Override protected void OnInit() throws TradingException { averageCalculator = new AverageCalculator(AverageCalculator.SMA, Period); } //------------------------------------------------------------------------ @Override protected void OnBarUpdate() throws TradingException { this.Calls++; averageCalculator.onBarUpdate(Strategy.Indicators.StdDev(Input,Period), CurrentBar); Value.set(0, averageCalculator.getValue()); } }



FC
#3

Kenzo105

09.03.2020 15:31
Voted for this task.
MF
#4

Mark Fric

26.02.2021 13:27
Task moved to project Extending SQ, new link to task: https://sq.projectpanel.com/tasks/sqp_0133

Votes: +1

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please