MT4 script to MT5 horizontal line step

 

Hi, 

Can anyone point me in the write direction? I've been using this script for mt4 (as below). I want to start using mt5 but haven't been able to find an equivalent script in mql5. Tried contact the previous author but no reply.  I wanted to try code it myself (newbie) but to no avail.

Was unsure how to combine objectcreate with the step function; well ......my attempt didn't work. The links I found were:

Object create 

https://www.mql5.com/en/docs/objects/objectcreate 

Step

https://www.mql5.com/en/docs/standardlibrary/datastructures/carray 

Looking at the Step function, it states this is for dynamic arrays...but I'm thinking my price levels are static, they don't need to change with live price/timeframes or anything like that (or have I misunderstood?)

I don't necessarily want someone to write the script for me(although I would have no complaints if someone could, if simple enough), but I'd prefer to be pointed in the right direction from a learning perspective.


I also found a vline plotter script: 

https://www.mql5.com/en/code/618

...also presumed I could substitute the vline objectcreate code for hline, but again I think this script link is dynamic in the sense that it recalculates timeframes and leaving this part of the code out did not work. 

Any comments/links/suggestions would be appreciated. 

Thanks.

Dre. 

MT4 script: 

//< 1. Property 7 >===========================================================================================//<   1>
                                                                                                              //<   2>
#property       copyright                "Copyright (C) 2009, MetaQuotes Software Corp."                      //<   3>
#property       link                     "https://www.metaquotes.net"                                          //<   4>
                                                                                                              //<   5>
#define         A.System.Series          "AIS"                                                                //<   6>
#define         A.System.Modification    "70101"                                                              //<   7>
#define         A.System.ReleaseDate     "2009.06.26"                                                         //<   8>
#define         A.System.Program         "Horizontal Grid Plotter"                                            //<   9>
#define         A.System.Programmer      "Airat Safin                          https://www.mql4.com/users/Ais" //<  10>
                                                                                                              //<  11>
//</1. Property 7 >===========================================================================================//<  12>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////<  13>
//< 2. Constants 1 >==========================================================================================//<  14>
                                                                                                              //<  15>
#define         acs.HGPrefix             "AHGL_"                                                              //<  16>
                                                                                                              //<  17>
//</2. Constants 1 >==========================================================================================//<  18>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////<  19>
//< 3. Presets 7 >============================================================================================//<  20>
                                                                                                              //<  21>
#property       show_inputs                                                                                   //<  22>
                                                                                                              //<  23>
extern double   aed.HGMax              = 2.0000                                                             ; //<  24>
extern double   aed.HGStep             = 0.0100                                                             ; //<  25>
extern double   aed.HGMin              = 1.0000                                                             ; //<  26>
                                                                                                              //<  27>
extern color    aei.HGColor            = White                                                              ; //<  28>
extern int      aei.HGStyle            = 2                                                                  ; //<  29>
extern int      aei.HGBackground       = 0                                                                  ; //<  30>
                                                                                                              //<  31>
//</3. Presets 7 >============================================================================================//<  32>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////<  33>
//< 4. Main Program 11 >======================================================================================//<  34>
                                                                                                              //<  35>
int    init                           ()                                                                      //<  36>
{                                                                                                             //<  37>
                                                                                                              //<  38>
int             ali.HGPriceMax         = MathRound     ( aed.HGMax      / Point                           ) ; //<  39>
int             ali.HGPriceStep        = MathRound     ( aed.HGStep     / Point                           ) ; //<  40>
int             ali.HGPriceMin         = MathRound     ( aed.HGMin      / Point                           ) ; //<  41>
                                                                                                              //<  42>
for  ( int ali.Price = ali.HGPriceMin  ; ali.Price    <= ali.HGPriceMax ; ali.Price      += ali.HGPriceStep ) //<  43>
     {                                                                                                        //<  44>
       double          ald.HGLinePrice = ali.Price     * Point                                              ; //<  45>
       string          als.HGLineName  = acs.HGPrefix  + DoubleToStr    ( ald.HGLinePrice , Digits        ) ; //<  46>
       ObjectCreate  ( als.HGLineName  , OBJ_HLINE     , 0 , 0          , ald.HGLinePrice                 ) ; //<  47>
       ObjectSet     ( als.HGLineName  , OBJPROP_COLOR                  , aei.HGColor                     ) ; //<  48>
       ObjectSet     ( als.HGLineName  , OBJPROP_STYLE                  , aei.HGStyle                     ) ; //<  49>
       ObjectSet     ( als.HGLineName  , OBJPROP_BACK                   , aei.HGBackground                ) ; //<  50>
     } // for                                                                                                 //<  51>
                                                                                                              //<  52>
}                                                                                                             //<  53> 

//</4. Main Program 11 >======================================================================================//< 54> 

Documentation on MQL5: Object Functions / ObjectCreate
Documentation on MQL5: Object Functions / ObjectCreate
  • www.mql5.com
Object Functions / ObjectCreate - Documentation on MQL5
 
DreKn01:


Any comments/links/suggestions would be appreciated. 

Have a read of this: Migrating from MQL4 to MQL5
 
RaptorUK:
Have a read of this: Migrating from MQL4 to MQL5

Thanks RaptorUK, 

No I hadn't. I had google searched mql4 to mql5, which referenced code converter websites; tested a few=they didn't work...but more to the point - the code churned out was of no help.

That article is like a translation table.  Will have a study! Much appreciated! 

 
DreKn01:

...

I've been using this script for mt4 (as below). I want to start using mt5 but haven't been able to find an equivalent script in mql5.

Tried contact the previous author but no reply.  I wanted to try code it myself (newbie) but to no avail.

...


AIS1 LINES

Airat Safin| 8 February, 2020

A set of scripts for quickly marking the chart with horizontal and vertical lines


AIS1 LINES

Modification: 1.01
Release Date: 2020-02-08

Free Open Source Software


AIS1 LINES

GUIDELINES

1. AIS1 LINES is a set of scripts for marking the chart with horizontal and vertical lines


2. Program files:

   1. "AIS1_LINES_HORIZONTAL_PLOT.MQ5"   is a horizontal lines plotter file

   2. "AIS1_LINES_HORIZONTAL_REMOVE.MQ5" is a horizontal lines remover file

   3. "AIS1_LINES_VERTICAL_PLOT.MQ5"     is a vertical   lines plotter file

   4. "AIS1_LINES_VERTICAL_REMOVE.MQ5"   is a vertical   lines remover file


3. Copy program files in "../scripts" folder


4. Run MetaEditor and compile program files


5. Run 

   1. "AIS1_LINES_HORIZONTAL_PLOT" to draw horizontal lines

   2. "AIS1_LINES_VERTICAL_PLOT"   to draw vertical   lines


6. Run

   1. "AIS1_LINES_HORIZONTAL_REMOVE" to delete horizontal lines

   2. "AIS1_LINES_VERTICAL_REMOVE"   to delete vertical   lines


7. Input parameters

   1. for horizontal lines:

      1. "PriceMax"   defines maximal price level of the lines in quote units

      2. "PriceStep"  defines distance between horizontal price lines in quote units

      3. "PriceMin"   defines minimal price level of the lines in quote units

   2. for vertical lines:

      1. "TimeLeft"   defines left  bound of the lines in 'yyyy.mm.dd hh:mm' format

      2. "TimeStep"   defines distance between vertical time lines in minutes

      3. "TimeRight"  defines right bound of the lines in 'yyyy.mm.dd hh:mm' format

   3. for horizontal and vertical lines:

      1. "LineColor"  defines color of the lines

      2. "LineWidth"  defines width of the lines

      3. "LineStyle"  defines style of the lines according to the following table:

         "0" is solid lines

         "1" is dash  lines

         "2" is dot   lines

         "3" is dash-and-dot        lines

         "4" is dash-and-double-dot lines

      4. "LineBack"   defines background or foreground plotting:

         "0" is foreground plotting

         "1" is background plotting

 

 

<Deleted>

Reason: