help me plz me can't calculate function LotsSize to Ordersend

 

i want return(lot_buy)  in OrderSend(Symbol(),OP_SELL,********,Bid,2,ssl,stp,NULL,Magicnumber,0,clrRed);

plz help me


void OpenSellOrder()

   {
         if(TakeProfit>0&&StopLoss>0)
         {
            stp=Bid-(TakeProfit*Point);
            ssl=Bid+(StopLoss*Point);
         }
         else
         {
            stp=0;
            ssl=0;
         }
            OrderSend(Symbol(),OP_SELL,LotsSize(Lots,Lots),Bid,2,ssl,stp,NULL,Magicnumber,0,clrRed);
      return;

   }

void CloseBuyOrder()

{

   for(int i=0;i<total;i++)

   { 

      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))

      if(OrderSymbol()!=Symbol()||OrderType()<2)

      {

         if(OrderType()==0)

         {

            OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,Black);

         }

      }

   }

}

ouble LotsSize(double lot_buy,double lot_sell)

{

lot_buy=Lots;

lot_sell=Lots;

double lot_buy_plus=0.0;

double lot_sell_plus=0.0;

for(int bl=0;bl<total;bl++)

   {

    if(OrderSelect(bl,SELECT_BY_POS,MODE_TRADES))

      if(OrderType()==0)

      {

         if(OrderOpenPrice()<OrderClosePrice())

         {

         lot_buy=lot_buy+Lots+lot_buy_plus;

         return(lot_buy);

         }

         /*else if(OrderOpenPrice()>OrderClosePrice())

               {

                  lot_sell_plus=lot_buy;

               }

         else if(lot_buy>MaxLots)

               {

                  lot_buy=Lots;

               }*/

      }

      

      if(OrderType()==1)

      {

         if(OrderOpenPrice()>OrderClosePrice())

         {

         lot_sell=lot_sell+Lots+lot_sell_plus;

         return(lot_sell);

         }

         /*else if(OrderOpenPrice()<OrderClosePrice())

               {

                  lot_buy_plus=lot_sell;

               }

         else if(lot_sell>=MaxLots)

               {

                  lot_sell=Lots;

               }*/

      }

   }

}

 
grimoll2e: plz help me
  1. When you post code please use the SRC button! Please edit your post.
               General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. Help you with what? You haven't stated a problem. Show us your attempt and state the nature of your problem.
              No free help
              urgent help.

  3. Risk depends on your initial stop loss, lot size, and the value of the pair.
    • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
    • Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
    • Do NOT use TickValue by itself - DeltaPerLot
    • You must normalize lots properly and check against min and max.
    • You must also check FreeMargin to avoid stop out
    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5=0.1 Lots maximum.
Reason: