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

 
artmedia70:

For Buy, stop and take are calculated from the Bid price - that's one.

Secondly, if you calculate stop order prices, they need to be normalised. The fact that SL and TP were normalized earlier is no big deal. Then you use the non-normalized value of the expression in the trade order.

Third, all prices must meet the requirements and restrictions on trade operations. The level of StopLevel, for example, may be larger than the size of the stop order.



Did I understand correctly that the values need to be normalised within the trade order?
 
Tell me how, elegantly, to find the TIME Lowe of yesterday. Because I've got some unwieldy constructions coming out.
 
001:
Tell me how, elegantly, to find the TIME Lowe of yesterday. Because I've got some unwieldy constructions coming out.

Find the price-channel indicator(doncian channel ), put a depth of 1period on the diaries... should be that
 
YOUNGA:

Find the price-channel indicator (doncian channel), set a depth of 1period on the diaries... should be that
Thanks, I'll give it a try. Anyone else have any options while I'm looking?
 

Good afternoon, please help with the code.

In this implementation, market buy and sell orders are averaged separately. How can I implement that the last open order is not subject to general modification in its series?

extern int t=10;

///////////////////////////////////////////////////////
      int kolOK=0;
//   int i=0;
   int kol1=0;
   int kol2=0;
   double lots1=0;
   double lots2=0;
   double sum0=0;
   double sum=0;
  // double sum1=0;
   /////////////////////////////////////////////////////////////////////
   int Total = OrdersTotal();
   for(int i=Total-1; i>=0; i--)
   {
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
      if (OrderSymbol()!=Symbol()) continue;
      if (OrderType()==OP_BUY)
      {
       lots1=lots1+OrderLots();
       sum0=sum0+OrderLots()*OrderOpenPrice();
      // sum1=sum1+OrderProfit( )+OrderSwap( )+OrderCommission( )  ; 
       kol1=kol1+1;
      }
      if (OrderType()==OP_SELL)
      {
       lots2=lots2+OrderLots();
       sum=sum+OrderLots()*OrderOpenPrice();
      // sum1=sum1+OrderProfit( )+OrderSwap( )+OrderCommission( )  ;
       kol2=kol2+1;
      }
   }
   ////////////////////////////////////////////////////////////////////////////
   double zeroprice1=0;
   double zeroprice2=0;
   if (lots1!=0) zeroprice1=sum0/lots1;
   if (lots2!=0) zeroprice2=sum/lots2;
   zeroprice1 = (MathRound(zeroprice1*MathPow(10,Digits)))/MathPow(10,Digits);
   zeroprice2 = (MathRound(zeroprice2*MathPow(10,Digits)))/MathPow(10,Digits);

 int res1 = 0;
 int res2 = 0;

 double zeroprice10 = NormalizeDouble(zeroprice1 + t*Point, Digits);
 double zeroprice20 = NormalizeDouble(zeroprice2 - t*Point, Digits);
 if (zeroprice10 !=0 || zeroprice20 !=0) {
   int Total2 = OrdersTotal();
   for(int in=Total2-1; in>=0; in--)
   {
      if (!OrderSelect(in,SELECT_BY_POS,MODE_TRADES)) continue;
      if (OrderSymbol()!=Symbol()) continue;     

           if (OrderType()==OP_BUY) {if (zeroprice10 == NormalizeDouble(OrderTakeProfit(), Digits)) res1=res1+1; else { if (OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),zeroprice10,0,CLR_NONE)) res1 = res1+1;} }

           if (OrderType()==OP_SELL){if (zeroprice20 == NormalizeDouble(OrderTakeProfit(), Digits)) res2=res2+1; else { if (OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),zeroprice20,0,CLR_NONE)) res2 = res2+1;} } 
       }   
   }
 
fmv_for_a_way:


Understood, thanks. I have indeed made a mistake with the prices. We check for stop loss before placing a pending order. There is also a stop and loss check for the same lousiness.

In this particular case, the broker's stop level = 0 and the stop and profit are set much further away. As for the market order price, my understanding is that it opens at the nearest market price and the stop level has nothing to do with it. Right?

No, it isn't. Alpari uses the double spread as a StopLevel.
 
fmv_for_a_way:

Did I understand correctly that the values need to be normalised within the trade order?
Not necessarily right inside. But just before sending it, yes.
 
artmedia70:
Not necessarily right inside at all. But just before shipment, yes.


Thank you. I'll look for a solution.
 
People, can you tell me where to download MT4 build 625?
 

Can you tell me if there is any way (e.g. through API)

to switch to another account from the program

Reason: