You need to write an advisor. I have an idea. - page 4

 
dimasik >>:
lascu.roman, ты можешь сделать чтобы ордера открывались не с рынка, а отложенниками??? Это важно, потому что брокер с рынка не принимает сразу установку SL и TP. Вот.

This is done in 2 steps.

1) Open on the market TP = 0, SL = 0

2) Modify SL, TP.

Or did I get it wrong?

 
meta-trader2007 >> :

Actually this TS is profitable on H1 timeframes and higher (but not always, and sometimes - during a no-trend).

The main thing is not to use TP and trawl has to be 3 or more times of stop.

i must have been testing in the wrong place =)

 
GarF1eld >> :

It's done in 2 steps.

...

Or did I get it wrong?

Better to change the DC to a normal one.

maybe i was testing in the wrong place =)

You have to test on a shoddy story)

And here's how on the checkpoints:


 
I've got a bit of an issue.)
 
meta-trader2007 >> :

It is better to change the DC to a normal one.

You have to test on a poor quality story)

This is how on the checkpoints:


Could you add to the Expert Advisor on pending orders to delete previous orders when the next pair of orders is opened?

It would be very good...and the trade flow would not be clogged...the 418 errors are coming up

 
And delete when one of the already open ones is triggered)
 
extern bool Limits = TRUE; // TRUE - LIMIT orders; FALSE - STOP orders
extern double Distance = 10; // Probably less than zero
extern double TP = 144;
extern double SL = 55;
extern double TralSL = 34;
extern double Lots = 0.1;

double Spread;

void init()
{
  Distance *= Point;
  TP *= Point;
  SL *= Point;
  TralSL *= Point;
  
  Spread = Point * MarketInfo(Symbol(), MODE_SPREAD);
  
  return;
}

void TrailingOrders()
{
  int i, Total = OrdersTotal();
  double Difference, tp, sl;
  
  for ( i = 0; i < Total; i++)
  {
    OrderSelect( i, SELECT_BY_POS);
   
    if (OrderType() == OP_BUY)
    {
      sl = Bid - TralSL;
      Difference = NormalizeDouble( sl - OrderStopLoss(), Digits);
        
      if ( Difference > 0)
      {
        sl = NormalizeDouble( sl, Digits);
        
        OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0);
      }
    }
    else if (OrderType() == OP_SELL)
    {
      sl = Ask + TralSL;
      Difference = NormalizeDouble( sl - OrderStopLoss(), Digits);
        
      if ( Difference < 0)
      {
        sl = NormalizeDouble( sl, Digits);
       
        OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0);
      }
    }
  }
  
  return;
}

bool OrderScan( int TypeOrder )
{
  int i, Total = OrdersTotal();
  
  for ( i = 0; i < Total; i++)
  {
    OrderSelect( i, SELECT_BY_POS);
    
    if (OrderType() == TypeOrder)
      return(TRUE);
  }
  
  return(FALSE);
} 

void MyOrderSend( int TypeOrder, double open, double sl, double tp )
{
  if ( OrderScan( TypeOrder))
    OrderModify(OrderTicket(), open, sl, tp, 0);
  else
    OrderSend(Symbol(), TypeOrder, Lots, open, 0, sl, tp);
      
  return;
}

void OpenOrders( double H, double L )
{
  double open, tp, sl;
  
  if ( Limits)
  {
    if (! OrderScan(OP_BUY))
    {
      open = NormalizeDouble( L - Distance + Spread, Digits);
      tp = NormalizeDouble( open + TP, Digits);
      sl = NormalizeDouble( open - SL, Digits);
  
      MyOrderSend(OP_BUYLIMIT, open, sl, tp);
    }
  
    if (! OrderScan(OP_SELL))
    {
      open = NormalizeDouble( H + Distance, Digits);
      tp = NormalizeDouble( open - TP, Digits);
      sl = NormalizeDouble( open + SL, Digits);
  
      MyOrderSend(OP_SELLLIMIT, open, sl, tp);
    }
  }
  else
  {
    if (! OrderScan(OP_BUY))
    {
      open = NormalizeDouble( H + Distance + Spread, Digits);
      tp = NormalizeDouble( open + TP, Digits);
      sl = NormalizeDouble( open - SL, Digits);
  
      MyOrderSend(OP_BUYSTOP, open, sl, tp);
    }

    if (! OrderScan(OP_SELL))
    {
      open = NormalizeDouble( L - Distance, Digits);
      tp = NormalizeDouble( open - TP, Digits);
      sl = NormalizeDouble( open + SL, Digits);
  
      MyOrderSend(OP_SELLSTOP, open, sl, tp);
    }
  }
  
  return;
}

void start()
{
  static int PrevTime = 0;

  TrailingOrders();
  
  if ( PrevTime == Time[0])
    return;
    
  PrevTime = Time[0];
  
  OpenOrders(High[1], Low[1]);
  
  return;
}


mpeugep, post your test results here.

 

ran these EAs on demo, orders are not being placed.... What is the reason?

 
dimasik >> :

ran these EAs on demo, orders are not being placed.... What is the reason?

Pending orders are placed at the beginning of the formation of a new bar, provided there are no corresponding open positions.

Write here about the positive results of the tester with the stack attached.

 

When I tested the exp_Higt-Low.mq4 expert in realtime on the DAX demo (for 5 hours), at first it showed a profit, and then it started to lose.

I have only one thing to say - it is possible to work in this direction. The only problem is that my Expert Advisor tries to load a trade flow with pending orders, that is why it has a task to close pending orders, for example, when one of the pending orders triggers or when a new pair of pending orders opens.

to mql4com

could you add the exp_Higt-Low.mq4 that meta-trader2007 posted earlier as I described above?

I will continue testing tomorrow.