HOW to get a programmer 100% interested in writing an EA based on your IDEA - page 11

 

Or organise an adjustable take profit setting in this EA.

Here's the full code.

 
//+------------------------------------------------------------------+
//|                                                         Gray.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
 
extern double lot=1;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  int tiket=0;
//----
if (iVolume(NULL,0,0)==1){
    Print("WATR1="+iCustom( NULL, 0, "WATR", 0, 0) );
    Print("WATR2="+iCustom( NULL, 0, "WATR", 1, 0) );
    
    if (iCustom( NULL, 0, "WATR", 0, 2)<1000 && iCustom( NULL, 0, "WATR", 1, 1)<1000) {tiket =OrderSend(Symbol(),OP_SELL,lot,Bid,3,iCustom( NULL, 0, "WATR", 1, 0),0,NULL,16384,0,Red);}
    if (iCustom( NULL, 0, "WATR", 1, 2)<1000 && iCustom( NULL, 0, "WATR", 0, 1)<1000) {tiket= OrderSend(Symbol(),OP_BUY,lot,Ask,3, iCustom( NULL, 0, "WATR", 0, 0),0,NULL,16384,0,Green);}
    CheckOrders();
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
}
void CheckOrders(){
int pos=0;
int total=OrdersTotal();
for (pos=0;pos<total;pos++) {
if (OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true){ 
if (OrderType()==OP_BUY && OrderStopLoss()<iCustom( NULL, 0, "WATR", 0, 1))OrderModify(OrderTicket(),OrderOpenPrice(),iCustom( NULL, 0, "WATR", 0, 1),OrderTakeProfit(),0,Green);
if (OrderType()==OP_SELL && OrderStopLoss()>iCustom( NULL, 0, "WATR", 1, 1))OrderModify(OrderTicket(),OrderOpenPrice(),iCustom( NULL, 0, "WATR", 1, 1),OrderTakeProfit(),0,Red);
                                                                                   }
                                                          }
                                      }
 
Ultramarin:

Or organise an adjustable take profit setting in this EA.

Here's the full code.

Have you tried it?
 
Registr:
Ultramarin:

Or organise an adjustable take profit setting in this EA.

Here is the full code.

Have you tried working?
If this is the full EA code, then Registr has given you the best advice.
 

I can add a few remarks now

1. the return(0) operator belonging to the start function should at least be duplicated below one curly bracket. Since it will only be executed if the condition for volume of 1 is met.

the rest of the time the start function should close incorrectly.

the 2 conditions of the value from the called indicator <1000 is probably the idea to show that on the bar there is no one value from the buffers

i.e. a sort of crossing (change of indicator colour and its relative position relatively to the current price)

i'm afraid that in this case it will work only for those symbols with the current price value greater than 1000 (for example, PDR)

if the indicator draws only one colour on the current bar (the value of another buffer on this bar is 0)

Otherwise on almost any currency pair the current value of the indicator will always be less than 1000, and the conditions will trigger on every bar

3. I recommend to take the condition of a new bar as follows


int time;
 
int start
   {
      if (time!=Time[1])
         {
            // расчет индикатора и выполение действий с ордерами
            //-----
            //-----
            //-----
            //-----
            time=Time[1];
 
         }
       return(0);
   }



 
olyakish:

I can add a few remarks now

1. the return(0) operator belonging to the start function should at least be duplicated below one curly bracket. Since it will only be executed if the condition for volume of 1 is met.

the rest of the time the start function should close incorrectly.

the 2 conditions of the value from the called indicator <1000 is probably the idea to show that on the bar there is no one value from the buffers

i.e. a sort of crossing (change of indicator colour and its relative position relatively to the current price)

i'm afraid that in this case it will work only for those symbols with the current price value greater than 1000 (for example, PDR)

if the indicator draws only one colour on the current bar (the value of another buffer on this bar is 0)

Otherwise on almost any currency pair the current value of the indicator will always be less than 1000, and the conditions will trigger on every bar

3. I recommend to take the condition of a new bar as follows


You'd better tell him which keys to press... :)
 

Oh, and here's another thing.

4. Calling the custom indicator 12 times is blasphemy at the very least :)

in your case, 6 times will be enough (I counted that many times)

The processing speed of your EA will grow not by twice, but by 1.5 times in my opinion. These actions only (code optimization), not to be confused with optimization of parameters


//+------------------------------------------------------------------+
//|                                                         Gray.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        https://www.metaquotes.net |
//|                                   обработал напильником olyakish |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "https://www.metaquotes.net"
 
extern double lot=1;
extern string rem01="Профит в пунктах от текущей цены";
extern int TP=100;
 
int time;
double WATR[2,3];// первое измерение - индекс буфера; второе измерение - индекс бара 
 
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   int tiket=0;
 
   if (Time[1]!=time)
      {
         WATR[0,0]=iCustom( NULL, 0, "WATR", 0, 0);
         WATR[1,0]=iCustom( NULL, 0, "WATR", 1, 0);
         WATR[0,1]=iCustom( NULL, 0, "WATR", 0, 1);
         WATR[1,1]=iCustom( NULL, 0, "WATR", 1, 1);
         WATR[0,2]=iCustom( NULL, 0, "WATR", 0, 2);
         WATR[1,2]=iCustom( NULL, 0, "WATR", 1, 2);         
         Print("WATR1=",WATR[0,0]);
         Print("WATR2=",WATR[1,0]);
    
         if (WATR[0,2]>0 && WATR[1,1]>0) // проверить это место (правильно ли будет направелние  открытия по индикатору)
            {
               tiket= OrderSend(Symbol(),OP_BUY,lot,Ask,3,WATR[0,0],Bid+TP*Point,NULL,16384,0,Green);
            }
         if (WATR[1,2]>0 && WATR[0,1]>0) // проверить это место (правильно ли будет направелние  открытия по индикатору)
            {
               tiket =OrderSend(Symbol(),OP_SELL,lot,Bid,3,WATR[1,0],Ask-TP*Point,NULL,16384,0,Red);                           
            }
         CheckOrders();
         time=Time[1];
      }
   return(0);
  }
//+------------------------------------------------------------------+
void CheckOrders()
   {
      int pos=0;
      int total=OrdersTotal();
      for (pos=0;pos<total;pos++) 
         {
            if (OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true)
               { 
                  if (OrderType()==OP_BUY && OrderStopLoss()<WATR[0,1]){OrderModify(OrderTicket(),OrderOpenPrice(),WATR[0,1],OrderTakeProfit(),0,Green);}
                  if (OrderType()==OP_SELL && OrderStopLoss()>WATR[1,1]){OrderModify(OrderTicket(),OrderOpenPrice(),WATR[1,1],OrderTakeProfit(),0,Red);}
               }
         }
      return(0);  // на самом деле нужно просто return но так вроде писать нельзя ...
    }
//+------------------------------------------------------------------+

At least like this

Check



 
Unfortunately, it doesn't work.
 

Can someone explain

There are two identical EAs with absolutely identical parameters

One buys at the same time another sells at the same time

Entry and exit moments are the same

How do they both vanish cleanly?

 
Ultramarin:

How can they both merge cleanly ?

On the spread.