Getting Value from Indicator to int
Getting Value from Indicator to int
08 Jun 2018, 21:53
Hi, Anyone know to use cAlgo API in c# to only get value from an indicator like RSI or Belkhayate. I want to create a robot with Visual Studio by using Indicator code from cAlgo then get value of the indicator without using cTrader to display the graph. I only want to calculate the value with a certaim timeframe and currency pair.
Replies
hengsarathvichet
11 Jun 2018, 11:13
RE:
Panagiotis Charalampous said:
Hi hengsarathvichet,
See below an example of calling an indicator from within a cBot
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { private RelativeStrengthIndex _rsi; protected override void OnStart() { _rsi = Indicators.RelativeStrengthIndex(MarketSeries.Close, 14); } protected override void OnBar() { Print(_rsi.Result.LastValue); } protected override void OnStop() { // Put your deinitialization logic here } } }Let me know if this is what you are looking for.
Best Regards,
Panagiotis
Yes it is. Anymore example of robot and how can I set by timeframe ?
@hengsarathvichet
PanagiotisCharalampous
11 Jun 2018, 11:34
Hi hengsarathvichet,
Here it is
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { private RelativeStrengthIndex _rsi; protected override void OnStart() { var series = MarketData.GetSeries(TimeFrame.Daily); _rsi = Indicators.RelativeStrengthIndex(series.Close, 14); } protected override void OnBar() { Print(_rsi.Result.LastValue); } protected override void OnStop() { // Put your deinitialization logic here } } }
Best Regards,
Panagiotis
@PanagiotisCharalampous
hengsarathvichet
11 Jun 2018, 11:57
RE:
Panagiotis Charalampous said:
Hi hengsarathvichet,
Here it is
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { private RelativeStrengthIndex _rsi; protected override void OnStart() { var series = MarketData.GetSeries(TimeFrame.Daily); _rsi = Indicators.RelativeStrengthIndex(series.Close, 14); } protected override void OnBar() { Print(_rsi.Result.LastValue); } protected override void OnStop() { // Put your deinitialization logic here } } }Best Regards,
Panagiotis
If so, Where can I set currency pair ?
@hengsarathvichet
PanagiotisCharalampous
11 Jun 2018, 12:13
Hi hengsarathvichet,
Which currency pair are you talking about? The one that the cBot will trade on?
Best Regards,
Panagiotis
@PanagiotisCharalampous
hengsarathvichet
11 Jun 2018, 12:17
RE:
Panagiotis Charalampous said:
Hi hengsarathvichet,
Which currency pair are you talking about? The one that the cBot will trade on?
Best Regards,
Panagiotis
Ok, I know how to do that but What about custom Indicator ?
@hengsarathvichet
hengsarathvichet
11 Jun 2018, 13:01
RE:
Panagiotis Charalampous said:
Hi hengsarathvichet,
Which currency pair are you talking about? The one that the cBot will trade on?
Best Regards,
Panagiotis
I got null error from this
Robot m = new Robot(); Symbol eurUsd = m.MarketData.GetSymbol("EURUSD"); MarketSeries seriesEurUsd = m.MarketData.GetSeries(eurUsd, TimeFrame.Minute); Console.WriteLine(seriesEurUsd.SymbolCode);
@hengsarathvichet
PanagiotisCharalampous
11 Jun 2018, 14:15
Hi hengsarathvichet,
The indicator will run for the same symbol as the cBot. Do you need something different? Do you need an indicator for another symbol than the cBot's one?
Best Regards,
Panagiotis
@PanagiotisCharalampous
hengsarathvichet
11 Jun 2018, 14:45
RE:
Panagiotis Charalampous said:
Hi hengsarathvichet,
The indicator will run for the same symbol as the cBot. Do you need something different? Do you need an indicator for another symbol than the cBot's one?
Best Regards,
Panagiotis
I'm running it externally on Windows Form. Yes I need to use a custome indicator.
This : /algos/indicators/show/425
@hengsarathvichet
PanagiotisCharalampous
11 Jun 2018, 15:59
Hi hengsarathvichet,
The code I provided assumes you are running the cBot from cTrader. You will not be able to run it on an external WinForms application as market data will be missing.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Jun 2018, 09:23
Hi hengsarathvichet,
See below an example of calling an indicator from within a cBot
Let me know if this is what you are looking for.
Best Regards,
Panagiotis
@PanagiotisCharalampous