Page 1 of 2 12 LastLast
Results 1 to 10 of 16
 5 Attachment(s)    

Thread: Count Lots OP_SELL and OP_BUY

  1. #1

    Default Count Lots OP_SELL and OP_BUY

    HI

    I wanna count the lots of all open orders (OP_Buy and OP_Sell).

    could someone tell me the code to count the lots of all open orders?






    thanks!!

    chris

  2. #2

    Default

    Count Lots OP_SELL and OP_BUY-2012-06-24_180301_small-png

    i wanna count this lots (>> pic)

  3. #3
    Member
    Join Date
    Oct 2010
    Location
    Australia
    Posts
    259

    Default

    This is Funyoo's code
    mode 0 for pips, mode 1 for dollars

    Code:
    double countprofit(int mode,string comment,string symbol){
       double p=0;
       if(OrdersTotal()>0){
          for(i=OrdersTotal()-1;i>=0;i--){
             OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
             if(OrderSymbol()==symbol && OrderComment()==comment || comment=="" && OrderMagicNumber()==magic){
                if(mode==1 && OrderType()==type)p+=OrderProfit();
                if(mode==0 && OrderType()==OP_BUY && type==OP_BUY){p+=(OrderClosePrice()-OrderOpenPrice())/pt;}
                if(mode==0 && OrderType()==OP_SELL && type==OP_SELL){p+=(OrderOpenPrice()-OrderClosePrice())/pt;}
             }
          }
          return(p);
       }
    }

  4. #4

    Default

    thank you... but that is counting the profits, isnt it??

    how can i count the Lot-sizes of the open buy/sell posistions?

  5. #5
    Member
    Join Date
    Oct 2010
    Location
    Australia
    Posts
    259

    Default

    Sorry your right..

    Once you select the order:

    OrderType()==OP_BUY ){BuyLots = OrderLots();}

    OrderType()==OP_SELL ){SellLots = OrderLots();}

    Depending on what you want to achieve

    if you want to add them up.. {p+=(OrderLots();}



    If you want to select the first order
    OrderSelect(0,SELECT_BY_POS,MODE_TRADES);

    if you want to select the last order
    OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES);


    example of selecting the smallest lots open
    Code:
    //+-------------------------------------------------------------------------------+ Smallest LOTS +--------------------+
    double SmallestLots(string pair){
       double orderlots=100;
       if(OrdersTotal()>0){
          for(i=OrdersTotal()-1;i>=0;i--){
             OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
             if(OrderSymbol()==pair && OrderType()==OP_BUY && OrderMagicNumber()==MagicNumber){
               if (OrderLots() <= orderlots)orderlots=OrderLots();
             }
             if(OrderSymbol()==pair && OrderType()==OP_SELL && OrderMagicNumber()==MagicNumber){
               if (OrderLots() <= orderlots)orderlots=OrderLots();
             }
           }  
           return(orderlots);

    I hope it makes sense.

  6. #6

    Default

    hi arbus

    thank you for your help.
    I've insert this code for the lots >

    if(OrdersTotal()>0)
    {
    openbuylots = 0; openselllots = 0; // set the variables to zero
    for(i=0;i<OrdersTotal();i++)
    {
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderCloseTime()==0)
    {
    if(OrderType()==OP_BUY) openbuylots += OrderLots();

    if(OrderType()==OP_SELL) openselllots += OrderLots();
    }
    }
    }

  7. #7

    Default

    but after the basketclose there getting something wrong... > pics...

    Count Lots OP_SELL and OP_BUY-basket-png

    Count Lots OP_SELL and OP_BUY-didnt-hit-tp-png

    Count Lots OP_SELL and OP_BUY-first-pos-close-after-basket-png

  8. #8

    Default

    and the EA is actually a EA from Funnyo >> the "Dual_Grid_EA" i just wanna change the steps and the lots of the posistions.... here is the one I'm working with....
    Attached Files Attached Files

  9. #9
    Member
    Join Date
    Oct 2010
    Location
    Australia
    Posts
    259

    Default

    You are probably better to know or find the 1st lot position.
    Then just multiply the 1st position to get the rest of the lot sizes you need.

    This is Funyoo's original code.
    Code:
    if(addpositions){
             blots=lots*MathPow(multiplier,count(OP_BUY));
             slots=lots*MathPow(multiplier,count(OP_SELL));
          }
    It should work to change the lots of the positions.
    It multiplies the number of buy(or sell) orders by the multiplier by the original lots.

    To change the steps you need to change "pips" variable.

    I am thinking you want to do something else? Do you want to change the step with regard to the number of open orders?

  10. #10

    Default

    hi arbus

    thank you for your reply.

    yes that works to change the lots, but the problem is, if there are view posistions the lots are big, but if it is breakout in one direktion the OP_Buy or OP_sell are then just only on and the lots of the new posistion is getting to small.

    the steps are fine/ok.

    i only wanna count the open lots
    >>> blots=lots+(openselllots*multiplier)
    >>> slots=lots+(openbuylots*multiplier)

    and thank you for your help!!!

Similar Threads

  1. Margin and Lots
    By painofhell in forum Trading discussion
    Replies: 1
    Last Post: 09-01-2014, 08:54
  2. Lots Multiplier( help Please)
    By joepayne in forum MQL programming
    Replies: 22
    Last Post: 02-12-2011, 04:35
  3. Nano Lots
    By JXBlack in forum Brokers
    Replies: 1
    Last Post: 07-23-2010, 20:36
  4. Change lots/multiplier to lots=0.01 gives OrderSend error 130?
    By sleepypipsCDN in forum MQL programming
    Replies: 7
    Last Post: 04-12-2009, 09:17
  5. Mini Lots - Micro Lots
    By funyoo in forum Trading discussion
    Replies: 0
    Last Post: 01-23-2009, 12:06

Tags for this Thread

100, breakout, change, eas, grid, magic number, profit, thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •