Add levels for Simple Moving Average
Add levels for Simple Moving Average
19 Sep 2019, 10:58
It seems that cTrader doesn't support adding levels for its Simple Moving Average. I am using IC Market as my broker, I want to add 50 & -50 levels on my 200 SMA. I can do it with mt4 but not with cTrader. Is it possible to do with cTrader? Please refer to the photos attached.
Can please somebody help? Thanks in advance!
Replies
beej.sanchez
19 Sep 2019, 11:33
( Updated at: 21 Dec 2023, 09:21 )
RE:
WOW. thank you for your help!
Usong cTrader, I set the indicator to 200 SMA, then 5 as the level. I am assuming this is the same with what Ive done with MT4, 200 SMA, add 50 & -50 Level
The photo below shows the result.
Panagiotis Charalampous said:
Hi beej.sanchez,
There is no such feature in cTrader but you can easily achieve this with a custom indicator. See below an example
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewIndicator : Indicator { [Parameter(DefaultValue = 14)] public int Periods { get; set; } [Parameter(DefaultValue = 5)] public double Level { get; set; } [Output("Main")] public IndicatorDataSeries MA { get; set; } [Output("Leven Up")] public IndicatorDataSeries LevelUp { get; set; } [Output("Leven Down")] public IndicatorDataSeries LevelDown { get; set; } SimpleMovingAverage _sma; protected override void Initialize() { _sma = Indicators.SimpleMovingAverage(MarketSeries.Close, Periods); } public override void Calculate(int index) { // Calculate value at specified index MA[index] = _sma.Result[index]; LevelUp[index] = _sma.Result[index] + Symbol.PipSize * Level; LevelDown[index] = _sma.Result[index] - Symbol.PipSize * Level; } } }Best Regards,
Panagiotis
@beej.sanchez
PanagiotisCharalampous
19 Sep 2019, 11:45
Hi beej.sanchez,
I used pips but it seems that MT4 uses points. It can be easily modified if you wish.
Best Regards,
Panagiotis
@PanagiotisCharalampous
beej.sanchez
19 Sep 2019, 12:20
RE:
Can you please show me also the formula for points?
Panagiotis Charalampous said:
Hi beej.sanchez,
I used pips but it seems that MT4 uses points. It can be easily modified if you wish.
Best Regards,
Panagiotis
@beej.sanchez
PanagiotisCharalampous
19 Sep 2019, 12:33
Here it is
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewIndicator : Indicator { [Parameter(DefaultValue = 14)] public int Periods { get; set; } [Parameter(DefaultValue = 50)] public double Level { get; set; } [Output("Main")] public IndicatorDataSeries MA { get; set; } [Output("Leven Up")] public IndicatorDataSeries LevelUp { get; set; } [Output("Leven Down")] public IndicatorDataSeries LevelDown { get; set; } SimpleMovingAverage _sma; protected override void Initialize() { _sma = Indicators.SimpleMovingAverage(MarketSeries.Close, Periods); } public override void Calculate(int index) { // Calculate value at specified index MA[index] = _sma.Result[index]; LevelUp[index] = _sma.Result[index] + Symbol.TickSize * Level; LevelDown[index] = _sma.Result[index] - Symbol.TickSize * Level; } } }
@PanagiotisCharalampous
beej.sanchez
19 Sep 2019, 13:17
RE:
Thank you very Much!
Panagiotis Charalampous said:
Here it is
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewIndicator : Indicator { [Parameter(DefaultValue = 14)] public int Periods { get; set; } [Parameter(DefaultValue = 50)] public double Level { get; set; } [Output("Main")] public IndicatorDataSeries MA { get; set; } [Output("Leven Up")] public IndicatorDataSeries LevelUp { get; set; } [Output("Leven Down")] public IndicatorDataSeries LevelDown { get; set; } SimpleMovingAverage _sma; protected override void Initialize() { _sma = Indicators.SimpleMovingAverage(MarketSeries.Close, Periods); } public override void Calculate(int index) { // Calculate value at specified index MA[index] = _sma.Result[index]; LevelUp[index] = _sma.Result[index] + Symbol.TickSize * Level; LevelDown[index] = _sma.Result[index] - Symbol.TickSize * Level; } } }
@beej.sanchez
beej.sanchez
19 Sep 2019, 16:02
Hello Panagiotis Charalampous
Can you please direct me to the proper channel regarding my concern which is I have a Mt4 indicator that needs to be converted to cTrader and possible remove the errors. Thanks
@beej.sanchez
PanagiotisCharalampous
19 Sep 2019, 16:14
Hi beej.sanchez,
You can get in touch with a Consultant.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
19 Sep 2019, 11:10
Hi beej.sanchez,
There is no such feature in cTrader but you can easily achieve this with a custom indicator. See below an example
Best Regards,
Panagiotis
@PanagiotisCharalampous