Opening, closing in Expert Advisor generated by MQL5 Wizard

 
Comments not related to "Aggregating Moving Average signals from different timeframes" have been moved to this thread.
 
Andy:

Tell me, can the trading signals module only open sell and buy, without closing or reversing them?


The trading signals module ONLY gives "can buy" and "can sell" signals. The rest of the logic for opening, closing and flipping is implemented in the CExpert class.

 
Andy:

When using LongCondition and ShortCondition, I have a buy open and if the sell condition is met, it opens with a buy close. ...


What type of account: netting or hedge?

Question 2: before writing your own trading signals module, have you tried to generate an EA on one of the standard trading signals modules and understand how it works?

Question 3: Have you read these articles:MQL5 Wizard: The New Version andCreate a Trading Robot in 6 Steps?

 
Andy:
This is the same for netting and hedging accounts, I generated an Expert Advisor from the standard MA signal module, it opens and closes immediately when changing from long to short...

Here's where you need to go more in-depth. From you:

  • A generated Expert Advisor based on a standard signal module,
  • account type (netting or hedge),
  • screenshot from the strategy tester - "Settings" tab
  • screenshot from the strategy tester - "Settings" tab
  • specify the date and number of the trade the issue is about...

 
Andy:
You can simply generate an EA on the MA signal module - and you will see that there is a continuous opening and closing of the short and there is no position holding simply to a stop or manual closing, the position is always reversed!

This is a technical forum, not a telepathic forum. If you want an accurate answer, then don't be lazy to provide the data:

Forum on trading, automated trading systems and testing trading strategies

Summarizing signals from Moving Average from different timeframes

Vladimir Karputov, 2017.09.02 14:29


And here's where you need to elaborate. From you:

  • generated Expert Advisor based on the standard signals module,
  • type of account (netting or hedge),
  • screenshot from the Strategy Tester - "Settings" tab
  • screenshot from the strategy tester - "Settings" tab
  • specify the date and number of the trade for which there are questions...


 
Andy:
And in principle, any signals module can only open a position and that's it, without the EA closing it - is there a code example?

The trading signals module does NOT CLOSE or OPEN positions - it only generates a "Open Buy" or "Open Sell" signal.


 
Andy:
... It is only possible to open a position and that's it, without the EA closing it - is there a code example?

Set the parameter, which is responsible for the final score to close the position

Closing threshold

equal to 100 and most likely your Expert Advisor will close no trades.

 

Good evening! I am joining the discussion. I, too, am interested in the possibility of implementing in the module (trading signals) signals to open and close long and short positions. I read the previously mentioned articles, but could not find a solution to the problem.

For instance, I wanted to implement signals to open Buy/Sell position by crossover of two MAs with time filter and close position by reverse crossover of two MAs (without time filter) or by SL/TP. The only way out was to use the ready-made Expert Advisor - https://www.mql5.com/ru/code/261 but SL and TP are not considered there and my own attempt to add SL and TP into the code was a failure.

If this module could be implemented, it would be convenient to generate Expert Advisors with necessary trailing bars and money management

Мастер MQL5 - Торговые сигналы по пересечению двух экспоненциальных скользящих средних
Мастер MQL5 - Торговые сигналы по пересечению двух экспоненциальных скользящих средних
  • votes: 18
  • 2011.01.11
  • MetaQuotes Software Corp.
  • www.mql5.com
Торговые сигналы по пересечению двух экспоненциально сглаженных скользящих средних "Signals based on crossover of two EMA".
 
PeretsCHILI:

...

For example, I wanted to implement signals to open Buy/Sell position by crossing two MAs with a time filter, and to close by the opposite crossing of two MAs (without a time filter),

...


Make two modules of custom indicator trading signals: one module may give signals ONLY for opening, the second module may give signals ONLY for closing. You can also implement it in one module - you only need to adjust weights of each signal and in the Expert Advisor to adjust levels for opening and closing (variables Signal threshold value to open [0...100] and Signal threshold value to close [0...100]).

 

PeretsCHILI:

...

К примеру, хотел реализовать сигналы на открытие позиции Buy/Sell по пересечению двух МА с фильтром времениа закрытие происходит по обратному пересечению двух МА (без фильтра времени)

...

Vladimir Karputov:

Make two modules of custom indicator trading signals: one module should give signals ONLY for opening, the second module should give signals ONLY for closing. This can also be implemented in one module - you only need to adjust weights of each signal and in the Expert Advisor to adjust levels for opening and closing (variables Signal threshold value to open [0...100] and Signal threshold value to close [0...100]).


PeretsCHILI: To write such a module, you should clearly describe "what it is - the crossover of two Moving Average indicators". Try to formulate the task "What should be considered as crossing of two indicators of Moving Average" accurately and clearly. I assure you there will be many surprises for you :)

 

I have decided on the wording of the problem:

open long: fast MA crosses slow MA from bottom to top, plus time filter

close long: fast МА intersects slow MA from above downwards

Open short: fast МА intersects slow MA from above and plus time filter

close shorts: fast МА intersects slow MA from bottom to top.

In the previously mentioned example CheckOpenLong, CheckCloseLong, CheckOpenShort, CheckCloseShort were used for this respectively.

If you make two modules, one with signals for opening and one for closing, I understand that the first would use LongCondition and ShortCondition, as in the standard module library. What to use in the second module for closing?