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

 

#property version "1.07"

Changed the colour of the buttons.

Alpari MT5

I don't use buttons - just as an information panel

 
Aleksandr Klapatyuk:

#property version "1.07"

Changed the colour of the buttons.

buttons are not used - just as an information bar

and another colour

Alpari MT5.png

Files:
 

tell me who author of this code -(or originally I downloaded another code from the link you gave meSpeed-v1.mq548 kb)

because it's like this

//+------------------------------------------------------------------+
//| AVGiS.mq5 |
//| Copyright 2017, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"

is it him?

SEM

i got it - when positions get to profit - by pressing the button, more positions will open in the direction of

EURUSDH2 USDCHFH2.png

No, it turns out that when the horizontal line worked for the sell, the buy button works for the sell button and the sell button does not work ----- probably the reversal button should be used.

I will have to experiment to see what is best, but a reversal would probably help.

 

#property version "1.08"

added a reversal button.

and in the settings, changed the location

button setup

input string   t9="------ Button: AVGiS -----";         // AVGiS
input bool     ObjectLineX             = false;         // Button: Horizontal Line(true) || Buy/Sell(false)
input bool     TickRevers              = false;         // Button: Revers
input int      TrailingStop_STOP_LEVEL = 350;           // Trailing Stop LEVEL
input ENUM_TIMEFRAMES _period          = PERIOD_CURRENT;// period
input int      limit_total_symbol      = 190;           // limit_total_symbol
input int      limit_total             = 190;           // limit_total
//---

When opening a position, stop loss is set immediately - but so is the trawl (it's a yellow horizontal line), to disable it, just set 0

input string   t2="------ Obj:Trailing Line     --- ";  // Trailing Obj:Line
input double   InpStopLoss             = 55;            // Obj: Stop Loss, in pips (1.00045-1.00055=1 pips) ------------------что бы отключить, ставим 0 !!!!!!
input ushort   InpObjTrailingStop      = 27;            // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStep      = 9;             // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)

but the stop loss will not be at the same position, it will be pulled up by the trailinginput ushort InpObjTrailingStop = 27;// Obj: Trailing Stop (distance from price to object, in pips)

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

I don't understand how these buttons work.

Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Типы объектов
Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Типы объектов
  • www.mql5.com
При создании графического объекта функцией ObjectCreate() необходимо указать тип создаваемого объекта, который может принимать одно из значений перечисления ENUM_OBJECT. Дальнейшие уточнения свойств созданного объекта возможно с помощью функций по работе с графическими объектами.
Files:
2.mq5  17 kb
 

#property version "1.09"

Added another button - deletes all open positions for all pairs.

Deletes Expert Advisor and changes chart template

Alpari MT5XXX

Files:
2.mq5  17 kb
 

#property version "1.10"

added, hide buttons.

I messed up here - it works on demo, but on real it got error 2019.11.05 15:51:33.103 AVGiS intelligence (GBPUSD,H1) array out of range in 'AVGiS intelligence.mq5' (176,34)

   //+------------------------------------------------------------------+
   //| Calculate optimal lot size                                       |
   //+------------------------------------------------------------------+
   double            TradeSizeOptimized(void)
     {
      double price=0.0;
      double margin=0.0;
      string arr[];
      int resize = 0, syTotal = SymbolsTotal(true);
      for(int i = 0; i < syTotal; i++)
        {
         string name = SymbolName(i, true);
         if(SymbolInfoInteger(name, SYMBOL_VISIBLE))
           {
            resize = ArrayResize(arr, i+1);
            arr[i] = name;
           }
         //--- select lot size

         if(!SymbolInfoDouble(arr[i],SYMBOL_ASK,price))
            return(0.0);
         if(!OrderCalcMargin(ORDER_TYPE_BUY,arr[i],1.0,price,margin))
            return(0.0);
         if(margin<=0.0)
            return(0.0);
        }
      double lot=NormalizeDouble(AccountInfoDouble(ACCOUNT_MARGIN_FREE)*MaximumRisk/margin,2);
      //--- calculate number of losses orders without a break
      if(DecreaseFactor>0)
        {
         //--- select history for access
         HistorySelect(0,TimeCurrent());
         //---
         int    orders=HistoryDealsTotal();  // total history deals
         int    losses=0;                    // number of losses orders without a break

         for(int y=orders-1; y>=0; y--)
           {
            ulong ticket=HistoryDealGetTicket(y);
            if(ticket==0)
              {
               Print("HistoryDealGetTicket failed, no trade history");
               break;
              }
            for(int i = 0; i < syTotal; i++)
              {
               string name = SymbolName(i, true);
               if(SymbolInfoInteger(name, SYMBOL_VISIBLE))
                 {
                  resize = ArrayResize(arr, i+1);
                  arr[i] = name;
                 }
               //--- check symbol
               if(HistoryDealGetString(ticket,DEAL_SYMBOL)!=arr[i])
                  continue;
               //--- check Expert Magic number
               if(HistoryDealGetInteger(ticket,DEAL_MAGIC)!=Magic_Number)
                  continue;
               //--- check profit
               double profit=HistoryDealGetDouble(ticket,DEAL_PROFIT);
               if(profit>0.0)
                  break;
               if(profit<0.0)
                  losses++;
              }
           }
         //---
         if(losses>1)
            lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
        }
      for(int i = 0; i < syTotal; i++)
        {
         string name = SymbolName(i, true);
         if(SymbolInfoInteger(name, SYMBOL_VISIBLE))
           {
            resize = ArrayResize(arr, i+1);
            arr[i] = name;
           }
         //--- normalize and check limits
         double stepvol=SymbolInfoDouble(arr[i],SYMBOL_VOLUME_STEP);
         lot=stepvol*NormalizeDouble(lot/stepvol,0);
         double minvol=SymbolInfoDouble(arr[i],SYMBOL_VOLUME_MIN);
         if(lot<minvol)
            lot=minvol;
         double maxvol=SymbolInfoDouble(arr[i],SYMBOL_VOLUME_MAX);
         if(lot>maxvol)
            lot=maxvol;
        }
      //--- return trading volume
      return(lot);
     }
   //+------------------------------------------------------------------+
 

here's a working expert

Files:
 

Added to the previous Expert, two methods for the Horizontal line.

1 possibility : line 1 will open line 4 at a given distance, line 2 will open line 3at a given distance.

input string   t3="------ Obj:Name 1-2-3-4 ------";     // Имя Объекта
input string   InpObjUpNameZ           = "TOP 1";       // Obj: TOP (Name Obj) ВВЕРХУ 1
input string   InpObjDownNameZ         = "LOWER 2";     // Obj: LOWER (Name Obj) ВНИЗУ 2
input int      Step                    = 5;             // Obj: Шаг сетки, пунктов(0 = false)
input string   InpObjDownName0         = "TOP 3";       // Obj: TOP (Name Obj) ВВЕРХУ 3
input ENUM_TRADE_COMMAND InpTradeCommand=open_sell;     // Obj:  command:
input string   InpObjUpName0           = "LOWER 4";     // Obj: LOWER (Name Obj) ВНИЗУ 4
input ENUM_TRADE_COMMAND InpTradeCommand0=open_buy;     // Obj:  command:

2nd possibility: line 7 will open a line 10 at a given distance which moves behind the price and when the price touches it, a command will trigger. line 8 will open a line 9 at a given distance, - the same action as for 7 and 10

input string   t5="- 2_Obj:Trailing Line 7-8-9-10 --- ";// Trailing Obj:Line
input string   InpObjUpNameZx          = "TOP 7";       // Obj: TOP (Name Obj) ВВЕРХУ 7
input string   InpObjDownNameZx        = "LOWER 8";     // Obj: LOWER (Name Obj) ВНИЗУ 8
input int      StepZx                  = 5;             // Obj: Шаг сетки, пунктов(0 = false)
input string   InpObjUpNameX           = "TOP 9";       // Obj: TOP (Horizontal Line) ВВЕРХУ 9
input ENUM_TRADE_COMMAND InpTradeCommandX=open_sell;    // Obj:  command:
input string   InpObjDownNameX         = "LOWER 10";    // Obj: LOWER (Horizontal Line) ВНИЗУ 10
input ENUM_TRADE_COMMAND InpTradeCommand0X=open_buy;    // Obj:  command:
input ushort   InpObjTrailingStopX     = 5;             // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStepX     = 5;             // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Типы объектов
Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Типы объектов
  • www.mql5.com
При создании графического объекта функцией ObjectCreate() необходимо указать тип создаваемого объекта, который может принимать одно из значений перечисления ENUM_OBJECT. Дальнейшие уточнения свойств созданного объекта возможно с помощью функций по работе с графическими объектами.
Files:
 
Aleksandr Klapatyuk:

Added to the previous Expert, two methods for the Horizontal line.

1 possibility : line 1 will open line 4 at a given distance, line 2 will open line 3 at a given distance.

2 possibilities: line 7 will open a line 10 at a given distance which moves behind the price and when the price touches it, a command will trigger. line 8 will open a line 9 at a given distance, - the same action as for 7 and 10.

tried how it works

EURJPYM301.png

EURJPYM302

EURJPYM303

you could have changed in the settings from that line - would have opened a sell

Files:
 
Aleksandr Klapatyuk:

Added to the previous Expert, two methods for the Horizontal line.

1 possibility : line 1 will open line 4 at a given distance, line 2 will open line 3 at a given distance.

2nd possibility: line 7 will open a line 10 at a given distance, which moves behind the price and when the price touches it, a command will trigger. line 8 will open a line 9 at a given distance, - the same action as for 7 and 10.

in the first possibility, lines 4 and 3 will open at a given distance, up to infinity

Files: