Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1576

 
Sergei Gurov #:
Hello, I need to create a rectangle via mouse clicks on a graph. I understand how to define the first point. By using lparam. But when I make a click for the second time, the first and the second point are the same. Can you tell me how to make it so that the first click was with one price, and the second click was already with a different price (I.e. they should not be equal)
Now my code looks like this:
Logically, I realise that it won't work the way I need it to. But I don't have enough programming knowledge to solve this problem
And how to define the next points if there will be more than 2 clicks on the chart? For example 3 or 5

if there is no object - when clicking, create a rectangle with the upper right corner on the mouse cursor, switch to the "markup" mode.

if there is an object and "markup" mode - 1) when moving or clicking the mouse, change the size of the rectangle so that the lower left corner is on the mouse cursor 2) when clicking - end "markup" mode

The "markup" mode (the rectangle is marked or not) can be stored in EA variables or object properties.

 

Hi Comunnity, can help me with this problem please, thanks

void OpenTrade(int order_type, double tp_points, double sl_points)
  {
   // Obtener el precio según el tipo de orden
   double price = (order_type == ORDER_TYPE_BUY) 
                  ? SymbolInfoDouble(Symbol(), SYMBOL_ASK) 
                  : SymbolInfoDouble(Symbol(), SYMBOL_BID);

   // Calcular Take Profit (TP) y Stop Loss (SL) con paréntesis claros
   double tp_price = (order_type == ORDER_TYPE_BUY) 
                     ? (price + (tp_points * Point))
                     : (price - (tp_points * Point));

   double sl_price = (order_type == ORDER_TYPE_BUY) 
                     ? (price - (sl_points * Point))
                     : (price + (sl_points * Point));

')' - open parenthesis expected 94 51

')' - open parenthesis expected           95  51

')' - open parenthesis expected 98 51

')' - open parenthesis expected 99 51

4 errors, 0 warnings 5 1


 

I am trying to make a new code.
I need the code to delete all the pending orders in each new candela, but it is not working

my code is sending new pending order in each candela
buy limit
sell limit
buy stop
limit stop
 and I need it to delate them before sending the new one.
it is not deleting at all. any one can help me?!
i am using MQL5

 
abuqies #:

I am trying to make a new code.
I need the code to delete all the pending orders in each new candela, but it is not working

my code is sending new pending order in each candela
buy limit
sell limit
buy stop
limit stop
 and I need it to delate them before sending the new one.
it is not deleting at all. any one can help me?!
i am using MQL5

#include <Trade/Trade.mqh> // Include the trade library to access trading functions
CTrade trade; // Create an instance of the CTrade class for managing trades

// . . .
// Example usage in your code
// if(CloseAllOrders()){   // Check if all pending orders have been closed successfully
//    YourOpenOrdersCode(); // Proceed with opening new orders or other logic
// }
// Rest of your code . . .

// Function to close all pending orders
bool CloseAllOrders(){
   // Loop through all orders in reverse order (from the last to the first)
   for(int i=OrdersTotal()-1; i>=0; i--){
      // Select the order using its ticket number
      if(OrderSelect(OrderGetTicket(i))){
         // Attempt to delete the selected order using the trade object
         trade.OrderDelete(OrderGetTicket(i));
      }
   }

   // Check if all orders have been successfully closed
   if(OrdersTotal()==0){
      return(true); // Return true if there are no more orders
   }else{
      return(false); // Return false if some orders still remain
   }
}
 

Good afternoon! The problem is as follows: a series of orders is closed.

I need to know what their final profit (profit, swap, commission) is.

Is it enough to select the last trade from the history and get data from it?

 

Hi everyone,

I’m setting up my friend’s MT5 account to copy my trades. However, whenever I activate my strategy on his MT5, all my current open positions are immediately copied into his account. This isn’t ideal, as these trades are executed at different prices, resulting in poor timing and increased risk for him.

What I’m looking for is a way to ensure that only new trades (opened after the subscription starts) are copied to his account, without syncing the existing open positions from my account.

Has anyone faced this issue before? If so, how can I stop MT5 copy trading from syncing current open trades when subscribing to a signal?

Thanks in advance for your help!

 
Daniel Steven Ogden # :

Hey, everybody,

I am setting up my friend's MT5 account to copy my trades. However, whenever I activate my strategy on his MT5, all my current open positions are immediately copied to his account. This is not ideal, as these trades are at different prices, which causes timing issues and increased risk for him.

I am looking for a way to make it so that only new trades (opened after the subscription started) are copied to his account, without synchronising existing open positions from my account.

Has anyone encountered this problem before? If so, how can I prevent MT5 copy trading from synchronising current open trades when subscribing to a signal?

Thanks in advance for your help!

You need to pass the open time of the positions and if it is older than 60 seconds = do not copy it

 
Daniel Steven Ogden #:

Hey, everybody,

I am setting up my friend's MT5 account to copy my trades. However, whenever I activate my strategy on his MT5, all my current open positions are immediately copied to his account. This is not ideal, as these trades are at different prices, which causes timing issues and increased risk for him.

I am looking for a way to make it so that only new trades (opened after the subscription started) are copied to his account, without synchronising existing open positions from my account.

Has anyone encountered this problem before? If so, how can I prevent MT5 copy trading from synchronising current open trades when subscribing to a signal?

Thanks in advance for your help!

It is unlikely that you will be able to forbid it. Perhaps the only way is to wait until all positions are closed. Usually on Friday before the weekend they close them to avoid increased risks if they are not long-term positions. In this case, start copying on the weekend.

 
I have completed my code.  Do I need another platform that integrates with MT4/MT5 to send signals or automate my trades.  I am using Pine Connector, but they haven't been very helpful, and reviews aren't the best. I attempted to send test signals...no trades and it has taken trades in 48hrs.
 
Tabby72 Rowland #:
I have completed my code.  Do I need another platform that integrates with MT4/MT5 to send signals or automate my trades.  I am using Pine Connector, but they haven't been very helpful, and reviews aren't the best. I attempted to send test signals...no trades and it has taken trades in 48hrs.

so.. where are you planning to send the signal?