[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 226

 
doon:

How do I make an EA buy or sell at a certain time(sleep not to use)?

The date-time functions will help: https://book.mql4.com/ru/functions/datetime
 
Fam:
The date-time functions will help: https: //book.mql4.com/ru/functions/datetime

Thanks, but you'll still have to insert a slip there.

 
People! I am trying to make, that would trade a lot depending on the risk.... what does not work....writes
 EURUSD,M15: OrderSend error 4051

tell me where the error is....

void OpenBuy() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 
   ldLot = GetSizeLot(); 
   ldStop = GetStopLossBuy(); 
   ldTake = GetTakeProfitBuy(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol(),OP_BUY,ldLot,Ask,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenBuy); 
   if (UseSound) PlaySound(NameFileSound); 
} 
void OpenSell() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 

   ldLot = GetSizeLot(); 
   ldStop = GetStopLossSell(); 
   ldTake = GetTakeProfitSell(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol(),OP_SELL,ldLot,Bid,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenSell); 
   if (UseSound) PlaySound(NameFileSound); 
} 
string GetCommentForOrder() {   return(Name_Expert); } 
double GetSizeLot() { 
   double ldlot=Lots;
   int    orders=HistoryTotal();     // history orders total
   int    losses=0;                  // number of losses orders without a break
   ldlot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
   if(DecreaseFactor>0)
     {
      for(int i=orders-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
         if(OrderProfit()>0) break;
         if(OrderProfit()<0) losses++;
        }
      if(losses>1) ldlot=NormalizeDouble(ldlot-ldlot*losses/DecreaseFactor,1);
     }
   if(ldlot<0.1) ldlot=0.1;
                         } 
double GetStopLossBuy() {       return (Bid-sStopLoss*Point);} 
double GetStopLossSell() {      return(Ask+sStopLoss*Point); } 
double GetTakeProfitSell() {    return(Bid-sTakeProfit*Point); } 
double GetTakeProfitBuy() {     return(Bid+sTakeProfit*Point); } 

return(0);
 

Thank you all, I'll be trying it out...
 
charter:

I'm afraid this is only true for the time-series.

In my case, there's nowhere even to poke it.

Your idea is correct, i.e. the order has to be reversed somehow, but I don't know how yet


Don't worry, it works.
 
Vovo4ka:
People! I am trying to make, that would trade a lot depending on the risk.... what does not work....writes

tell me where the error is....


forgot to put a line in the lot.
return (ldlot);
 
todem:

I forgot to put a line in the lot.

right...... forgot.... thank you very much.... I've already checked it 20 times, I couldn't figure out what the hell...)
 

Help with a question about requote+slippage.

The situation is as follows: I send a request for transaction by Expert Advisor, Slippage=3 pt, error 138 Requote occurs. I tried to RefreshRates() and tried again with a new Ask, but the server price is better than the Ask I sent (second time after RefreshRates()), and logically I need to agree, but because server price deviation is larger than Slippage in the request - this request is rejected. (((

How can you control this situation? Ie if the server price is better then to move the Slippage or what, so that the request is accepted by the server. Or it is not possible?

 
ZZZEROXXX:

Help with a question about requote+slippage.

The situation is as follows: I send a request for transaction by Expert Advisor, Slippage=3 pt, error 138 Requote occurs. I tried to RefreshRates() and tried again with a new Ask, but the server price is better than the Ask I sent (second time after RefreshRates()), and logically I need to agree, but because server price deviation is larger than Slippage in the request - this request is rejected. (((

How can you control this situation? Ie if the server price is better then to move the Slippage or what, so that the request is accepted by the server. Or it is not possible?


Increase the slippage. The trades must have been opened in a fast market. It happens sometimes after important news that the Eurobucks is so fast in 1-2 ticks that it's a nightmare. And while the server is processing the advisor's order, the price changes very steeply.
 
Zhunko:
MT4 has a built-in converter. Service -> Quotes Archive.

Thank you! But the goal is as follows. Offset daily bars (candlesticks), updated with the arrival of quotes, the chart behaves like a normal chart: you can hang other indicators, EAs, build channels, levels, etc. on it. It should be something like non-standard timeframes, but non-standard in shifting bars (candlesticks) relative to the terminal time: H4 - at -3, -2, -1, 1, 2 or 3 hours; D1 - at -23, -22, ... 1, 2, ... or 23 hours; W1 - for -6, -5, ... or 6 days and so on. The offset must be set in the input parameters of the indicator.

Is there such a thing?

I thank you in advance.