[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 405

 
hoz:
1. Why would it happen all of a sudden? We just need to add else, that function returned some more value, which would mean, "No price". Seems logical. When I was throwing the function, I was thinking more about previous logic, then I didn't pay attention to its end. And why the 0 function will return 0 by itself I don't understand something...

2. Why do I need Ask at all (if we're talking about the purchase price specifically), if I can always use MarketInfo(fs_symbol, MODE_ASK) ? After all, if you look at it this way, by referring to Ask, you can't be sure that it's accurate at a given point in time?

1. Simple. The function is declared as double, so when it is called, it will return double regardless of whether it calls return or not. If we add else... but we don't have this else yet.

2. If it makes no difference whether you press 3 keys or 30, you don't need these Bid and Ask. If Expert Advisor doesn't make long calculations, it's OK, it's convenient to use Bid and Ask. If it performs long calculations, you can use RefreshRates(). There are several ways of doing it.

 
hoz:


As far as I understand it, this is not what we need. And we need last Ask and Bid server prices, not local terminal ones. Right?

That's why I started the discussion here, to understand once and for all how to organise it more logically and correctly. For in theory this is correct, but in practice...

The server is somewhere out there, and we are given a terminal to contact the server. If there is a connection, then the last price in the terminal will correspond to the last price on the server. If there is no connection, then it doesn't matter what prices are there at all.

 
After executing the first or second if statement, I need to interrupt the following if statements and transfer control to a block with other trading criteria. Loops have an interrupt with the continue statement, but I need to interrupt the execution of a series of statements. How do I do this? Can you give me a hint?
 
Have you tried a break; have you tried a break?
 
Good afternoon. I am currently working on a diploma on trading robots. I don't need to reinvent anything very grandiose, because I'm an economist, not a programmer. But I had an idea, although I think it has occurred to many people, to connect parabolic sar and (since sar is not very good at flat) bollinger bands. Basically with standard settings, and buy, when candle touches bottom of BB (and parabolic moves below), and next one closes above previous (and parabolic moves further from price because of accel and shows trend). Same at the top when selling. It would be interesting to use trailing stop, the settings of which could be set manually... Does anybody happen to have a similar idea already in mql? or if anyone can help, because i would really like to really test it...thanks in advance
 
Integer:

1. Simple. The function is declared as double, so it will return double when called, regardless of whether return was called in it. If we add else... ...but that else isn't there yet.

2. If it makes no difference whether you press 3 keys or 30, you don't need these Bid and Ask. If Expert Advisor doesn't make long calculations, it's OK, it's convenient to use Bid and Ask. If it performs long calculations, you can use RefreshRates(). Everything can be done in several ways.

1. Yes, I'm just overworked so I must have written a silly thing...

2. Long is a relative term. Are you suggesting we measure the speed of the average calculation?

Integer:

The server is out there somewhere and we are given a terminal to contact the server. If there is a connection, then the last price in the terminal will correspond to the last price on the server. If there is no connection, it doesn't matter what price is on the server.

If we assume, as you have written, that the last value of variable market data (in our case, the price ) corresponds to the last server's value, then it means that terminal updates market environment variables if it has connection with the server. But it's not so, because this function exists and it means that prices are not refreshed all the time, right?

I'm not arguing, I'm asking, arguing my point of view. Please note that!

 
hoz:

If we assume, as you wrote, that the terminal has the latest value of market data variable, in our case price, corresponding to the latest server value, then it means that the terminal updates market environment variables itself if there is a connection with the server, which means that RefreshRates() function is not needed. But it's not so, because this function exists and it means that prices are not refreshed all the time, right?

I'm not arguing, I'm asking, arguing my point of view. Please note that!


If new ticks come in during calculations in the EA (when the start() function is running), the EA will not know about them (ticks). RefreshRates() allows using the latest updated prices, but this function doesn't access the server. It updates the market environment known to the terminal. None of the functions, except for trading, accesses the server
 
Vinin:

If new ticks come in during calculations in the EA (when the start() function is running), the EA will not know about them (ticks). RefreshRates() allows to use the latest, updated prices, but this function does not access the server. It updates the market environment known to the terminal. None of the functions, except for trading ones, accesses the server.

So if the request is local and not to the server, then this function should work instantly! As stated above, function RefreshRates() may not have time to update market environment data...
 
hoz:

So if the request is local and not to the server, then this function should work instantly! And above it was said that RefreshRates() function may not have time to refresh market environment data...

It does work. And it refreshes it if there is something to refresh. But if there was no new tick, there is nothing to update.
 
Vinin:

And it will work out. And it refreshes it if there is something to refresh. But if there is no new tick, there is nothing to update.


So if there's no new tick, the price won't change... and of course the previous prices will still be valid. So there is no need to complicate things!

And Vadim wrote at the top that it was necessary to check this point. But there was no logic in his words, and no argumentation either. It's strange... So, I insert RefreshRates() everywhere and at that moment the last known data from the terminal become usable instead of the previous ones and everything goes as it should. ProvidedRefreshRates() returned TRU. If it's False, it means that data hasn't changed and it works with previous prices... Am I reasoning correctly?

So I don't need to bother. Just callRefreshRates() and it will work with actual data...

Reason: