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
A cursory examination suggests it should work. But you could improve the efficiency.
Think about how many different objects you have drawn on your chart. If you click *any* of those objects, you are going to loop through every single order and try to find a match. Many objects probably have nothing to do with orders. This is inefficient.
Which is why I suggested checking the first character of sparam for "#". This automatically identifies the object as being related to an order.
Furthermore, there is no need to loop through the orders. The object name and/or the object text already contains the ticket number. So extract the ticket number from there and close the order
Example:
You open an order. It is given ticket number 12345
Create an OBJ_BUTTON with name "#12345"
The code in OnChartEvent() would be something like this (uncompiled, untested, late at night...):
{
int ticket=(int)StringSubstr(sparam,1); // extract the ticket number
if(OrderSelect(ticket,SELECT_BY_TICKET)) // select the order
{
if(!OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,CLR_NONE)) // close the order
{
Print("# Error ",GetLastError());
}
}
}
Wow! I did not know about that.
So, you mentioned twice, and I exactly did not figure out about that.
Now I will test it for myself and bring it to my main EA file.
Thanks so much more.
I use OrderTicket() for other objects, now I see when I click that objects - order close.
I liked you method, but looks like it's influence other objects.
Other objects name like this here is one of them.
Thanks in advance.
I use OrderTicket() for other objects, now I see when I click that objects - order close.
I liked you method, but looks like it's influence other objects.
Other objects name like this here is one of them.
Thanks in advance.
The more elegant solution is to change your naming system
Nevertheless, you can still strip out the order number. It just depends on the exact naming format.
But before all that, what is the OBJPROP_TEXT of the button? Do any other objects have the same OBJPROP_TEXT?
The more elegant solution is to change your naming system
Nevertheless, you can still strip out the order number. It just depends on the exact naming format.
But before all that, what is the OBJPROP_TEXT of the button? Do any other objects have the same OBJPROP_TEXT?
Yeah! I know I can change names of Button object names ( also I use Prefix ) if I change button names then I could change a lot of things, e.g delete system and other things which is all of them linked each others.
Below are Button and HLine names.
"#"+IntegerToString(OrderTicket())+" -"+"Object Button"
( of course, object names a little a bit more different, but same method )
Thanks in advance.
Market Closed
Maybe I found, but I am not sure.
If this is not good, please let me know.
Thanks in advance.
//--- 2nd times edited
Hey! Man!
Thanks a lot. So far no problems. Correctly works!
#Crossover Objects - Open
I several times faced this issue, sometimes I passed sometimes I gave up, now I would not like to give up once again.
I have 2 objects " HLine and Button " they crossovers, I mean when I click one of them, both selected this is not good thing for me. ( BUTTON Width = 20, HLINE Width = as you know )
Q: How can I do when I click BUTTON object HLINE object won't selected while they crossovers, please?
( I can easily select HLINE where they not crossover )
Thanks in advance.
( I am working on it, any good comment would be better, please. )
#Profit in Pips - Open | #Profit in Pips - Closed for now - I solved it
Mr. William - I use your " Pip, Point ... " calculation codes.
Now I try to get Profit in pips value with below codes. I have 2 orders, one of them shows correctly ( OP_BUY ), 2nd of them not shows correctly - 399 - actual 400 ( OP_SELL ).
Q: Am I doing wrong for profit in pips calculation, please?
Thanks in advance.
( last day I checked out forums in different websites - that was not beneficially for me )
Forum on trading, automated trading systems and testing trading strategies
MetaTrader 4 Build 574 with Updated MQL4 Language and Market of Applications Released
whroeder1, 2014.01.27 14:11
One of amazing " if " operator example of a complex condition from Mr. William.
Just thanks!
I struggled latest 2 days to fix my " if " operator complex condition, but I can't solve my issue until I found above great example.
Please someone help me, I really struggle to solve this issue.
#296
Thanks in advance.
Below code sometimes works perfect, sometimes not. I can't solve this issue. When I use single order, it works perfectly, but when I open multiple orders, this function does not work correctly.
Please help me, and a little a bit more explains ( that what is wrong at the below code ) that would be better for me.
( Now, I am working on it. )
{
ticketnumber=(int) StringSubstr(sparam,1);
if(OrderSelect(ticketnumber,SELECT_BY_TICKET))
{
if(StringFind(sparam,Button_1,0)>=0)
{
// ...
}
if(StringFind(sparam,Button_2,0)>=0)
{
//...
}
for(i=OrdersTotal()-1; i>=0; i--)
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
if(Symbol()!=OrderSymbol()) continue;
update_1();
update_2();
update_3();
}
}
}
Thanks in advance.