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.


(Page 1 of 2)

Forex Software → Portfolio Expert → New Portfolio Expert with Protections and a News Filter

Pages 1 2 Next

You must login or register to post a reply

RSS topic feed

Posts: 1 to 25 of 34

Topic: New Portfolio Expert with Protections and a News Filter

Hello Traders,

I'm glad to present a new version of the Portfolio Expert in EA Studio.

The new Portfolio Expert is still in development, but you can test it now.

It is accessible from a new option on the Portfolio Summary page: "Portfolio Expert Beta MT5".
Please reload EA Studio with Ctrl + F5 to ensure everything is updated.


https://image-holder.forexsb.com/store/eas-portfolio-expert-beta-thumb.png

The new expert comes with a lot of protections and also with a news filter.

https://image-holder.forexsb.com/store/eas-portfolio-expert-beta-mt5-thumb.png

Here is an example of an activated protection:

https://image-holder.forexsb.com/store/eas-portfolio-expert-beta-max-orders-thumb.png

Please test this robot carefully and report all issues or ideas for improvements.
I'm also going to make an MT4 version next week.

You can preset the robot options from the new "MQL Options" settings page.

Trade Safe!

Re: New Portfolio Expert with Protections and a News Filter

Here is the "News Filter" in action.

It just prevented an entry due to "news".

https://image-holder.forexsb.com/store/eas-portfolio-expert-beta-news-thumb.png

Re: New Portfolio Expert with Protections and a News Filter

I uploaded a fix for the MQL code.

The "Max open positions (current expert)" and "Max open lots (current expert)" protections now work in the MetaTrader tester.

Here, I'm running a backtest with "Max open positions" set to 10.
As we can see, we have up to 10 positions open in the tester.

https://image-holder.forexsb.com/store/eas-portfolio-expert-beta-max-open-pos-tester-thumb.png

Re: New Portfolio Expert with Protections and a News Filter

Added "Portfolio Expert Beta MT4".

Fixed the ..:: Trading Stats ::.. info to also calculate the manually closed positions.

https://image-holder.forexsb.com/store/eas-protfolio-expert-fixed-trading-stats.png


...

The "Max Spread" protection also works well.

https://image-holder.forexsb.com/store/eas-protfolio-expert-max-spread-protection-thumb.png

5 (edited by Roughey 2024-08-17 12:04:56)

Re: New Portfolio Expert with Protections and a News Filter

are there in code double checks?

void CheckProtections(void)
  {
   if(Min_Equity > sigma && AccountInfoDouble(ACCOUNT_EQUITY) < Min_Equity) {
      const string equityTxt = DoubleToString(AccountInfoDouble(ACCOUNT_EQUITY), 2);
      const string message   = "Minimum equity protection activated at: " + equityTxt;
      ActivateProtection(message);
      return;
   }

   if(MaxDailyLoss > sigma) {
      const double dailyProfit = CalculateDailyProfit();
      if(dailyProfit < -sigma && MathAbs(dailyProfit) >= MaxDailyLoss) {
         ActivateProtection("Maximum daily loss protection activated! Daily loss: " +
                            DoubleToString(MathAbs(dailyProfit), 2));
         return;
      }
   }
  }

here you check Min Equity and MaxDailyLoss

and here in this function again

void CheckAccountProtection(void)
  {
   const double accountEquity = AccountInfoDouble(ACCOUNT_EQUITY);

   if(Min_Equity > sigma && accountEquity < Min_Equity)
     {
      const string equityTxt = DoubleToString(accountEquity, 2);
      const string message = "Minimum equity protection activated. Equity: " + equityTxt;
      ActivateProtection(message);
      return;
     }

   if(Max_Equity > sigma && accountEquity >= Max_Equity)
     {
      const string equityTxt = DoubleToString(accountEquity, 2);
      const string message = "Maximum equity protection activated. Equity: " + equityTxt;
      ActivateProtection(message);
      return;
     }

   if(MaxEquity_DD > sigma && equityDrawdownPercent >= MaxEquity_DD)
     {
      const string equityDDTxt = DoubleToString(equityDrawdownPercent, 2);
      const string message = "Max Equity DD protection activated! Equity DD: " + equityDDTxt + "%";
      ActivateProtection(message);
      return;
     }

   if(MaxDailyLoss > sigma && dailyLoss >= MaxDailyLoss)
     {
      entryProtectionMessage = StringFormat("Max daily loss protection activated! Daily loss: %.2f\n", dailyLoss);
      GlobalVariableSet(accEntrySuspendGlobalVarName, 1);
      CloseAllPositions();
      return;
     }

   if(Max_Daily_DD > sigma && dailyDrawdown >= Max_Daily_DD)
     {
      entryProtectionMessage = StringFormat("Max daily drawdown protection activated! Daily DD: %.2f%%\n", dailyDrawdown);
      GlobalVariableSet(accEntrySuspendGlobalVarName, 1);
      CloseAllPositions();
      return;
     }
  }

also this code line is not needed anymore i think

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsWithinMaxSpread(void)
  {
   if(Max_Spread == 0)
      return true;

   for(int attempt = 0; attempt < TRADE_RETRY_COUNT; attempt++)
     {
      const int spread = (int) MathRound((Ask() - Bid()) / _Point);

      if(spread <= Max_Spread)
         return true;

      Print("Too high spread of " + IntegerToString(spread) + " points. Waiting...");
      Sleep(TRADE_RETRY_WAIT);
     }

   Print("The entry order is cancelled due to too high spread.");

   return false;
  }

So i think we can throw out the first function to clean code. Only for interesting for what is this sigma variable good and why you use this? And why you use GlobalVariables which stored in a file of terminal?
Some questions and future things

1. What is this Max Equity? Is it like a Take profit?
2. Now we have Max Open position. Also its good to have Max open positions per bar. sometime on one bar it can make 5 positions open when we want only 1 let us do.
3. We have now Max Daily Loss. Now its good to have also Max Daily Win. Like a Take Profit. So when we have reached xx amount close trades. and let it reset by time x
4.Add Max open long positions also Max open sell positions - with this we can decide in ea only use long or sells.

Btw isnt it better to use seperate functions for each option? It will be faster. So i mean seperate function for Max Daily Loss. Seperate for Max Spread. Seperate for Max Equity. So when we do not use this than it will not calcculate. Now it is calculate all things every tick. Better to use functions or i am wrong?

Re: New Portfolio Expert with Protections and a News Filter

Roughey, thank you for the feedback!

I removed the duplicated code. It was leftover from the previous version of the Portfolio Expert.

> 1. What is this Max Equity? Is it like a Take profit?

The "Max Equity" protection is handy for prop firm challenges. The expert closes the positions and stops the experts when the equity reaches a certain equity level.

> 2. Now we have Max Open position. Also its good to have Max open positions per bar.

It is the same because the Portfolio Expert opens new positions only at the beginning of a bar.

> 3. We have now Max Daily Loss. Now its good to have also Max Daily Win.

The Max Daily Loss is useful for prop firms. They have such a limitation. When the account makes a certain daily loss, the robot closes all positions and waits until midnight. Usually, the prop firms reset the daily requirements at midnight terminal time.

> 4.Add Max open long positions also Max open sell positions

It looks too granular to me.

> Btw isnt it better to use seperate functions for each option? It will be faster.

It is possible to be faster. Code optimization and cleanup are always possible.

Re: New Portfolio Expert with Protections and a News Filter

I uploaded a new version of the MQL code for the individual experts and the Portfolio Expert.

The new versions clean the MT's chart comment and leftover messages on startup.

The experts work fine as per my tests.
If everything is correct, I'll officially release these versions next week.

Please report any issues you may discover.

Re: New Portfolio Expert with Protections and a News Filter

Popov wrote:

Roughey, thank you for the feedback!

I removed the duplicated code. It was leftover from the previous version of the Portfolio Expert.

> 1. What is this Max Equity? Is it like a Take profit?

The "Max Equity" protection is handy for prop firm challenges. The expert closes the positions and stops the experts when the equity reaches a certain equity level.

> 2. Now we have Max Open position. Also its good to have Max open positions per bar.

It is the same because the Portfolio Expert opens new positions only at the beginning of a bar.

> 3. We have now Max Daily Loss. Now its good to have also Max Daily Win.

The Max Daily Loss is useful for prop firms. They have such a limitation. When the account makes a certain daily loss, the robot closes all positions and waits until midnight. Usually, the prop firms reset the daily requirements at midnight terminal time.

> 4.Add Max open long positions also Max open sell positions

It looks too granular to me.

> Btw isnt it better to use seperate functions for each option? It will be faster.

It is possible to be faster. Code optimization and cleanup are always possible.

> 2. Now we have Max Open position. Also its good to have Max open positions per bar.

It is the same because the Portfolio Expert opens new positions only at the beginning of a bar.

Yes but when you have Max Open Positions e.g 50 and it is open 20 and you have strategies which have signals for next bar e.g 10 so it will open 10 new positions. So to avoid this or to have some more good management we can use or change to e.g 1..So the Ea open only not 10 next bar it open 1. So the max open new position is now 21.

Sometimes i have 200 Strategies and i know how it is.. Your balance is not good but i want to let not open to much signals on next bar.

> 3. We have now Max Daily Loss. Now its good to have also Max Daily Win.

The Max Daily Loss is useful for prop firms. They have such a limitation. When the account makes a certain daily loss, the robot closes all positions and waits until midnight. Usually, the prop firms reset the daily requirements at midnight terminal time.

Ok but we can use this also not for prop firms. It will be great. I when i can say after amount xxx stop trading rest of the day. Its only for money management. Sometimes its very good to stop trading when reach some amount. I know its not the behaviour of a portfolio or automared trading. But i think any kind of money management is better.

> 4.Add Max open long positions also Max open sell positions

It looks too granular to me.

What do you mean? With this it is possible easy to switch to only open buys or sells of the portfolio. Also sometimes good to spark in between when we know it is a more bear or bull market. Also some forum users call for this to only open shorts or longs.

Re: New Portfolio Expert with Protections and a News Filter

The Magic Number printed on  MT5 is different from what I entered.

Re: New Portfolio Expert with Protections and a News Filter

Hi Popov, just a question.. are the protections and news filters taken in considerations on the backtests, or do they only work when the experts are "live" on MT4/5? I suppose the second thing, but just for confirmation.

Thanks

Re: New Portfolio Expert with Protections and a News Filter

> are the protections and news filters taken in considerations on the backtests

The "Entry Protections" are considered: "Max spread", "Max open positions", and "Max open lots".
The other protections, including the "News filter", work only on live (and demo) trading.

Re: New Portfolio Expert with Protections and a News Filter

The new MQL code is published as an official release.

Now, the Portfolio Experts downloaded from EA Studio use this new code.

Trade Safe!

Re: New Portfolio Expert with Protections and a News Filter

Dear Popov,
this improvements are really useful and I find this will really give much more value to the portfolio management.

I've appreciated that some of my requests in the Wish List forum post are now available into the Portoflio settings (max equity, minimum equity, X minutes before/after news). Thanks!

14 (edited by poteree 2024-08-26 07:33:00)

Re: New Portfolio Expert with Protections and a News Filter

Question please: when settings values are at 0, it means null, right? Thanks

Re: New Portfolio Expert with Protections and a News Filter

poteree wrote:

Question please: when settings values are at 0, it means null, right? Thanks

when 0 it is like disabled

16 (edited by poteree 2024-08-26 17:41:55)

Re: New Portfolio Expert with Protections and a News Filter

Dear Popov,
in demo the Portfolio correctly blocked the EAs from trading after reached the Daily Loss, but after changing the settings to no limitations (mostly "0"), the portfolio EAs are still active (blue icon) but they do not trade anymore even if there are no limitations/blocks to opening trades. Please find attached a couple of screenshots of two portfolio settings (the demo account is currently around 24.450 usd):

Post's attachments

Immagine 2024-08-26 183638.png
Immagine 2024-08-26 183638.png 32.04 kb, file has never been downloaded. 

Immagine 2024-08-26 183717.png
Immagine 2024-08-26 183717.png 31.28 kb, file has never been downloaded. 

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

17 (edited by poteree 2024-08-27 06:58:02)

Re: New Portfolio Expert with Protections and a News Filter

Message on MT5: Date + 7:30 Entry Order was canceled. New entries are suspended until the Daily Reset hour : 0

"0" in this case is not disabled but it's 0. But midnight is past, the Portfolio EA should have open new trades after midnight, right?

Thanks

Post's attachments

Immagine 2024-08-27 075450.png
Immagine 2024-08-27 075450.png 12.26 kb, file has never been downloaded. 

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

Re: New Portfolio Expert with Protections and a News Filter

> New entries are suspended until the Daily Reset hour : 0

When the Daily loss (or Drawdown) protection is activated, new entries are suspended until midnight.

However, if you change your settings and disable the daily protections, the Expert should start trading normally.

I'll check the issue.

19 (edited by poteree 2024-08-27 12:30:50)

Re: New Portfolio Expert with Protections and a News Filter

Popov wrote:

> New entries are suspended until the Daily Reset hour : 0

When the Daily loss (or Drawdown) protection is activated, new entries are suspended until midnight.

However, if you change your settings and disable the daily protections, the Expert should start trading normally.

I'll check the issue.

The daily loss limit was hit yesterday, while "Daily Reset Time" was always at "0".

I've understood that "0" in this case stands for "disabled" not for midnight.

In the meantime, waiting for the fix, thanks.

Re: New Portfolio Expert with Protections and a News Filter

> "Daily Reset Time" was always at "0"

This is the time the Terminal resets the hold and resumes the trading. 0 means literally 0 o'clock to  00:00
At what time was the protection hit?
The expert should remove the hold automatically.

You can remove the limitation manually by deleting the MT Global Variables manually.
Click F3 to see a popup window with variable name and values.
Delete: Is_Entry_Suspended_xxx, and accEntrySuspendXXX
(XXX is the number of your account)

21 (edited by Roughey 2024-08-27 17:45:03)

Re: New Portfolio Expert with Protections and a News Filter

Popov wrote:

> "Daily Reset Time" was always at "0"

This is the time the Terminal resets the hold and resumes the trading. 0 means literally 0 o'clock to  00:00
At what time was the protection hit?
The expert should remove the hold automatically.

You can remove the limitation manually by deleting the MT Global Variables manually.
Click F3 to see a popup window with variable name and values.
Delete: Is_Entry_Suspended_xxx, and accEntrySuspendXXX
(XXX is the number of your account)

what i think about the global variables..why we use this? When it hit Daily Loss or Min Equity EA stop trading and close . But when i try to start again it is not working cause the global variable is set. why we not use the exact equity and balance what we have? is it cause of the resume trading? isnt it better to set a flag allowtrading to false and set it to true if reset time reached.

Re: New Portfolio Expert with Protections and a News Filter

There are three reasons:
- We cannot calculate the Daily Loss or drawdown directly because MQL lacks such a feature. We solve the problem by collecting the information while trading and providing it to the other experts.
- If one of the experts hits the limitation, it should signal to all the other experts to stop trading.
- If the limitation is hit, the experts halt the trading until midnight. We need to persist this information if we remove these experts and start new ones (or the same again). The newly added expert should continue holding the trades because any new position will violate the limitation.

Max Daily Drawdown and Max Daily Loss are terminating conditions for Prop firms' accounts.
You may not use these features for regular CFD trading.

Re: New Portfolio Expert with Protections and a News Filter

Popov wrote:

There are three reasons:
- We cannot calculate the Daily Loss or drawdown directly because MQL lacks such a feature. We solve the problem by collecting the information while trading and providing it to the other experts.
- If one of the experts hits the limitation, it should signal to all the other experts to stop trading.
- If the limitation is hit, the experts halt the trading until midnight. We need to persist this information if we remove these experts and start new ones (or the same again). The newly added expert should continue holding the trades because any new position will violate the limitation.

Max Daily Drawdown and Max Daily Loss are terminating conditions for Prop firms' accounts.
You may not use these features for regular CFD trading.

Ok but you say to the other experts? what if i use a different expert as from you. So the other expert which have nothing todo with EAS experts will also not work?

Re: New Portfolio Expert with Protections and a News Filter

> Ok but you say to the other experts? what if i use a different expert as from you.

If you have ever traded with Prop Firms, you should know that if you violate the Daily Loss or Drawdown limitation, they will automatically close your account. No matter whether you trade manually or with any third-party experts. That is.

We sold many Prop Firm Robots App licenses (https://prop.forexsb.com/) this year. These protections are vital for Prop Firm traders. Now, I decided to give such functionality to the EA Studio experts.

As I said before, if your broker does not have such limitations, you should not use these features.

Find more info here: Maximum Daily Loss

For example, in the case of an FTMO Challenge with the initial account balance of $200,000, the Max Daily Loss limit is $10,000. If you lose $8,000 in your closed trades, your account must not decline more than $2,000 this day. It must also not go -$2,000 in your open floating losses. The limit includes commissions and swaps.

I personally do not like the idea behind the Prop firm challenges, so I am reluctant to add this app to my website.

25 (edited by poteree 2024-08-27 19:23:44)

Re: New Portfolio Expert with Protections and a News Filter

Popov wrote:

> "Daily Reset Time" was always at "0"

This is the time the Terminal resets the hold and resumes the trading. 0 means literally 0 o'clock to  00:00
At what time was the protection hit?
The expert should remove the hold automatically.

You can remove the limitation manually by deleting the MT Global Variables manually.
Click F3 to see a popup window with variable name and values.
Delete: Is_Entry_Suspended_xxx, and accEntrySuspendXXX
(XXX is the number of your account)

The protection was hit at 06:00:02 broker time of yesterday Aug 26th.

By pressing F3 on a MT5 chart, I removed 1 accEntrySuspendXXX. There's no IS-Entry-SuspendedXXX.
Result: 1 TRADE HAS JUST BEEN OPEN!

Only for info: when pressing F3, there are 3 additional lines: accMaxDailyBalanceXXX, AccMaxDailyEquityXXX, AccMAxEquityXXX.

Question: is F3 the final solution? Or just a temporary workaround?
Thanks!

Posts: 1 to 25 of 34

Pages 1 2 Next

You must login or register to post a reply

Forex Software → Portfolio Expert → New Portfolio Expert with Protections and a News Filter

Similar topics in this forum