Asset traded only few hours a day

Posted By: MatPed

Asset traded only few hours a day - 03/10/17 13:20

Hi,
is there a way to test in advance if the selected asset is tradable before opening a trade?

I know that I can check if I am within the market hours but it deals to an hard to be maintained c code in a multiasset script.

Thank you
Posted By: Veli

Re: Asset traded only few hours a day - 03/14/17 08:46

Hi MatPet smile

I'm checking for the trading hours of the market insinde the asset loop with an if statement. I don't think that the code is hard to maintain. But i may have missend an issure with it. In this case i'd be happy to get informed wink

Code:
function run()
{
	int start = 0;
	int end = 0;
	
	while(asset(loop("GER30", "SPX500")))
	{
		if(Asset == "GER30")
		{
			start = 900;
			end = 1700;
		}
		else if(Asset == "SPX500")
		{
			start = 1100;
			end = 1900;
		}
		
		if(ltod(CET) >= start && ltod(CET) <= end)
		{
			yourStrategy();
		}
	}
}



If there is a better way i'd also like to know smile

Best wishes

Veli
Posted By: MatPed

Re: Asset traded only few hours a day - 03/14/17 13:02

Ciao,
my script is based on 13 assets on different time frames, and I am doing something similar to your code, but what happen, for instance, if the market is closed for an national holiday during a trading day?
Your code, as mine, is not able to track that event. Having the opportunity to check if an asset is tradable right before to open a position could help a lot.

In Multichart the trading time is listed in the platform, so I guess that could be possible to gather such information from the broker.
I hoped this could be possible in Zorro.

Naturally nobody can guarantee that your order will be 100% executed, but this will reduce the number of exceptions.

Ciao
Posted By: Veli

Re: Asset traded only few hours a day - 03/20/17 12:44

You're right. These are indeed problems with the solution.
I would be happy for a different one aswell wink

If i one day stumble across a better solution, I'll inform you and would be happy, if you would do the same wink

Until then i've not given up hope that one of the really clever members of this forum writes an answer to this Thread laugh
© 2024 lite-C Forums