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

 
Can you tell me how to close part of the profit (e.g. 50% of an open trade)?
 
kostural:
Please tell me how to close part of the profit (for example: 50% of the open trade) ?

Lot = NormalizeDouble(OrderLots()/2,Digits);
 
Good evening! I don't see a match when two buffers are equal to each other!!!! The code is simple.
for(int A=1;A<300;A++ ){  
 
 if ( buf1[]== buf2[]){Print ( "  СОШЛОСЬ!!!!!!!!!!!!   " , " buf1[A]  " ,  buf1[A]   ,  " buf2[A]  " , buf2[A]  , "  A  " ,   A  );}  }
 
You can see that there is definitely a match on the graph! Maybe I'm approaching the question in the wrong way? And you have to somehow remember where one buffer is smaller and where the other one is already? I wrote, even approximated how. But what is missing in the code?
 
Dimka-novitsek:
Good evening! I don't see matches when two buffers are equal to each other!!!! The code is simple. You can see that there is definitely a match on the graph! Maybe I'm approaching the question in the wrong way? And you have to somehow remember where one buffer is smaller and where the other one is already? I wrote, even approximated how. But what is missing in this code?

https://www.mql4.com/ru/search#!keyword=%D0%A1%D1%80%D0%B0%D0%B2%D0%BD%D0%B5%D0%BD%D0%B8%D0%B5%20%D0%B4%D0%B5%D0%B9%D1%81%D1%82%D0%B2%D0%B8%D1%82%D0%B5%D0%BB%D1%8C%D0%BD%D1%8B%D1%85%20%D1%87%D0%B8%D1%81%D0%B5%D0%BB
 

Good evening, could you please tell me how to close the counter orders?

 
Dimka-novitsek:
Good evening! I don't see matches when two buffers are equal to each other!!!! The code is simple. You can see that there is definitely a match on the graph! Maybe I'm approaching the question in the wrong way? And you have to somehow remember where one buffer is smaller and where the other one is already? I wrote, even approximated how. But what does the given code lack?
The code lackseverything , but the programmer lacks knowledge and attention/intelligence, otherwise he/she (the programmer) would have long ago paid attention to the search line, documentation, tutorials and maybe visited the branch for beginners which tells how to correctly handle floating point numbers. Instead of trying to learn how to "build a bicycle" by anti-scientific groping.
 
Ruslan1:

Good evening, could you please tell me how to close the counter orders?

https://docs.mql4.com/ru/trading/OrderCloseBy

 

Hello, I have a problem. I am learning to write in MQL and decided to try to write a simple Expert Advisor based on exponential moving average just for practice. The trades open as expected but for some reason at some point the deal is closed and the history shows the deal was closed with StopLoss but its value is not equal to what was originally set. Please help me to understand what is wrong. All work with trades in a piece of code below.

if(total<1)
{
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}

if (MaCurrent < Close[2] && MaPrevious > Close[3] && (Close[1] > Close[2]+70*Point || Close[0] > Close[2]+70*Point))
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,
"EMA",16385,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}

if (MaCurrent > Close[2] && MaPrevious < Close[3] && (Close[0] < Close[1]-70*Point || Close[0] < Close[2]-70*Point))
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,
"EMA",16385,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}


}

return(0);
}

 


Thank you! I'll give it a try.

 
7777877:

Good afternoon. PEOPLE, ANSWER THE QUESTION PLEASE (3rd time posting). A question about a file pointer...

It would have been a long time ago to parse a text file, how it is structured, what it consists of. Unprint the cursor position after each line reading using
int FileTell( int handle)
Everything will become clear at once.