Download MetaTrader 5
To add comments, please log in or register
Store your source codes in MQL5 Storage. It is secure!
DreKn01
8
DreKn01 2013.02.25 18:33 

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                     "http://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                          http://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
Simon Gniadkowski
Moderator
17990
Simon Gniadkowski 2013.02.25 18:54  
DreKn01:


Any comments/links/suggestions would be appreciated. 

Have a read of this: Migrating from MQL4 to MQL5
DreKn01
8
DreKn01 2013.02.25 19:13  
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! 

/
To add comments, please log in or register