[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 824

 
eugggy:
I'm not asking you to write me an EA, I originally asked for a couple of lines about closing, if it's not difficult, respectively if it's difficult, then don't. What is the problem?


Well, it's not a couple of lines, it's a couple of functions. Three functions, to be exact. Each one does its own thing.

Each function has a minimum of five lines.

 
eugggy:
Well, just say there's no time, I don't know how many lines such a block would take. Anyway, thanks for the tips, I'll try to make something up myself.

That's what I said I'd do tomorrow. Why be offended?
 
eugggy:
Well, just say there's no time, I don't know how many lines such a block would take. Anyway, thanks for the tips, I'll try to make something up myself.

Judging by the code presented and then deleted, it's already screwed up.
 
eugggy:
Do you think we were surprised? - No. There's nothing to see in it, I told you, all I need is removal.


// check for open orders
int n=0; // number of open orders
for (int i=OrdersTotal()-1; i>=0; i--)
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
if(OrderType()==OP_BUYSTOP) n++;
if(OrderType()==OP_SELLSTOP) n++;
}
if(n>0 && n<OrdersTotal()) // check for pending orders if open
for (i=OrdersTotal()-1; i>=0; i--) // delete pending orders
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
if(OrderType()==OP_BUYSTOP) OrderDelete(OrderTicket());
if(OrderType()==OP_SELLSTOP) OrderDelete(OrderTicket())
if(OrderType()==OP_BUYLIMIT) OrderDelete(OrderTicket());
if(OrderType()==OP_SELLLIMIT) OrderDelete(OrderTicket());
}

Code in first approximation. Further it is modified, simplified and made more complicated by the task. There are a lot of approaches.

 
eugggy:
Thanks, I'll give it a try.

No. You should write down in words what each line does in your code and you will see for yourself
 
eugggy:
Well, just say there's no time, I don't know how many lines such a block would take. Anyway, thanks for the tips, I'll try to make something up myself.
Go here. You will learn from Igor Kim who has done everything for you. You may learn a lot and find a ready-made code for yourself.
When you're good at it, you'll be able to write everything yourself.
I highly recommend it to start with.
 
artmedia70:
Go here. It's a long time since Igor Kim did all the work for you. You'll learn a lot and find ready-made code for yourself.
When you're good at it, you'll be able to write everything yourself.
I highly recommend it to start with.
That's a good idea... I did it too, when I started mastering the language...
 
keekkenen:
That's a very good point... I did it too when I started learning the language...
But it was clear that the man was "buried". You should have suggested it right away instead of arguing about it...
Everyone starts somewhere...
 
eugggy:

Yes, a lot of useful stuff. I could have done without the freebies, but the textbook is very intricately written.
The textbook is brilliantly written. 5+ You should read Stroustrup's books on c++ and be amazed :)
 
eugggy:

Well, for those who know what c++ is, it might be awesome, but for me it's a bit complicated:) It's not even about all those functions and operands, it's about the way they're spoken: nobody talks like that nowadays, so it's harder to understand. Example: "as a result of operator execution" is already stressing me out, why not say "when the operator is executed". So I'd say the textbook is written with an A.

Yeah, they talk like that nowadays, it would make Ellochka the Ogre. Pay attention to the examples, i.e. program codes, their completeness, simplicity, brevity. If you have problems with the basics of programming, in my opinion, the best textbook is the 1986 high school textbook on computer science.
Reason: