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
At least in method setters this is justified - the code may become more readable and compact, you get a la named parameters
ChartObject *hline=HLine::New(1.255).Color(clrGreen).Width(2).Selectable(true); // не надо помнить очерёдность параметров и можно писать в одну строку - цепочкой
// получается вот из подобного :
class HLine:public ChartObject {
public:
HLine(double price);
HLine *New(double _price) { return new HLine(_price); } // это чтобы не городить (new HLine(...)).Method1
HLine *Color(color _clr) { fgColor=_clr; return GetPointer(this); } // а это чтобы получались цепочки obj.Method1(..).Method2(..)
};
and a little bit interferes with the qualification of functions by the returned type.
Feel free to return GetPointer(this) from methods.
This way &this is more concise.
Well, let me start first.
To close an order, we do not have to define the order type and the price that corresponds to this type. It is enough to write "close at price" in OrderClosePrice()!
void OnStart()
{
int i, total = OrdersTotal()-1;
for(i = total; i >= 0; i--)
{
if(OrderType() < OP_SELLSTOP)
{
if(!OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 100))
printf("***********");
}
}
}/********************************************************************/
Pretty cool! ) Thank you.
Judging by the example, you don't need OrderSelect() either?
(Cool! ) Thanks.
Judging by the example, OrderSelect() isn't needed either?
Nice! ) Thanks.
Needed. Just missed it due to laziness...
Yeah, well... Really messed up.
But before, I didn't come across these topics.
So you can use OrderClosePrice only AFTER the corresponding OrderSelect. Since OrderSelect copies the data for Order(const)-functions once, and the same RefreshRates is not able to update them.
I.e. if, for example, OrderClosePrice fails to close, then you must do OrderSelect again before the next attempt (RefreshRates is not required).
ZS This thread is from 2005! There are detailed arguments from the developers here.
Open orders should be analysed from a higher number, i.e. for(int nom=OrdersTotal()-1; nom>=0; nom--)
This is especially important when deleting orders.
But what will happen if we do the opposite for(int nom=0; nom<OrdersTotal(); nom++) ?
At first, the index is equal to zero and the very first order with number 0 is deleted.
Then the index becomes equal to 1. At this point the remaining orders are shifted and the one with number 1
occupies the zero position. The former number 2 takes position 1. It will be deleted.
Then the index becomes 2. And the order which was number 4 at the beginning will be deleted.
Thus, the orders which occupy even-numbered positions at the beginning are deleted. The odd-numbered ones will remain. This can be seen in the comments to the orders and numbers.
I attach a script showing both options of deleting and screenshots
There are 20 pending orders
Deleted one by one