what's the mistake?
what's the mistake?
24 Apr 2020, 10:34
Hi, I have to print the SPAN A and B values of a random symbol in the fifth last candle
but I think there is an error on var index5
what's the mistake?
thanks
protected override void OnStart()
{
string EURUSD = Symbols[random.Next(Symbols.Count)];
Symbols.GetSymbol("EURUSD");
Print(EURUSD);
ichimoku = Indicators.IchimokuKinkoHyo(MarketData.GetBars(TimeFrame.Hour, EURUSD), 9, 26, 52);
var index5 = Bars.ClosePrices.Count - 5;
Print("Span A: ", ichimoku.SenkouSpanA[index5]);
Print("Span B: ", ichimoku.SenkouSpanB[index5]);
}
Replies
luca.tocchi
24 Apr 2020, 11:13
RE:
PanagiotisCharalampous said:
Hi Luca,
Why do you think there is a problem?
Best Regards,
Panagiotis
because the values are wrong
and Say "NaN"
@luca.tocchi
PanagiotisCharalampous
24 Apr 2020, 11:20
Hi Luca,
Can you post the complete cBot code?
Best Regards,
Panagiotis
@PanagiotisCharalampous
luca.tocchi
24 Apr 2020, 11:35
RE:
PanagiotisCharalampous said:
Hi Luca,
Can you post the complete cBot code?
Best Regards,
Panagiotis
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 ValoriSpanIchimoku : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
private IchimokuKinkoHyo ichimoku;
private Random random = new Random();
protected override void OnStart()
{
string EURUSD = Symbols[random.Next(Symbols.Count)];
Symbols.GetSymbol("EURUSD");
Print(EURUSD);
ichimoku = Indicators.IchimokuKinkoHyo(MarketData.GetBars(TimeFrame.Hour, EURUSD), 9, 26, 52);
var index5 = Bars.ClosePrices.Count - 5;
Print("Span A: ", ichimoku.SenkouSpanA[index5]);
Print("Span B: ", ichimoku.SenkouSpanB[index5]);
}
}
}
@luca.tocchi
PanagiotisCharalampous
24 Apr 2020, 12:19
Hi Luca,
This seems to happen only on symbols that have no data. See an example below
You need to use symbols that have data for this to work.
Best Regards,
Panagiotis
@PanagiotisCharalampous
luca.tocchi
24 Apr 2020, 12:34
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi Luca,
This seems to happen only on symbols that have no data. See an example below
You need to use symbols that have data for this to work.
Best Regards,
Panagiotis
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 Random random = new Random();
private IchimokuKinkoHyo ichimoku;
protected override void OnStart()
{
string EURUSD = Symbols[random.Next(Symbols.Count)];
Symbols.GetSymbol("EURUSD");
Print(EURUSD);
var symbol = MarketData.GetSymbol(EURUSD);
var index = Bars.ClosePrices.Count - 5;
ichimoku = Indicators.IchimokuKinkoHyo(MarketData.GetBars(TimeFrame.Minute10, EURUSD), 9, 26, 52);
Print("Span A: ", ichimoku.SenkouSpanA[index]);
Print("Span B: ", ichimoku.SenkouSpanB[index]);
}
}
}
now works
But..
I put: var index = Bars.ClosePrices.Count - 5;
5 is the value of the sixth last candle because the last one is 0
but the SSA and SSB values do not match
the blue line are the value of SSA e SSB
@luca.tocchi
luca.tocchi
25 Apr 2020, 09:26
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi Luca,
This seems to happen only on symbols that have no data. See an example below
You need to use symbols that have data for this to work.
Best Regards,
Panagiotis
what do you think is the mistake in this case?
@luca.tocchi
PanagiotisCharalampous
27 Apr 2020, 09:09
Hi Luca,
5 is the value of the sixth last candle because the last one is 0
This is not true. 5 means the fifth value from the last value of the indicator. If you notice, the Ichimoku indicator prints some values in the future. You need to take that into consideration as well.
Best Regards,
Panagiotis
@PanagiotisCharalampous
luca.tocchi
27 Apr 2020, 09:25
RE:
PanagiotisCharalampous ha detto:
Ciao Luca,
5 è il valore della sesta ultima candela perché l'ultima è 0
Questo non è vero. 5 indica il quinto valore dell'ultimo valore dell'indicatore. Se si nota, l'indicatore Ichimoku stampa alcuni valori in futuro. È necessario prendere in considerazione anche questo.
Migliori saluti
Panagiotis
oh... now it work
thanks
@luca.tocchi
PanagiotisCharalampous
24 Apr 2020, 10:57
Hi Luca,
Why do you think there is a problem?
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous