CW
Topics
05 Jan 2024, 09:43
424
3
Replies
Cwebhook
05 Jan 2024, 14:31
( Updated at: 06 Jan 2024, 08:16 )
RE: Using candle body range as source for SimpleMovingAverage
ctrader.guru said:
I'm not sure what you want to do, but start with this approach, if you explain better what you want to achieve I can help you better
using cAlgo.API;using cAlgo.API.Indicators;using System;namespace cAlgo{ [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class test : Indicator { protected override void Initialize() { SimpleMovingAverage sma = Indicators.SimpleMovingAverage(Bars.ClosePrices, 100); double body = Math.Abs(Bars.ClosePrices.Last(0) - Bars.OpenPrices.Last(0)); double body_sma = sma.Result.Last(0) * 3.0; } public override void Calculate(int index) { } } }
Thanks for the reply.
The body var returns a pip value of the current candle, in tradingview that pip value is passed directly to the sma function which then returns an average pip value, for example if I log the output to the data window these are those 2 values, which are changing in realtime with tick data. I'm trying to achieve the same in ctrader but no idea how to.
Cwebhook
10 Jan 2024, 12:56
RE: Using candle body range as source for SimpleMovingAverage
ctrader.guru said:
Thank you! that is what I was after.