Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 219
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
It is all absolutely, but according to the type of chart on which the script is based, so that the script should be as simple as possible. I do not use Expert Advisors, I am only trialling now, I do not plan any activities in my life in the next month, that is why I decided to take a look at forex.
So it is the processing of trading errors that makes the difference between a good script and a tutorial in this case. Do you want to learn from it or do you want it to work 100%?
If you just want the principle, here it is:
It closes both Buy and Sell.
There is absolutely no error handling. You may close only Buy or only Sell for yourself - remove one line.
Well... only Buy:
For Sell:
Thank you very much. That's just what I need. But what are red and blue and what is it for, it probably shows the reset point of each order, right? When I try it, I will add it to codebase at once by artmedia70. And by the way, why do we need processing of a normal if the script is accurate and the developer is confident in it?
And maybe I do not need to add them by the way and the developer himself that is artmedia70 will add to the codebase, they will turn out to be needed there, and I have no account there, and to the comments will not be able to answer a word, eh?
Thank you very much. But that's just what I need. But what are red and blue and what is it for, it probably shows the reset point of each order, right? When I try it, I will add it to codebase at once by artmedia70.
No, not in the codebase, not in any way. I'm used to making reliable things, not tutorials :)
If I had shown you a normal script, you would have told me that I, like everyone else, wrote all sorts of 'errors' again... But... you can't do without them. This is work with our money.
Blue and Red are the colour of the closure mark.
No, there's no need for a catbase. I'm used to making reliable things, not tutorials :)
If I showed you a normal script, you'd tell me that I, like everyone else, wrote all sorts of rip-offs again... But... you can't do without them. This is a job with our money.
Blue and Red are the colour of the closing icon.
By the way, why do you need to process a regular script if it is clear and the developer is confident in it?
The developer will only be confident in his program if his program will handle the errors returned by the trading server. If no error handling is done, the program may stumble at the first error. The error is NOT a program error, but an error returned by the trade server. For example - the above script does not get fresh data. So the server may return an error about the wrong price. For this, one should try to receive the most recent trade environment before closing - please execute RefreshRates() command or, instead of the Ask or Bid closing price, use the price obtained using MarketInfo(Symbol(),MODE_ASK) or MarketInfo(Symbol(),MODE_BID);
Then the script will take this form (for Sell):
And if you try to process other errors returned by the server, it will grow to those values when you say - "you've done it again..." :)
Now I get it and yes, it's important. The internet is no good here, the hardware is young too, so it's not really wise to rely on them for the full two hundred percent, but risk is a noble thing =) but thanks again for the addition, I will add it to both buy and sell.
Is it right for buy?
void start() {
string sy=Symbol();
int i, k=OrdersTotal()-1;
for (i=k; i>=0; i--) {
if (OrderSelect(i,SELECT_BY_POS)) {
if (OrderSymbol()!=sy) continue;
if (OrderType()==OP_BUY) {
double pp=MarketInfo(sy,MODE_BID);
OrderClose(OrderTicket(),OrderLots(),pp,5,Blue);
}
}
}
return;
}
And if I need to remove only 3 buy orders out of 5 buy ones out of all available, which value is the biggest, will the script get bigger in size? And one more question, if I'm not bothering to ask, because these checks take all the time, I wonder which script has a higher probability of slippage than the one with checks or the one without checks for errors?
Now I get it and yes, it's important. Internet is no good here, it's a fact, hardware is young too, so it's not really wise to rely on them for the full two hundred percent, but risk is a noble thing =) but thanks again for the addition, I will add it to both buy and sell.
Is this correct for buy?
Yes. But that is not all... ;)
This script, in addition to unprocessed similar errors, will also touch "alien" orders. I.e., if you have an EA working on this symbol, the script will close its positions, and the EA will open them again. This is how they will "fight" with each other.
To avoid this, it is necessary to limit the script in terms of magic. I.e., add a line if (OrderMagicNumber()>0) continue; then the script will only work with orders opened manually.
For Sell:
And there is a lot more to refine for "normal" reliability. It will come in time, don't doubt. ;)
Yes. But that's not all... ;)
This script, apart from the remaining unprocessed similar errors, will also touch "alien" orders. I.e., if you have an EA working on this symbol, the script will close its positions, and the EA will open them again. This is how they will "fight" with each other.
To avoid this, it is necessary to limit the script in terms of magic. I.e. add a line if (OrderMagicNumber()>0) continue; then the script will only process manually opened orders.
can you write: a script/advisor to close two opposite orders for profit in n*pips?
With this kind of request here