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

 
Alexsandr San:

Yes! You should also add this to the Utilityhttps://www.mql5.com/ru/code/23939


#property version "1.009"

Added this Function

input string   t10="----- Price Line:     -----";                //
input string   InpFont0                     = "BUY";             // Obj: BUY (Obj:Name) ВЕРХУ
input ENUM_TRADE_COMMAND InpCSCommand       = close_open_b;      // Obj:  command:
input string   InpFont1                     = "SELL";            // Obj: SELL (Obj:Name) ВНИЗУ
input ENUM_TRADE_COMMAND InCSCommand        = close_open_s;      // Obj:  command:
input string   InpFont2                     = "LOW Up";          // Obj: Name Price Line BUY
input string   InpFont3                     = "LOW Down";        // Obj: Name Price Line SELL
input ushort   InpIndentUp                  = 5;                 // Indent up, in pips (1.00045-1.00055=1 pips)
input ushort   InpIndentDown                = 10;                // Indent down, in pips (1.00045-1.00055=1 pips)
input int      InpSeconds                   = 3;                 // Number of seconds

under Indicator, need one name - LOW

input string   InpFont2                     = "LOW Up";          // Obj: Name Price Line BUY
input string   InpFont3                     = "LOW Down";        // Obj: Name Price Line SELL
Files:
 
Alexsandr San:

#property version "1.009"

I have added this function

under Indicator, need one name - LOW

Forgot! Disable this Function

#property version "1.010"

input string   InpFont2                     = "LOW Up";          // Obj: Name Price Line BUY
input string   InpFont3                     = "LOW Down";        // Obj: Name Price Line SELL
input ushort   InpIndentUp                  = 5;                 // Indent up, in pips (1.00045-1.00055=1 pips)
input ushort   InpIndentDown                = 10;                // Indent down, in pips (1.00045-1.00055=1 pips)
input int      InpSeconds                   = 3;                 // Number of seconds
input bool     InpOnTimer                   = false;             // OnTimer "LOW Up" "LOW Down"
Files:
 

What can this utility do!? - yes! practically everything, all your fantasies in one .

GBPUSDM30

 
Alexsandr San:

What can this utility do!? - yes! practically everything, all your fantasies in one .

Well if the price comes to a crossover point, then yes)))) for sure

 
Alexsandr San:

What can this utility do!? - Yes! Pretty much everything, all your fantasies in one .

I'm asking for another function in this utility - trawl, behind the horizontal blue line

Asking for this utility 1

Snapshot2 2

Here I am, manually, moving the yellow horizontal line and a stop is triggered.

Snapshot3 3

 
Alexsandr San:

This utility is asking for another function - trawl, behind the horizontal blue line

1

2

Here I manually, moved the yellow horizontal line and triggered a stop

3

It is behind the horizontal line - it remains to be seen which calculation is done in the indicator Low_Macd_Line.mq5 to trawl behind the blue one

Photo by

in the picture - top blue, touching the upper yellow one, triggers the signal

and the lower blue one, touching the lower yellow one, triggers the signal

 
Alexsandr San:

It is behind the Horizontal lines - it remains to be seen which calculation is made in the Low_Macd_Line.mq5 indicator to trawl behind the blue one

in the picture - top blue, touching the upper yellow one, triggers the signal

and the lower blue one, touching the lower yellow one, triggers the signal

Was able to fix the trawl in the indicator windowLow_Macd_Line.mq5 worked - now on Monday, to get it right and update the utility

Shot4

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

here is the trawl itself

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTickObjTrailingCS(void)
  {
//---
   if(InpSignalsFrequency>=10) // trailing no more than once every 10 seconds
     {
      datetime time_current=TimeCurrent();
      if(time_current-m_obj_last_trailingCS>10)
        {
         if(RefreshRates())
            ObjTrailingCS();
         else
            return;
         m_obj_last_trailingCS=time_current;
        }
     }
//--- we work only at the time of the birth of new bar
   datetime time_0=iTime(m_symbol.Name(),Period(),0);
   if(time_0==m_prev_barsCS)
      return;
   m_prev_barsCS=time_0;
   if(InpSignalsFrequency<10) // trailing only at the time of the birth of new bar
     {
      if(RefreshRates())
         ObjTrailingCS();
     }
  }
//+------------------------------------------------------------------+
//| Object Trailing                                                  |
//|   InpObjTrailingStop: min distance from price to object          |
//+------------------------------------------------------------------+
void ObjTrailingCS(void)
  {
   double new_up_price        = -1;   //
   double new_down_price      = 1;   //
   double current_up_price    = ObjectGetDouble(0,InpFont0,OBJPROP_PRICE);
   double current_down_price  = ObjectGetDouble(0,InpFont1,OBJPROP_PRICE);
   double price_up            = ObjectGetDouble(0,InpFont2,OBJPROP_PRICE);
   double price_down          = ObjectGetDouble(0,InpFont3,OBJPROP_PRICE);

   if(current_up_price>new_up_price)
     {
      if(current_up_price>price_up+InpObjTrail)
        {
         m_obj_up_priceCS=price_up+InpObjTrail;
         HLineMove(0,InpFont0,m_obj_up_priceCS);
        }
     }
   if(current_down_price<new_down_price)
     {
      if(current_down_price<price_down-InpObjTrail)
        {
         m_obj_down_priceCS=price_down-InpObjTrail;
         HLineMove(0,InpFont1,m_obj_down_priceCS);
        }
     }
  }
//+------------------------------------------------------------------+
 
Alexsandr San:

Managed to get the trawl in theLow_Macd_Line.mq5 indicator window working - now on Monday, get it right and update the Utility

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

here is the trawl itself

Maybe someone will be interested in playing with this function in the tester - I am pasting the utility, it is purely for the tester, you also need this indicatorLow_Macd_Line.mq5

the function itself Here-

input string   t10="----- Price Line:     -----";                //
input string   InpFont0                     = "BUY";             // Obj: BUY (Obj:Name) ВЕРХУ
input ENUM_TRADE_COMMAND InpCSCommand       = close_open_b;      // Obj:  command:
input string   InpFont1                     = "SELL";            // Obj: SELL (Obj:Name) ВНИЗУ
input ENUM_TRADE_COMMAND InCSCommand        = close_open_s;      // Obj:  command:
input double   InpObjTrail                  = 0.0001;            // Obj: Trailing Stop MACD
input double   InpObjTrailStep              = 0.0001;            // Obj: Trailing Step MACD
input ushort   InpObjTrailingStopCS         = 15;                // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStepCS         = 5;                 // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
input string   InpFont2                     = "LOW Up";          // Obj: Name Price Line BUY
input string   InpFont3                     = "LOW Down";        // Obj: Name Price Line SELL
input ushort   InpIndentUp                  = 5;                 // Indent up, in pips (1.00045-1.00055=1 pips)
input ushort   InpIndentDown                = 10;                // Indent down, in pips (1.00045-1.00055=1 pips)
input int      InpSeconds                   = 3;                 // Number of seconds
input bool     InpOnTimer                   = true;              // OnTimer "LOW Up" "LOW Down"

when from the indicatorLow_Macd_Line.mq5 you need to set these Horizontal lines, one Name"LOW"

input string   InpFont2                     = "LOW Up";          // Obj: Name Price Line BUY
input string   InpFont3                     = "LOW Down";        // Obj: Name Price Line SELL
Files:
02_llliiiooo.mq5  255 kb
 
Alexsandr San:

One more function should be added to this utility - trawl, behind the horizontal blue line

#property version "1.011"

Trailing arm should be adjusted for each pair (for XAU/USD for 1 hour) for one minute 0.1001

On GBPUSD under one minute 0.0001

input double   InpObjTrail                  = 1.0001;            // Obj: Trailing Stop MACD ("0" -> Off)
input double   InpObjTrailStep              = 1.0001;            // Obj: Trailing Step MACD

The most important thing - when using the indicatorLow_Macd_Line.mq5

you have to correctly enter the name of the Horizontal line (there are two of them) - it's very important!!! What would the indicatorLow_Macd_Line.mq5 be in 1 window of the Indicator on the chart

input string   InpFont2                     = "LOW Up";          // Obj: Name Price Line BUY
input string   InpFont3                     = "LOW Down";        // Obj: Name Price Line SELL

It should be like this!

input string   InpFont2                     = "LOW";          // Obj: Name Price Line BUY
input string   InpFont3                     = "LOW";          // Obj: Name Price Line SELL

GBPUSDM1XX 1.

GBPUSDM1YY 2.

GBPUSDM1YY1 3.

GBPUSDM1YY2 4.

In the pictures - trawl worked and changed direction - now you want to manually, again set the horizontal line of SELL - in case this changes direction again

Files:
 
Alexsandr San:

#property version "1.011"

Trailing arm should be adjusted for each pair (for XAU/USD for 1 hour) for one minute 0.1001

On GBPUSD under one minute 0.0001

The most important - when the indicatorLow_Macd_Line.mq5

need to properly enter the name of the horizontal line (there are two) - more important!!! What would the indicatorLow_Macd_Line.mq5 was in 1 window of the indicator on the chart

#property version "1.012"

Slightly refined the Function

input string   t0="----- Price Line:        -----";              //
input string   InpFont0                     = "BUY";             // Obj: BUY (Obj:Name) ВЕРХУ
input ENUM_TRADE_COMMAND InpCSCommand       = close_open_b;      // Obj:  command:
input string   InpFont1                     = "SELL";            // Obj: SELL (Obj:Name) ВНИЗУ
input ENUM_TRADE_COMMAND InCSCommand        = close_open_s;      // Obj:  command:
input double   InpObjTrail                  = 1.0001;            // Obj: Trailing Stop MACD ("0" -> Off)
input double   InpObjTrailStep              = 1.0001;            // Obj: Trailing Step MACD
input bool     InpDub                       = false;             // "0.0":Price=false(Trail->Off) "LOW":Price=true(Trail->ON)
input bool     InpDubll                     = false;             // Duplicate "BUY""SELL" (ObjTrailStep)
input ushort   InpObjTrailingStopCS         = 15;                // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStepCS         = 5;                 // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
input string   InpFont2                     = "LOW Up";          // Obj: Name Price Line BUY
input string   InpFont3                     = "LOW Down";        // Obj: Name Price Line SELL
input bool     InpOnTimer                   = false;             // OnTimer "LOW Up" "LOW Down"
input ushort   InpIndentUp                  = 5;                 // Indent up, in pips (1.00045-1.00055=1 pips)
input ushort   InpIndentDown                = 10;                // Indent down, in pips (1.00045-1.00055=1 pips)

When triggered, horizontal line SELL opens a position and displays a horizontal line BUY and vice versa.

Also, the line is set either from "0" and distance is setby Obj: Trailing Step MACD

or from Horizontal line"LOW".


input double   InpObjTrailStep              = 1.0001;            // Obj: Trailing Step MACD
input bool     InpDub                       = false;             // "0.0":Price=false(Trail->Off) "LOW":Price=true(Trail->ON)
input bool     InpDubll                     = false;             // Duplicate "BUY""SELL" (ObjTrailStep)

FromTimer "LOW Up" "LOW Down" same, onlythe distance is set (input ushort InpObjTrailingStepCS = 5;// Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)

input ushort   InpObjTrailingStepCS         = 5;                 // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
input string   InpFont2                     = "LOW Up";          // Obj: Name Price Line BUY
input string   InpFont3                     = "LOW Down";        // Obj: Name Price Line SELL
input bool     InpOnTimer                   = false;             // OnTimer "LOW Up" "LOW Down"

How to know the distance of the horizontal line in the indicatorLow_Macd_Line.mq5 to set in the trail (on each pair, a different distance)

Copy and paste in the Utility settings

input double   InpObjTrailStep              = 1.0001;            // Obj: Trailing Step MACD

Photo by

in the picture from "0" to Horizontal BUY 0.0064 and when it touches Horizontal LOW, Horizontal SELL will be set (only below"0"-0.0064)

IMPORTANT!!! do not put minus ( - ) in front of figures, which we input into utility

Snapshot2 One of the Variants of this function

Files:
Reason: