Close the first position MQL4 - page 2

 
TeeZai:

Hi @ghobar

How would you want to treat the 2nd position?

Let it continue run? Or close with 10pips profit?

TeeZai:

Try:

Sorry for the delay

The second sale is closed based on another strategy

The problem in the first position is that if each position was in the first position of its kind, ie (buy or sell) it would close if it was in 10 pips of profit.

It confuses me a lot

Unfortunately, the guide you gave closes any position that is above 10 pips in profit in the same way

Global thanks.

 
What solution do professors suggest for this problem ???
 
ghobar: The second sale is closed based on another strategy
enum Strategy{ STRATEGY_A, STRATEGY_B};
input MagicNumberBase = 20210511; // MagicNumber
#define MAGIC_NUMBER_A (MagicNumberBase+STRATEGY_A)
#define MAGIC_NUMBER_B (MagicNumberBase+STRATEGY_B)
Filter your Order Select loops by Magic Number and Symbol.
 
Mehmet Bastem:


int  FirsOrderClose=0;


If you get this piece of code at the beginning of the program, you will get the result you want

Thank you very much for your masterful guidance

I acted on your instructions but did not receive an answer.

//+------------------------------------------------------------------+
//|                         EURUSD EA.mq4                            |
//|        Copyright 2020, AbdullRahim Ghobar(Golden_Dimonds)        |
//|        https://www.mql5.com/en/signals/910701#!tab=account       |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, AbdullRahim Ghobar(Golden_Dimonds)"
#property link      "https://www.mql5.com/en/signals/910701#!tab=account"
#property version   "2.20"
#property strict
//+------------------------------------------------------------------+

int  FirsOrderClose=0;

//+------------------------------------------------------------------+
void Trail2()
  {
    int total = OrdersTotal();
   for (int i=0; i<=OrdersTotal(); i++)
     {
      if(OrderSelect(i-0,SELECT_BY_POS)==true)
      int type   = OrderType();

      bool result = false;
// Buy
      if(
         OrderMagicNumber()==Magic1
         &&
         (((Bid-OrderOpenPrice())/Point)>100)
         &&
         OrderType()==OP_BUY
         && FirsOrderClose==0
      )
         {
         result = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, CLR_NONE);
         FirsOrderClose=1;
         break;
         }

 
TeeZai:

Try:

Thank you very much for your masterful guidance

I acted on your instructions but did not receive an answer

 
William Roeder:
Filter your Order Select loops by Magic Number and Symbol.

Hi My system is based on Martingale and has 2 close strategies

First »The first position is closed based on a profit margin of 10 pips (TP)

I do not have a problem with this because the profit is closed with 10 pips

But the next positions open without profit limit and when the signal indicator leaves, all positions close.

The problem arises when the first position closes with 10 pips (TP) of profit and the second position takes the first place, but the profit limit is

Here the second strategy must have 2 positions up to close I want every position to be closed in the first position at any time, if there is a profit of 10 pips.

An example of my  close code 

//+------------------------------------------------------------------+
//|                         EURUSD EA.mq4                            |
//|        Copyright 2020, AbdullRahim Ghobar(Golden_Dimonds)        |
//|        https://www.mql5.com/en/signals/910701#!tab=account       |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, AbdullRahim Ghobar(Golden_Dimonds)"
#property link      "https://www.mql5.com/en/signals/910701#!tab=account"
#property version   "2.20"
#property strict

input int step=1;  //steps to change distance
double disbuy=0;
double dissell=0;
bool closebuy3=false;
bool closesell3=false;

//+------------------------------------------------------------------+

int start()
  {

  if(Volume[0]<=1)
  
  {
  if(Orders1()==100) 
{
disbuy=Distance;
dissell=Distance;
closebuy3=false;
closesell3=false;
if(BuysTotal()>step)
{
 disbuy=Distance1;
 closebuy3=true;
 }

///////////////////////////////////////////////////////////////// 3,3,3,5,30 ///////////////////////////////////////
 
        double bb1_shift10=iCustom("EURUSD",0,"Future Volume",3,2,5,3,30,true,false,false,false,Blue,Red,233,234,1,4,0,0);
        double bb1_shift11=iCustom("EURUSD",0,"Future Volume",3,2,5,3,30,true,false,false,false,Blue,Red,233,234,1,4,1,0);
  
       if(bb1_shift11!=EMPTY_VALUE&&closebuy3)
       {
       close3(Magic3);
       
        }
       if(bb1_shift10!=EMPTY_VALUE&&closesell3)
       {
       close3(Magic4);
               }  

 }
}
          Trail2();
         return(0);
  }
 

Hello to all professors

Is it possible for me to provide more guidance in this case ???

 
ghobar:

Hello to all professors

Is it possible for me to provide more guidance in this case ???

I tried different methods to solve this issue But I could not get the desired result.
 
ghobar:
I tried different methods to solve this issue But I could not get the desired result.

We could not solve this problem

But another solution seemed to me to give the profit margin of the first position to the next positions

With this solution, it can be said that the problem will be solved.

Thanks to those who contributed to this post

return();


Reason: