Dear Stock# community,
We tried to lunch Sample SMA example with some minor personalization.
The main problem we have is related to drawing candles received from quik real time.
The code reported below is able to draw correctly history data but not the current one received from quik.(we report only a peace of code related to candle drawing, in case you need more information please tell us about it),
Please might you suggest us where the error could be? (We have already set up permissions to administrator for both quik and C# project)
Thank you very much for your help.
Kind regards,
// Trader creation
_trader = new QuikTrader(this.Path.Text);
// CONNECTION
_trader.Connected += () =>
{
_candleManager = new CandleManager(_trader);
//WHEN A NEW CANDLE IS RECEIVED
_candleManager.Processing += (series, candle) =>
{
if (candle.State == CandleStates.Finished)
this.GuiAsync(() => ProcessCandle(candle));
};
_trader.Connect();
}
private void Start_Click(object sender, RoutedEventArgs e)
{
if (_strategy == null)
{
// register our security and timeframe
var series = new CandleSeries(typeof(TimeFrameCandle), _lkoh, _timeFrame);
/*CREATION OF CANDLES FROM HISTORY *.txt*/
IEnumerable<Candle> candles = File.ReadAllLines("LKOH_history.txt").Select(line =>
{
var parts = line.Split(',');
//Returns a string array that contains the substrings that are delimited by ','.
var time = (parts[0] + parts[1]).ToDateTime("yyyyMMddHHmmss");
return (Candle)new TimeFrameCandle
{
OpenPrice = parts[2].To<decimal>(), //To<decimal>() is converter from string to decimal
HighPrice = parts[3].To<decimal>(),
LowPrice = parts[4].To<decimal>(),
ClosePrice = parts[5].To<decimal>(),
TimeFrame = _timeFrame,
OpenTime = time,
TotalVolume = parts[6].To<int>(),
Security = _lkoh,
State = CandleStates.Finished,
};
});
var lastCandleTime = default(DateTime);
// History candles drawing
foreach (var candle in candles)
{
ProcessCandle(candle);
lastCandleTime = candle.OpenTime;
}
/* now we try to get current data from quik */
_candleManager.Start(series);
// Calculation of time intervals of current candle
var bounds = _timeFrame.GetCandleBounds(series.Security);
// get candles from when quik started to the latest one
candles = _candleManager.Container.GetCandles(series, new Range<DateTime>(lastCandleTime + _timeFrame, bounds.Min));
// draw candles received from quik
foreach (var candle in candles)
{
ProcessCandle(candle);
}
}
}
Comentários (4)
Entrar ou Criar conta, Faça login ou cadastre-se para deixar um comentário
First of all what kind of problem did you find? Also you didn't provided the source code of ProcessCandle
Good expirience for those who do not speak Russian. How did you know that?
Thanks.
For sure, ProcessCandles source code is the following one:
The problem consists of impossibility to draw candles from quik.
It seams that:
Regarding your question, we use a lot google translate and we have a russian trader in our team.
Thank you again for your help. Really appreciated.
Check the table "Все сделки". This table should be filled by tick data (historical and realtime).
Thanks Mihail,
It works on Windows 7, but we have some issues on Windows 8 (still not able to receive and draw candles from Quik). Source code and setting are the same. It isn't a big issue, cause we can always forget about Windows 8.
We start looking at Stock# Studio. Complements, it seems to be really well done and complete for developing and testing common algorithms.
I wonder if you plan to make an English version ? It would be cool.