Twisting and turning, iMA's trying to cheat - page 8

 
<br / translate="no">
Vladimir Karputov:

Your question is unclear.


The goal is to move away from the price value itself in the EA, replacing it with an iMA

Artyom Trishkin:

To get Moving Average data with deviation, you need to add / subtract the required deviation in pips*Point() to the returned value

Thanks to

 

Expert Advisor generated by MQL5 Wizard based on TWO signal modules "SignalMAAboveBelow.mqh" - one signal with an averaging period of 100 and the other with an averaging period of 200.

Made some small changes in OnInit():

//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit()
  {
   if((Signal_0_MA_Weight+Signal_1_MA_Weight)*100/2<Signal_ThresholdOpen ||
      (Signal_0_MA_Weight+Signal_1_MA_Weight)*100/2<Signal_ThresholdClose)
      return(INIT_PARAMETERS_INCORRECT);

//--- Initializing expert
   if(!ExtExpert.Init(Symbol(),Period(),Expert_EveryTick,Expert_MagicNumber))
     {
...
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//---
   string text="MA ("+Signal_0_MA_PeriodMA+"), Reverse ("+Signal_0_MA_Reverse+")"+"\n"+
               "MA ("+Signal_1_MA_PeriodMA+"), Reverse ("+Signal_1_MA_Reverse+")";
   Comment(text);

//--- ok
   return(INIT_SUCCEEDED);
  }

First, we check the condition that the sum of weights of signals divided in two must not be less than the threshold value of opening or closing a position. This edit allows you to discard passes during optimization where there is not a single trade.

Second edit: displays on the chart visual information about averaging periods and "Reverse" parameter.

 

Modernized trailing (based on standard \MQL5\Include\Expert\Trailing\TrailingParabolicSAR.mqh)) - standard trailing module used to move StopLoss by the iSAR value on the bar with index "1" - but such behavior allowed a strong lag of the price and, as a result, a loss of potential profit.

And since the main Expert Advisor "SignalMAAboveBelow_x2_iSAR_trailing.mq5" works only when a new bar appears, I decided to change the standard trailing module - now StopLoss is set by the iSAR value on the bar with index "0". The upgraded trailing module is saved under the name "SignalMAAboveBelow_x2_iSAR_trailing.mq5" saved in the following folder: C:\Users\barab\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\Researches iMA\SignalMAAboveBelow_x2_iSAR_trailing.mq5.

The main Expert Advisor SignalMAAboveBelow_x2_iSAR_trailing.mq5 has been changed accordingly:

#property link      "http://wmua.ru/slesar/"
#property version   "1.002"
//+------------------------------------------------------------------+
//| 1.002:                                                           |
//|  trailing -> TrailingParabolicSAR(aggressive).mqh                |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Include                                                          |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>
//--- available signals
#include <Expert\Signal\SignalMAAboveBelow.mqh>
//--- available trailing
#include <Expert\Trailing\TrailingParabolicSAR(aggressive).mqh>
//--- available money management
#include <Expert\Money\MoneyFixedLot.mqh>

Trailing now works as follows:

before trailing

Before trailing


Trailing iSAR value on bar "0"

Trailing on the iSAR value on the bar "0".

Please attach the file of the upgraded trailing unit and the Expert Advisor file...

 

Vladimir, when installing in"Data Directory"\MQL5\Include\Expert\Signal\ MetaEditor gives the same errors. Maybe it's just the MT version that has been updated? I have 1545. Are the EAs in this thread rewritten or just modified? What would be the best way to start writing a similar EA and change the order opening conditions?

 
imtochukwu:

Vladimir, when installing in"Data Directory"\MQL5\Include\Expert\Signal\ MetaEditor gives the same errors. Maybe it's just the MT version that has been updated? I have 1545. Are the EAs in this thread rewritten or just modified? What would be the best way to start writing a similar EA and change the order opening conditions?


Which file do you put in the "Data folder"{MQL5\Include\Expert\Signal)?
 
Vladimir Karputov:

Which file do you put in the "Data directory"\MQL5\Include\Expert\Signal\ folder?

SignalMAAboveBelow_x2_iSAR_trailing.mq5 this file, for example. It generates 25 errors.
Files:
pprtgh.JPG  221 kb
 
imtochukwu:

SignalMAAboveBelow_x2_iSAR_trailing.mq5 this file, for example. It shows 25 errors.

"SignalMAAboveBelow_x2_iSAR_trailing.mq5" is an Expert Advisor, not a signal module. Click on the file, it will be downloaded. Click on the downloaded file - it will be opened in MetaEditor.
 
Vladimir Karputov:

"SignalMAAboveBelow_x2_iSAR_trailing.mq5" is an EA, not a signal module. Click on the file - it will be downloaded. Click on the downloaded file - it will be opened in MetaEditor.

Vladimir, it's clear as day. But you have to download it in"Data Folder"\MQL5\Include/Expert\Signal/ directory, don't you? How can I compile the file without errors?
 
imtochukwu:

Vladimir, it's clear as day. But you're saying to download it in"Data Folder"\MQL5\Include\Expert\Signal`, aren't you? How to compile a file without errors?


You got it wrong.

  • TheSignalMAAboveBelow.mqh MODULE must be downloaded to the folder"Data Directory"\MQL5\Include\Expert\Signal\.
  • SignalMAAboveBelow_x2_iSAR_trailing.mq5" just need to download and click on it, the editor will start and compile the "SignalMAAboveBelow_x2_iSAR_trailing.mq5" in the editor.

 
Vladimir Karputov:


You got it wrong.

  • TheSignalMAAboveBelow.mqh MODULE must be downloaded to the folder"Data Directory"\MQL5\Include\Expert\Signal\.
  • Download and click on theSignalMAAboveBelow_x2_iSAR_trailing.mq5DATUMENT and use the editor to compile the SignalMAAboveBelow_x2_iSAR_trailing.mq5 DATUMENT.


Vladimir, I figured it out, I have run it. Where can I swap sell orders with buy orders here?
Reason: