How I assemble my advisor by trial and error - page 18

 

manually or from the trend line buy

from the indicator stop

EURUSDM1

I just tweaked the Expert Advisor a little bit.

Files:
2.mq5  17 kb
Hand_support.mq5  160 kb
 
Aleksandr Klapatyuk:

manually or from the trend line buy

from the indicator stop

I just tweaked the Expert Advisor a little bit.

...

hope you got the answer to your question about mt4 setup ... :-)

 
Roman Shiredchenko:

...

hope your question was answered by the mt4 installation address... :-)

Yes! Thank you!

 

changed a little bit.

Reverse - reversal of a trading signal.

for the indicator has its own reversal. for the trend line to buy has its own reversal.

and separately for the trend line to close the position the reversal.

Example: draw sell trendline - as soon as the price touches the line - buy signal

GBPUSDM5

on the following picture - the trend line triggered sell - and made a buy

reverse was triggered

input string   t7="------ ТРЕНД ЛИНИЯ ------";        // 
input bool     InpReverse0          = true;          // Reverse Open - переворот торгового сигнала

GBPUSDM5

sinput string  t1="------ Как работать Эксперту---";  //    
input double   InpLots              = 0.01;           // Lots
input bool     InpPanel             = true;           // Скрыть кнопки\\по времени Buy\Sell
input bool     InpOnlyLimit         = false;          // Выставить отложенный ордер 
input bool     InpOnlystart         = true;           // Вкл. Buy\Sell
input bool     InpCloseOpposite     = false;          // Вкл.Trailing Stop по индикатору\Close opposite 
input bool     InpReverse           = false;          // Reverse Indicators - переворот торгового сигнала
input string   t7="------ ТРЕНД ЛИНИЯ ------";        // 
input bool     InpReverse0          = false;          // Reverse Open - переворот торгового сигнала
input string   BuyStop_TrendName    = "buy";          // Trend Line Name "buy";
input string   SellStop_TrendName   = "sell";         // Trend Line Name "sell";
input string   BuyClose_TrendName   = "closesell";    // Trend Line Name "closesell";
input string   SellClose_TrendName  = "closebuy";     // Trend Line Name "closebuy";
input bool     InpReverse1          = false;          // Reverse Close - переворот торгового сигнала
//+------------------------------------------------------------------+
Совершение сделок - Торговые операции - MetaTrader 5
Совершение сделок - Торговые операции - MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением текущими позициями путем их модификации или закрытия. Платформа позволяет удобно просматривать торговую историю на счете, настраивать оповещения о событиях на рынке и многое другое. Открытие позиций...
Files:
Hand_support.mq5  161 kb
2.mq5  17 kb
 
All for manual operation
Files:
 

something needs to be done - with the trend line on the close

the trend line didn't work with the reverse

but Take Profit worked on pips

EURGBPH2

Общие принципы - Торговые операции - MetaTrader 5
Общие принципы - Торговые операции - MetaTrader 5
  • www.metatrader5.com
Перед тем как приступить к изучению торговых функций платформы, необходимо создать четкое представление об основных терминах: ордер, сделка и позиция. — это распоряжение брокерской компании купить или продать финансовый инструмент. Различают два основных типа ордеров: рыночный и отложенный. Помимо них существуют специальные ордера Тейк Профит...
 
Aleksandr Klapatyuk:

something needs to be done - with the trend line on the close

the trend line didn't work with the reverse.



I don't know if I got it right.

but what it is, it's all working.

All right - I've had enough of everyone.

Rain bad mood.

Files:
Hand_support.mq5  161 kb
 

Added another function.

closing the position will open in the opposite direction

//+------------------------------------------------------------------+
//| TradeTransaction function                                        |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction &Trans,const MqlTradeRequest &Request_,const MqlTradeResult &Result_)
  {
//--- get transaction type as enumeration value
   ENUM_TRADE_TRANSACTION_TYPE type=Trans.type;
//--- if transaction is result of addition of the transaction in history
   static bool Flag=true;
   if(Flag)
      if(inpbuysell)
         if(type==TRADE_TRANSACTION_DEAL_ADD)
           {
            long     deal_type         =-1;
            long     deal_entry        =-1;
            double   deal_volume       =0.0;
            string   deal_symbol       =NULL;
            if(HistoryDealSelect(Trans.deal))
              {
               deal_type         =HistoryDealGetInteger(Trans.deal,DEAL_TYPE);
               deal_entry        =HistoryDealGetInteger(Trans.deal,DEAL_ENTRY);
               deal_volume       =HistoryDealGetDouble(Trans.deal,DEAL_VOLUME);
               deal_symbol       =HistoryDealGetString(Trans.deal,DEAL_SYMBOL);
              }
            else
               return;
            if(deal_entry==DEAL_ENTRY_OUT)
              {
               switch((int)deal_type)
                 {
                  case  DEAL_TYPE_BUY:
                     ExtTrade.Buy(deal_volume,deal_symbol);
                     break;
                  case  DEAL_TYPE_SELL:
                     ExtTrade.Sell(deal_volume,deal_symbol);
                     break;
                  default:
                     break;
                     Flag=false;
                 }
              }
           }
  }
//+------------------------------------------------------------------+
Files:
 
Aleksandr Klapatyuk:

Added another function.

When you close a position, it opens in the opposite direction

If it opens, it opens -

But on all pairs - which are open.

------------------------------------------------------------------

I corrected it a little - to make reverse work on each pair - separately

//+------------------------------------------------------------------+
//| TradeTransaction function                                        |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction &Trans,const MqlTradeRequest &Request_,const MqlTradeResult &Result_)
  {
//--- if transaction is result of addition of the transaction in history
   static bool Flag=true;
//--- get transaction type as enumeration value
   ENUM_TRADE_TRANSACTION_TYPE type=Trans.type;
   if(Flag && inpbuysell)
      if(type==TRADE_TRANSACTION_DEAL_ADD)
        {
         long     deal_type         =-1;
         long     deal_entry        =-1;
         double   deal_volume       =0.0;
         string   deal_symbol       =deal_symb;
         if(HistoryDealSelect(Trans.deal))
           {
            deal_type         =HistoryDealGetInteger(Trans.deal,DEAL_TYPE);
            deal_entry        =HistoryDealGetInteger(Trans.deal,DEAL_ENTRY);
            deal_volume       =HistoryDealGetDouble(Trans.deal,DEAL_VOLUME);
            deal_symbol       =HistoryDealGetString(Trans.deal,DEAL_SYMBOL);
           }
         else
            return;
         if(deal_entry==DEAL_ENTRY_OUT && deal_symbol==deal_symb)
           {
            switch((int)deal_type)
              {
               case  DEAL_TYPE_BUY:
                  ExtTrade.Buy(deal_volume,deal_symbol);
                  break;
               case  DEAL_TYPE_SELL:
                  ExtTrade.Sell(deal_volume,deal_symbol);
                  break;
               default:
                  break;
                  Flag=false;
              }
           }
        }
  }
//+------------------------------------------------------------------+
 

trawl in a ParabolicSAR way from the thermal

//+------------------------------------------------------------------+
//|                                         TrailingParabolicSAR.mq5 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Include                                                          |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>
#include <Expert\Trailing\TrailingParabolicSAR.mqh>
//+------------------------------------------------------------------+
//| Inputs                                                           |
//+------------------------------------------------------------------+
//--- inputs for trailing
input double Trailing_ParabolicSAR_Step   =0.02;  // Speed increment
input double Trailing_ParabolicSAR_Maximum=0.2;   // Maximum rate
//---
bool         Expert_EveryTick=false;
//+------------------------------------------------------------------+
//| Global expert object                                             |
//+------------------------------------------------------------------+
CExpert ExtExpert;
//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Initializing expert
   if(!ExtExpert.Init(Symbol(),Period(),Expert_EveryTick,0))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing expert");
      ExtExpert.Deinit();
      return(-1);
     }
//--- Creation of trailing object
   CTrailingPSAR *trailing=new CTrailingPSAR;
   if(trailing==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating trailing");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Add trailing to expert (will be deleted automatically))
   if(!ExtExpert.InitTrailing(trailing))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing trailing");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Set trailing parameters
   trailing.Step(Trailing_ParabolicSAR_Step);
   trailing.Maximum(Trailing_ParabolicSAR_Maximum);
//--- Tuning of all necessary indicators
   if(!ExtExpert.InitIndicators())
     {
      //--- failed
      printf(__FUNCTION__+": error initializing indicators");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- ok
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Deinitialization function of the expert                          |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ExtExpert.Deinit();
  }
//+------------------------------------------------------------------+
//| "Tick" event handler function                                    |
//+------------------------------------------------------------------+
void OnTick()
  {
   ExtExpert.OnTick();
  }
//+------------------------------------------------------------------+
//| "Trade" event handler function                                   |
//+------------------------------------------------------------------+
void OnTrade()
  {
   ExtExpert.OnTrade();
  }
//+------------------------------------------------------------------+
//| "Timer" event handler function                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   ExtExpert.OnTimer();
  }
//+------------------------------------------------------------------+

Checked it - it works.

Alpari MT5

Files:
Reason: