Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 815

 
CJIeCaPb:

I inserted a message and error handling into the while (true) loop. The loop works, message is written, no errors. But it does not pass the condition, the data are not updated.

Here are some more hints.

This cycle does not consider all orders; besides, if there are more than one order of one type (for example, three bystop orders are placed), then what will happen?

for(i=1;i<=OrdersTotal();i++)
{
 Alert(i);
 if(OrderSelect(i-1,SELECT_BY_POS)==true)
 {
  if(OrderSymbol()!=Symb)continue;
  if(OrderType()==OP_BUYSTOP)
  {
   OrderTicketBuy=OrderTicket();
   Alert("Buy");
   }
   if(OrderType()==OP_SELLSTOP)
   {
   OrderTicketSell=OrderTicket();
   Alert("Sell");
   }
  }
}


Actually, it should be vice versa: first we should choose an order, and only if an order is chosen we should check its type and make all sorts of nonsense about it:

while(OrderType()==OP_BUY)//Buy
{
 RefreshRates();
 
 SelectBuy=OrderSelect(OrderTicketBuy,SELECT_BY_TICKET);
 ...
}
 
//--------------------------------------------------------------------------
//Sell
while(OrderType()==OP_SELL)
{
 RefreshRates();
  
 SelectSell=OrderSelect(OrderTicketSell,SELECT_BY_TICKET);
 ...
}
 


And in the "sweep-switch-which-type-traits-stoploss", why exactly continue everywhere??? And when will this line be executed, in one and in the second switch?

    CloseBuy=OrderClose(OrderTicketBuy,Lote,Bid,1); continue;//119
-----
    CloseSell=OrderClose(OrderTicketSell,Lote,Ask,1); continue;//119
 
evillive:


Here the order type is considered first, and then the order is selected. Actually it should be the other way around, first select the order, and then if the order is selected look at its type and make all sorts of mockery of it:

so:

if(R==1)//238

{

 Alert("yes");

 R=0;

 SelectBuy=OrderSelect(OrderTicketBuy,SELECT_BY_TICKET);

}


if(R==2)//245

{

 Alert("yes");

 R=0;

 SelectSell=OrderSelect(OrderTicketSell,SELECT_BY_TICKET);

}

And in the "scroll-type-tralit-stoploss"( =D. What don't you like? I think it's normal, it's very clear. ), why exactly everywhere??? And when will this line be executed, in one and in the second switch?

That way it will break by condition:

 Timen=OrderCloseTime();

 if(Timen>0)

 {

  DeleteSell=OrderDelete(OrderTicketSell);

  OldProfit=0;

  WarBuy=true;

  break;

 }

Well, yes, break will look better in the OrderClose string. Then we need to add OrderDelete.

evillive:

Here are some more hints.

This loop does not consider all orders. Besides, if there are more orders of one type than one (for example, three bystop orders are placed), then what will happen?

OrdersTotal starts from 1 and OrderSelect from 0.

Is there more than one order of the same type on 1 symbol? No. But I will have another look.

We need a condition close to this one: "If MA==price, then".

This will do:

if((MA>Open[0] && MA<Close[0]) || (MA<Open[0] && MA>Open[0]))

P.S.: Happy New Year!

 
It's not New Year's Eve for some. Happy New Year!!!
 

Happy New Year!

I have recently started studying MQL 4 and wanted to ask a question:

For example I have a condition to open an order:

if (Bid>=SS+5*Point)

OrderSend(Symbol(),OP_BUY,Lot,Ask,10,Ask-SL*Point,Ask+TP*Point,NULL,Magic,0,Green);

The question is: what condition has to be specified to open the second order in case the first order has a profit of 10 points or more?

 
lexdemon:

Happy New Year!

I have recently started studying MQL 4 and wanted to ask a question:

For example I have a condition to open an order:

if (Bid>=SS+5*Point)

OrderSend(Symbol(),OP_BUY,Lot,Ask,10,Ask-SL*Point,Ask+TP*Point,NULL,Magic,0,Green);

The question is: what condition is necessary to specify to open the second order in case the first order has a profit of 10 points or more?

Look here, there are a lot of functions for almost all cases.

https://www.mql5.com/ru/forum/131859

 
lexdemon:

Happy New Year!

I have recently started studying MQL 4 and wanted to ask a question:

For example I have a condition to open an order:

if (Bid>=SS+5*Point)

OrderSend(Symbol(),OP_BUY,Lot,Ask,10,Ask-SL*Point,Ask+TP*Point,NULL,Magic,0,Green);

Now the question, what conditions have to be specified to open the second order in case the first order has a profit of 10 points or more?

Pre-select the order OrderSelect (Ticket_first_order, SELECT_BY_TICKET);

if(OrderOpenPrice()+10*Point==Ask)

OrderSend(Symbol(),OP_BUY,Lot,Ask,10,Ask-SL*Point,Ask+TP*Point,NULL,Magic,0,Green);

 
CJIeCaPb

 Нужно условие максимально приближенное к этому: "если MA==цене, то".

Такое  пойдет:

if((MA>Open[0] && MA<Close[0]) || (MA<Open[0] && MA>Open[0]))


Hooray, it seems to be working. I inserted return and "O" operator in each loop to avoid unnecessary operations.

One problem: the orders are awkward - I don't know how to formulate the condition.

Files:
test3.mq4  16 kb
 

I have a trader called forexstart, if it makes a difference. the problem is that i wrote a trading robot that works on 1 minute charts. it analyses the history on many charts, the history is given for about a month and a half and no longer.

i have a trading robot that runs on a one-minute chart. it analyzes the history. on many charts the history is given for about a month and a half and no longer, although the hourly - daily - yearly chart shows the history.

How can I deal with it?


 
pycha:

I have a trader called forexstart, if it makes a difference. the problem is that i wrote a robot that works on 1 minute charts. it analyzes the history on many charts, the history is not present for about a month and a half and not anymore.

i have a trading robot that runs on the one-minute chart. it displays the history. on many charts the history is given for about a month and a half and no longer, although the hourly - daily - yearly chart displays the history. there are also cases where the robot returns to a certain date and then breaks and the game continues a couple of months back, although the higher charts show it again.

How can i deal with it?


If after a few cycles of deleting - downloading history from the server DC, the breaks are still there, it means that they will give you the history. Google Tickstory Lite and prepare a lot of disk space for tick history, then feed this history to the tester and you will have an M1 for a decade or more.
 

I have just experimented with the "archive of quotes" . by updating each chart separately, the history for almost all charts has started to work correctly, except for a few exotic pairs, I deleted and updated them a couple of times - no new data for the chart. in general, we can say that the problem has been solved


thanks for the efficiency))))