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 → Expert Advisor Studio → Disable entry or exit signal for single strategy EAs

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 18

Topic: Disable entry or exit signal for single strategy EAs

Hello everyone,

Sometimes when I want to replace an EA with an updated strategy, the old EA may still have an open position running.
I don't like closing positions prematurely or just removing the EA from the chart, because the strategy may have its own exit conditions.

How can I modify the source code to disable the entry signal, so new trades are not opened, but the EA still manages the opened position?

On the other hand, sometimes I want to disregard the exit signal for a certain strategy and simply allow the TP or SL orders to close the trade. So how can I deactivate the exit signal in this scenario?

I learned how to do this with a portfolio EA using the double slash infront of the signalList[i++] lines, but how is this done with a single strategy EA?

Re: Disable entry or exit signal for single strategy EAs

For entries you do not need to overcomplicate things with source editing, just set Max Open Positions to zero!

Re: Disable entry or exit signal for single strategy EAs

footon wrote:

For entries you do not need to overcomplicate things with source editing, just set Max Open Positions to zero!

Hello, I've tried your suggestion and it does not work. The EA is still opening new positions.
If I'm not mistaken, putting a zero in any of the "entry protection" fields means that the EA disregards that feature.

Re: Disable entry or exit signal for single strategy EAs

Interesting, it did work on portfolios very well. I'll look into it.

Re: Disable entry or exit signal for single strategy EAs

Seems to be a bug, it supposed to stop opening new positions, I'll report it to to the dev.

Re: Disable entry or exit signal for single strategy EAs

footon wrote:

Interesting, it did work on portfolios very well. I'll look into it.

Yes, that works for portfolio EAs, but not for single strategy EAs.

Just tested this idea to disable the entry logic from the source code.
I found the line of the code with the entry logic "OpenPosition(entrySignal);", and just turned it into a comment with 2 forward slashes > "//OpenPosition(entrySignal);"

It is working in the backtests and it worked for 2 forward tested trades.

Do you know how to replicate this for the exit logic? I saw ClosePosition in the code, but there are so many of them...

Re: Disable entry or exit signal for single strategy EAs

I would substitute ManageClose with this:

void ManageClose(void)
  {
   // Do not Exit
   bool ind1long  = false;
   bool ind1short = false;

   if((posType == OP_BUY  && ind1long) ||
        (posType == OP_SELL && ind1short) )
      ClosePosition();
  }

This way it's like using Do Not Exit indi, closing would work only with set TP/SL.

8 (edited by geektrader 2024-06-06 00:17:28)

Re: Disable entry or exit signal for single strategy EAs

Or just

void ManageClose(void)
  {

return;

...Existing Logic Stays As Is.

}

Re: Disable entry or exit signal for single strategy EAs

> Disable entry or exit signal for single strategy EAs

It looks like ending new options will be useful:

Allow opening of new positions: true
Allow closing of current positions: true

Any ideas for better naming?

...

Besides that, I plan to add separate options for enabling the entires and exits of each strategy for the Portfolio Experts.

Re: Disable entry or exit signal for single strategy EAs

footon wrote:

I would substitute ManageClose with this:

void ManageClose(void)
  {
   // Do not Exit
   bool ind1long  = false;
   bool ind1short = false;

   if((posType == OP_BUY  && ind1long) ||
        (posType == OP_SELL && ind1short) )
      ClosePosition();
  }

This way it's like using Do Not Exit indi, closing would work only with set TP/SL.

Thank you for the suggestion. It's working!

Re: Disable entry or exit signal for single strategy EAs

geektrader wrote:

Or just

void ManageClose(void)
  {

return;

...Existing Logic Stays As Is.

}

Thanks to you as well. Another working option!

Re: Disable entry or exit signal for single strategy EAs

Popov wrote:

> Disable entry or exit signal for single strategy EAs

It looks like ending new options will be useful:

Allow opening of new positions: true
Allow closing of current positions: true

Any ideas for better naming?

...

Besides that, I plan to add separate options for enabling the entires and exits of each strategy for the Portfolio Experts.

Excellent idea Popov, that way we can do it directly from the inputs of the EA without touching the source code.
The naming sounds perfect in my opinion.

Re: Disable entry or exit signal for single strategy EAs

Open New Positions: True
Close Open Positions: True

Re: Disable entry or exit signal for single strategy EAs

"Guys, from what I noticed, you came back strong. Very interesting this question. Let me see if I understood, especially because I am using a translator to talk to you. In this case, each portfolio strategy would have a true or false button so that each one can be deactivated or activated, or just a button for new open or closed trades to prevent it from continuing to open trades from a certain point, allowing us to switch to new strategies."

15 (edited by KCGO 2024-06-07 05:18:33)

Re: Disable entry or exit signal for single strategy EAs

geektrader wrote:

Open New Positions: True
Close Open Positions: True

I think "Close Open Positions: True" is a bit ambiguous, because some may think that it means closing the positions immediately, like in the Bulk Operations features in MT5.

The initial wording proposed by Popov is perfect.

Allow opening of new positions: true
Allow closing of current positions: true

Re: Disable entry or exit signal for single strategy EAs

gabdecsters wrote:

"Guys, from what I noticed, you came back strong. Very interesting this question. Let me see if I understood, especially because I am using a translator to talk to you. In this case, each portfolio strategy would have a true or false button so that each one can be deactivated or activated, or just a button for new open or closed trades to prevent it from continuing to open trades from a certain point, allowing us to switch to new strategies."

Yes that is the idea.
My need was turning off the entry or exit logic for single strategy EAs, but from what I understand, Popov is also going to implement this for each strategy in a portfolio EA.

Re: Disable entry or exit signal for single strategy EAs

>  Popov is also going to implement this for each strategy in a portfolio EA.

That's right!

I'm thinking of having options like;

--- Individual Strategies  Control --
001 - enable entry - true
001 - enable exit   - true
002 - enable entry - true
002 - enable exit   - true
...
099 - enable entry - true
099 - enable exit   - true

...

I'm also thinking of showing the individual strategies' performance information in the chart. We will discuss this in a separate topic.

Re: Disable entry or exit signal for single strategy EAs

Good morning friends
Mr popov you came back even inspired lol
You know that in the past I thought about something like this, but I believe that the number of imputs in meta Trader has a limit
The number of external True is false has one. Maximum number of 120 if not me. Deception is the portfolio has a maximum strategy number of 300

Posts: 18

Pages 1

You must login or register to post a reply

Forex Software → Expert Advisor Studio → Disable entry or exit signal for single strategy EAs

Similar topics in this forum