Topics
29 May 2015, 12:39
 0
 2897
 4
18 Sep 2014, 10:49
 0
 2863
 2
19 Aug 2014, 13:03
 5185
 17
13 Aug 2014, 09:17
 2613
 2
Replies

Gman89
01 Jun 2015, 16:31

This post was removed by moderator because it duplicates another post. 


@Gman89

Gman89
01 Jun 2015, 16:12

I see what you mean. the MarketSeries values are based on the bid price and I am trying to access the mid price which would mean getting the correct highs and lows from the price. Because the spread changes slightly from tick to tick you need access to the tick data in order to correctly determine the mid price based high/low. My work around was to maybe allow an indicator to basically do this for me but it seems you can't.


@Gman89

Gman89
01 Jun 2015, 15:05

Any workaround for this in the mean time? The only way I can calculate Ask OHLC is if I calculate my own bars from data via OnTick() by adding Symbol.Spread to LastValue.


@Gman89

Gman89
01 Jun 2015, 14:58

Can you explain the logic? Since I need the mid highs and lows I can't see how this is possible without processing data via the OnTick() method as the instantaneous spread at the time of the mid high/low would have to be known.

At the moment I think the only solution is to write something elaborate to process the tick data to calculate my own bars, then accumulate some history first before actually entering the main code - very annoying.


@Gman89

Gman89
29 May 2015, 12:16

RE: RE:

botmaster said:

Gman89 said:

This is quite a big deal for a lot of strategies. Does anyone know of a good work around at least? Both for historical OHLC and present time. It's not enough to just add spread/2 to the values as highs and lows will be at different times with different bids and asks compared to when you ask the value.

I agree, in fact I'm currently porting my system from another platform to give cAlgo a try.    The custom back-testing engine I wrote uses the bid and ask to determine P/L.   Now, that I'm moving things over to a cBot,  I'm rather concerned that back-testing will not be nearly as accurate with bid only values.     

 

For me the issue is that as well as in real time. I don't mind writing my own custom backtester using mid based historical data that I obtain separately, but for real time execution I need to know that the OHLC are based on mid values as well to ensure that my back-testing actually reflects what is being traded. 

I would really like to get a response from Spotware about this. I can deal with a work around for now if anyone can think of a way without writing some elaborate code that calculates the bars myself - but this defeats the point of using cAlgo. Is it possible to use the Indicator or Timeseries classes to do this?


@Gman89

Gman89
28 May 2015, 16:16

This is quite a big deal for a lot of strategies. Does anyone know of a good work around at least? Both for historical OHLC and present time. It's not enough to just add spread/2 to the values as highs and lows will be at different times with different bids and asks compared to when you ask the value.


@Gman89

Gman89
27 May 2015, 20:24

RE:

Spotware said:

I am printing Symbol.Ask, Symbol.Bid and MarketSeries.Close.LastValue on every tick and noticed that MarketSeries.Close.LastValue and Symbol.Bid values are always same and also MarketSeries.TickVolume.LastValue is coming as some incremental values.

This should not be the case as this would mean that we always have bid side trades.

MarketSeries.Close is built based on bid prices only.

And also MarketSeries.TickVolume.LastValue doesn't seem to have the correct values.

MarketSeries.TickVolume shows number of bid changes for historical trendbars.

Does it help?

If you wanted to use MarketSeries to utilize mid price, what would be the best workaround? I ask because the value for open, high and low based on mid price movement are important in my algo's. This also means initializing my historical window based on mid for my indicators on start.

 

See here:

 

/forum/calgo-support/5340


@Gman89

Gman89
22 May 2015, 16:00

See this post:

/forum/cbot-support/2579

Basically you can query the data if you decide on a time frequency and then using the OnTimer method - this basically does the same thing as OnTick but the event is time based and not tick based.


@Gman89

Gman89
22 May 2015, 15:57

I solved the issue.

I realized in newer versions of cAlgo there is an OnTimer method. I just set this to 1 second and utilized the RefreshData() function to ensure the MarketSeries values are up to date.

 


protected override void OnStart()
{
       Timer.Start(1);

}


protected override void OnTimer()
        {
 
            // Wait until close
            if (atClose())
            {
                  RefreshData()
                  // further code

            }
 
        }
        private bool atClose()
        {
            if (Time.Second == 59)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

 


@Gman89

Gman89
22 May 2015, 13:47

Hey,

Thanks for the reply.

Is that placed in the OnTick() method? Because the issue I have is that I cannot access the latest value of MarketSeries.Close.LastValue unless the bot is prompted to do so on a tick. If there is no tick then I can't read the latest value.

Lets say for example that the last tick movement was at 50 seconds, and because of low volume there isn't another tick movement until 10 seconds in the next minute; I still want to be able to get the candlestick at 59 seconds. Currently, I cannot do this because OnBar() and OnTick() only get called when there is an actual tick. If I used my code in my original post it would just skip the bar completely, and if I used OnBar() to utilized Close.Last(1) there would be a 10 second delay even though no real information has changed in that time.  

 


@Gman89

Gman89
22 May 2015, 13:16

I have this issue as well. If you want to use a method like Close.LastValue it will only return a value in the OnTick() method once there is actually a tick. If there is no tick then you can't access LastValue which is annoying. 


@Gman89

Gman89
18 Apr 2015, 11:01

This post was removed by moderator, because it duplicates another post. /forum/calgo-support/4959?page=1#1


@Gman89

Gman89
18 Apr 2015, 11:00

Hi,

I run an algo that makes a decision based on the previous (just finished) m1 bars close. The code on whether to execute (based on the recent value) is then placed in the OnBar method. My assumption is that the time to execute the trade (usually less than a second in a liquid market) is negligible compared to the typical length of the trade.

The problem I have is that during times of lower volume this delay can sometimes be on the order of 30 seconds. I've watched the chart during these periods - typically what happens is that as the time ticks over from 59 seconds, the data feed and chart seem to hang and no new bar appears. In terms of the code, this means that the OnBar method is not entered until this hanging stops. This is problematic as there might be a jump between the close and open in that time which the algo will not recognize. I have tried running this on an AWS instance in Frankfurt and Ireland where server latency was ~15ms so I don't think it is my PC or my location.

Because my algo is determined by the previous close value, a band-aid solution would be to have something like the OnBar method execute right before the close (1-2 seconds maximum) either based on time or tick.

I'm trying to avoid using the tick timeframes and having to write a whole bunch of supporting code to work out an effective OHLC - mostly because I'm utilizing the cAlgo Last() method to make things easier.

Does anyone know of a solution to this problem or a good work around? I can sacrifice 1-2 seconds as this would be much better than the occasional 30 seconds I'm getting during these periods.

Thanks!


@Gman89

Gman89
19 Aug 2014, 15:31

It definitely was.

I restarted my computer and the problem seems to have disappeared. Will let you know if it comes back.


@Gman89