Tick Capture

Post your indicators here
ianj
Trader
Posts: 81
Joined: Sat Feb 09, 2013 2:07 am

Re: Tick Capture

Post by ianj »

kwanann wrote:Are u storing all these anywhere?
I have been thinking about what to do with this - of more public use. Data distribution restrictions will likely preclude mass exports but i was perhaps thinking about a web page where you type in the date/time and up pops up a historical tick chart - perhaps that might be useful to others ?
CNS VPS - it just works :-)
ianj
Trader
Posts: 81
Joined: Sat Feb 09, 2013 2:07 am

Re: Tick Capture

Post by ianj »

I now have a tick capture Robot - lets see what its lifecycle is compared with the indicator - running side by side on live
CNS VPS - it just works :-)
ianj
Trader
Posts: 81
Joined: Sat Feb 09, 2013 2:07 am

Re: Tick Capture

Post by ianj »

I wish i knew C# better !

I have found i can subscribe to market data for more than one pair inside a single robot but i have a problem extending it to an arbitrary limit

You subscribe to market data using something similar to this:

Code: Select all

            marketDepthGBPUSD = MarketData.GetMarketDepth("GBPUSD");
            marketDepthGBPUSD.Updated += MarketDepthUpdatedGBPUSD;
but MarketDepthUpdatedGBPUSD must be a method with 0 parameters - so the call cannot identify WHICH market data has been updated (if you setup multiple pairs as above) It works if you have a single method per pair like this:

Code: Select all

            marketDepthGBPUSD = MarketData.GetMarketDepth("GBPUSD");
            marketDepthGBPUSD.Updated += MarketDepthUpdatedGBPUSD;

            marketDepthEURUSD = MarketData.GetMarketDepth("EURUSD");
            marketDepthEURUSD.Updated += MarketDepthUpdatedEURUSD;

and

        void MarketDepthUpdatedEURUSD() {
            MarketDepthUpdated(marketDepthEURUSD);
        }
        void MarketDepthUpdatedGBPUSD() {
            MarketDepthUpdated(marketDepthGBPUSD);
        }

so the MarketDepthUpdated method can tell WHICH market data has updated, but it requires one method per pair - its hardly dynamic. In other languages you have the concept of function points (C/C++) or objects with polymorphic invocation (Java). How, in C# can i pass in a 0 argument method name that can tell what has updated

So right now i can add an instance of the construct above for each pair - at least it allows me to reduce the number of robots - perhaps reducing the memory footprint of the whole setup, but its not ideal ...
CNS VPS - it just works :-)
ianj
Trader
Posts: 81
Joined: Sat Feb 09, 2013 2:07 am

Re: Tick Capture

Post by ianj »

Ah! - i can use

Code: Select all

class MyUpdate { 
  ....
  public void updated() {
    robot.MarketDepthUpdated(symbol, marketDepth);
  }
}
my = new MyUpdate (this, "EURUSD", marketDepthEURUSD);
marketDepthEURUSD.Updated += my.updated;

and to handle the update:
void MarketDepthUpdated(string symbol, MarketDepth _marketDepth) {
......
where my is an instance of a customs class that KNOWS the market update instance, symbol and robot - and so can call with the correct parameters

.. and it works - C# is forgiven - that means an arbitrary number of market data subscriptions can be managed in 1 robot - hopefully that will help.

I would have to run side by side with separate robots for a while to make sure it still works the same way - the event triggering policy is not defined and it might be different with multiple robots leading to different update timings

Now all i need to do is to get Trade.* to allow arbitrary symbol trading in a robot and i am content ..
CNS VPS - it just works :-)
Radar
Trader
Posts: 437
Joined: Fri Mar 23, 2012 5:39 pm
Location: Round the bend ;)

Re: Tick Capture

Post by Radar »

Hey Ianj,
Now all i need to do is to get Trade.* to allow arbitrary symbol trading in a robot and i am content ..
Should be the same deal, shouldn't it?

Create a public function with blank Symbol(), SL, TP, etc, and polymorph as needed?

Have fun!

Radar =8^)
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
ianj
Trader
Posts: 81
Joined: Sat Feb 09, 2013 2:07 am

Re: Tick Capture

Post by ianj »

The problem with arbitrary symbol trading is that i do not think cAlgo supports it - and that seems to be supported by a response in the spotware forum:
http://ctdn.com/forum/cbot-support/443

The problem is that all the trade API's use the robot property Symbol - and there does not seem to be any way to instantiate or retrieve a "Symbol" for a specific pair - GetMarketDepth allows specification using a string or Symbol - but not the Trade API's

The online help sorta ihints that "Symbol" is a type - but its not - its a property - but i don't know what type it is ..

Again, its probably my lack of experience with C# - exactly what is Symbol ?
CNS VPS - it just works :-)
ianj
Trader
Posts: 81
Joined: Sat Feb 09, 2013 2:07 am

Re: Tick Capture

Post by ianj »

OK - managed it :D

Despite the spotware posting i managed to post a GBPUSD order from a EURUSD chart.

Symbol seems to be both a property AND an interface in using cAlgo.API.Internals;

I implemented the Symbol interface and overrode "Code" to return "GBPUSD" but otherwise used the standard Symbol property attributes on a EURUSD chart

- and voila ! A GBPUSD position !

I need to tidy it up to be more general and look for complications but it seems to work

Code: Select all

            mySymbol.Code = "GBPUSD"; 
            Trade.CreateMarketOrder(TradeType.Buy, mySymbol, Volume);
            mySymbol.Code = "EURUSD"; 
            Trade.CreateMarketOrder(TradeType.Buy, mySymbol, Volume);
            mySymbol.Code = "AUDUSD"; 
            Trade.CreateMarketOrder(TradeType.Buy, mySymbol, Volume);
3 positions (EURUSD, GBPUSD, AUDUSD) - one chart/robot (EURUSD) :D

I understand this is a diversion from it being a CAPTURE indicator, but my other project is a trading BRIDGE and that does not have a thread and the info might still be useful to others
CNS VPS - it just works :-)
ianj
Trader
Posts: 81
Joined: Sat Feb 09, 2013 2:07 am

Re: Tick Capture

Post by ianj »

Back to capture - if you are interested in more trade operations check this out -my Bridge Robot
http://www.stevehopwoodforex.com/phpBB3 ... =68&t=3122

Have see a few disconnects with an Indicator & Robot now - as suspected the Robot stays alive (so will probably maintain its socket connections) and the indicator restarts. So far the only discernible indication of a connection issue is the bid/asks dropping out (count=0) on the level 2 update. So its safe to assume that a lack of bid OR ask means that it is currently IN or recovering from a disconnection. I don't yet know if the bid/ask drops at the START of the disconnection or when it reconnects - that is one for later

PS - i am looking at the potential of OnError with an Error code os Disconnected - lets see if it does that
CNS VPS - it just works :-)
ianj
Trader
Posts: 81
Joined: Sat Feb 09, 2013 2:07 am

Re: Tick Capture

Post by ianj »

Interesting .. I restarted my UK VPS over the weekend (memory upgrade) and when i restarted cAlgo its was taking a much smaller memory footprint - according to the Task Manager

UK is Windows 2003 -32 bit - CNS VPS
US is Windows 2012 -64 bit - CNS VPS

I checked today and its larger but still far smaller than it was at the close of last week or when i started capturing last week. I must add that all i did was START cAlgo on Sunday night (is now Monday lunch) - it restarted the cAlgo indicators (40 pairs captured now), but nothing else - no compilations, no usage of the GUI. Is suspect that something potentially heavyweight - like using it as a dev environment, using the editor and compiler etc, bloats the memory footprint (was 300MB+ last week - is now 155 MB)

I just checked my US VPS - and its 300+MB. Looks like its time for some experiments ..

I think i will also assemble a single indicator to capture multiple pairs and compare it against the 1 per chart i am using already

UK - I just checked with SysInternals: Process Explorer and it shows that the complete memory usage is 400MB+, but only 155MB in the working set - all the rest is swapped out to disk and stable - which is fine by me
US is showing 380/413MB - working set is HIGHER - that looks odd !

Restarted UK cAlgo - its back UP to 300MB+ again - maybe it settles down after a while - i'll have to keep an eye on it
CNS VPS - it just works :-)
ianj
Trader
Posts: 81
Joined: Sat Feb 09, 2013 2:07 am

Re: Tick Capture

Post by ianj »

Hmm! Spotware recommends deleting all excess Robots/Indicators - that doesn't work - as soon as you restart cALgo it re-downloads them again

Been watching the working set/private memory usage a good part of today - each instance is running around 40 indicators capturing rates - nothing else

* UK Win 2003 - 32 bt - WS 137 MB Private 350 MB
* US Win 2008 - 76 bit - WS 340 MB Private 280 MB

I still dont understand why the WS larger than private memory on Win 2008, but it looks like, memory wise, 2003 uses less resources to capture - given the rumoured improvement of Win 2008 over 2003 (VPS remember) i can't say which is best but am glad its this way - The IC Markets cAlgo is gonna have to move over at the end of this week - a new friend will be joining it - the Think cAlgo instance

BTW Hats off to CNS - no complaints about bandwidth usage yet - i did warn them in advance though
CNS VPS - it just works :-)
Post Reply

Return to “Indicators”