How receive a value of Main Moving Average Line of Keltner Channels in my cBot?
How receive a value of Main Moving Average Line of Keltner Channels in my cBot?
09 Apr 2018, 22:53
Hi All,
We have one of bases indicators Keltner Channels are volatility-based envelopes set above and below an exponential moving average, I add this indicator to chart but don't know How to receive a value of Main Moving Average Line in my cBot.
If somebody can help I will very appreciate.
Thanks.
Replies
anton.kovalchuk
10 Apr 2018, 12:23
Hi Panagiotis Charalampous
Thank you for an answer.
I know about the indicator only.
KeltnerChannels Summary Initializes the Keltner Channels indicator instance Syntax public KeltnerChannels KeltnerChannels(int maPeriod, MovingAverageType maType, int atrPeriod, MovingAverageType atrMaType, double bandDistance) Return type KeltnerChannels Parameters Name Description maPeriod Moving Average Period maType Moving Average Type atrPeriod Average True Range Period atrMaType Average True Range MAType bandDistance ATR Multiplier
Members Name Description Bottom Moving Average - ATR * BandDistance Main Moving Average Line Top Moving Average + ATR * BandDistance
protected override void OnTick()
{
// my cBot should knowns when the current market price will be equal to KeltnerChannels.Main.LastValue
//and able to close position when current market price will be equal to KeltnerChannels.Bottom.LastValue or Top
}
@anton.kovalchuk
PanagiotisCharalampous
10 Apr 2018, 12:30
Hi Anton,
Since you cannot provide me with the indicator, please see below how you can access the values of an SMA indicator from a cBot.
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; using System.Windows.Forms; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC)] public class NewcBot : Robot { private SimpleMovingAverage _sma; protected override void OnStart() { _sma = Indicators.SimpleMovingAverage(MarketSeries.Close, 14); } protected override void OnBar() { Print(_sma.Result.LastValue); } protected override void OnStop() { } } }
You can adjust the above sample to your indicator.
Best Regards,
Panagiotis
@PanagiotisCharalampous
anton.kovalchuk
10 Apr 2018, 13:41
( Updated at: 21 Dec 2023, 09:20 )
Thank you a lot Panagiotis
To clarify only, so I can use data from indicators that exist in cAlgo\Sources\ catalog only. Correct?
An indicator that I was going to use does not exist there but exist in standard indicators list. as on my screenshot:
@anton.kovalchuk
PanagiotisCharalampous
10 Apr 2018, 14:08
Hi Anton,
You can use custom indicators as well. Read how to do this here.
Best Regards,
Panagiotis
@PanagiotisCharalampous
anton.kovalchuk
10 Apr 2018, 15:10
Great, The manual explain all that I need. Thanks!
@anton.kovalchuk
PanagiotisCharalampous
10 Apr 2018, 11:24
Hi anton.kovalchuk,
If you could share the indicator with us, then maybe we could create an example for you.
Best Regards,
Panagiotis
@PanagiotisCharalampous