Topics
Replies
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
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, 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
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
beej.sanchez
19 Sep 2019, 20:27
THANKS!
@beej.sanchez