forex software

Create and Test Forex Strategies

forex software

Skip to forum content

Forex Software

Create and Test Forex Strategies

You are not logged in. Please login or register.


Forex Software → Portfolio Expert → Limit the number of open positions.

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 7

1 (edited by Popov 2021-11-27 16:55:51)

Topic: Limit the number of open positions.

Hi,

i am using counting deals on portfolio ea on mql4 this code

void OpenOrdersResults()
  {
//------------------------------------------------------
   SumOrders=0;
   BuyOrders=0;
   SellOrders=0;
   TypeLastOrder=-1;
   PipsBuyOrders=0;
   PipsSellOrders=0;
   PipsLastBuyOrders=0;
   PipsLastSellOrders=0;
   ProfitBuyOrders=0;
   ProfitSellOrders=0;
   SumFloating=0;
//---
   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
        {
         const int magicNumber = OrderMagicNumber();
         if(OrderSymbol()==Symbol() && (magicsize * Magic <= magicNumber && magicNumber < (magicsize * Magic + strategiesCount)))
           {
            TypeLastOrder=OrderType();
            if(OrderType()==OP_BUY)
              {
               //               PipsLastBuyOrders=(Bid-OrderOpenPrice())/pip;
               //               PipsBuyOrders+=(Bid-OrderOpenPrice())/pip;
               //               ProfitBuyOrders+=OrderProfit()+OrderCommission()+OrderSwap();
               BuyOrders++;
              }
            if(OrderType()==OP_SELL)
              {
               //               PipsLastSellOrders=(OrderOpenPrice()-Ask)/pip;
               //               PipsSellOrders+=(OrderOpenPrice()-Ask)/pip;
               //               ProfitSellOrders+=OrderProfit()+OrderCommission()+OrderSwap();
               SellOrders++;
              }
            SumOrders++;
            SumFloating+=OrderProfit()+OrderCommission()+OrderSwap();
           }
        }
     }

  }

now i am struggling to get this code in mql5 for new portfolio ea..
i need this cause i am managing the open orders..

EnableMaxPositionsPerBar   = false;               
MaxPositionsPerBar         = 2;                    // Set Max Open Position per Bar
EnableMaxBuyPositions      = false;         
MaxBuyPositions            = 6;                    // Set Max Open Long Positions
EnableMaxSellPositions     = false;         
MaxSellPositions           = 7;                    // Set Max Open Short Positions
EnableTotalPositions       = false;           
TotalPositions             = 10;                   // Set Max Open Positions

so i need it so i can change during running the ea that he not open more thax x posi at same time or only open longs or open short and at on bar ea porfolio can open x positions per bar..sometimes if portfolio is big ea opens 20-30 positions at once.

Re: Limit the number of open positions.

It can be easier limit the number of open positions. However, I'm afraid it will break the trading logic of the suspended strategies.

With the new Portfolio Experts it will be easier to add additional features.
I'll open a new topic to discuss the possibilities.

I'll post a solution for the current request.

Re: Limit the number of open positions.

Added a "Max Open Positions" option in the Portfolio Experts for MT4 and MT5.
The new option works both in tester and in a live trading.


https://image-holder.forexsb.com/store/portfolio-expert-max-open-positons.png

Please report any issues.

Re: Limit the number of open positions.

Popov wrote:

Added a "Max Open Positions" option in the Portfolio Experts for MT4 and MT5.
The new option works both in tester and in a live trading.
Please report any issues.


nice...is this now when 100 deals are open ea will not open a new trade?

or is this open trades per bar? ea can open 100 trades at new bar?

Re: Limit the number of open positions.

Each strategy can open one position at a time. Since we have 100 strategies at max, it means that 100 is the absolute maximum for the particular Base_Magic range (for the particular symbol).

> or is this open trades per bar?

The limit means total simultaneously open positions not matter if they are open this or om a previous bar.

It is not count of orders but actually open positions.

Re: Limit the number of open positions.

Hello
I have created an expert with studio and the "max open position" option doesn't limit the positions open simultaneously even I set it to max 1 open position the expert opens 2 positions
Can you help me where I should modify in the code the max open position to only 1 ?
Thanks

Post's attachments

Untitled.png 52.97 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: Limit the number of open positions.

cristyangeo wrote:

Hello
I have created an expert with studio and the "max open position" option doesn't limit the positions open simultaneously even I set it to max 1 open position the expert opens 2 positions
Can you help me where I should modify in the code the max open position to only 1 ?
Thanks

Use o criador web ele funciona perfeitamente e os doados são melhores e as ias mais precisas

Posts: 7

Pages 1

You must login or register to post a reply

Forex Software → Portfolio Expert → Limit the number of open positions.

Similar topics in this forum