TL-Users: Idea Changing Linear MT4 Charts to Logarithmic Charts
Page 1 of 612 12 LastLast
Results 1 to 10 of 15

Thread: TL-Users: Idea Changing Linear MT4 Charts to Logarithmic Charts

  1. #1
    Hi there,
    I've very special idea for everyone who blames MT4/MT5 for not drawing the correct and right trendlines using the Linear Charts whcih MT4/MT5 is using.
    May any Coder could alter this interval Converter from the Standard MT4 -Arithmetic -Linear Charts to Logarithmic Chart Scale.
    I believe this is the only way to acquire Logarithmic Charts in MT4/MT5 for all technical Trendline-Lovers.
    Here is the indi and the source code:
    // ------------------------------------ ------------------------------
    //| Period_Converter_Opt. mq4|
    //| Copyright (c)2005, MetaQuotes Software Corp.. |
    //| http://www.metaquotes.net |
    //| Ver.1.6 Modified by micclly|
    //| Ver.1.5 Modified by fai |
    //| Modified by wfy05@talkforex based on Period_Converter|
    //| http://www.talkforex.com |
    // ------------------------------------ ------------------------------
    #property copyright
    #property link http://www.mql4.com/codebase/indiors/277/
    #property indior_chart_window

    #include lt;WinUser32.mqhgt;

    /*
    Readme:

    I. Features:
    This is a better version of interval converter for MT4 based on the
    MT4's default period converter by metaquotes.
    The default interval converter script don't encourage real-time refreshing,
    and consume lots of CPU (50%-9xpercent ) making the entire system slow.
    Also, the default one is a script that do not spare when you exit MT4,
    so that you have to apply every converter script again after restarting, quite
    annoying.

    This one mended all over issues:
    1. Habit interval or updating millisecond degree upgrading.
    2. Low CPU cost, typical 5%-10percent or less.
    3. Works as an indior, so can be stored and reloaded during resume.
    4. There's nobody converter per chart limitation since it isn't script
    any more, it is possible to only use one window as source to generate as many
    new time chart as possible.
    5. Auto updating if there is new history block loaded.

    II. How to use:
    Duplie the mq4 file to your MT4 indiors folder (specialists \indiors)
    to install it as an indior, NOT script. Then in the custom indior
    record, attach period_converter_opt to the chart you need.
    It encourage 4 parameters:
    PeriodMultiplier: new phase multiplier variable, default is 2
    UpdateInterval: update interval in milliseconds,
    zero signifies update real-time. default is zero.
    Enabled: You can disable it without remove it with this alternative.

    Other parameters include comments or for debugging, it is safe to ignore them.

    Also Make certain that you have Permit Dll imports alternative checked in shared tab
    it will not work

    Then, FileOpen Offline to open the generated offline information. Subsequently
    the offline information will be updated automatically.

    So long as you maintain the source chart open and the converter indior
    running, the generated chart including indiors inside will always
    be updated. Also you can close the generated chart and open again
    later from FileOpen Offline without problem.

    If you want to stop MT4, it is possible to leave those offline chart as other
    normal online charts. When you start MT4 next time, these charts will
    also be loaded and updated.


    III. Notes:
    1. Do NOT uncheck the offline chart option in offline chart shared properties.
    Or after MT4 restart, it is going to treat that chart as online chart and request
    the information from server, resulting empty chart window.
    2. It is possible to attach more than one converter to same window using distinct
    PeriodMultiplier, e.g: you can attach 3 converter using
    PeriodMultiplier = 2, 4, 10 to M1 to generate M2, M4, M10 at the exact same moment.
    It's even ok to use the M1 chart to generate Hourly chart like H2, which
    only cost a few more CPU source during initial conversion. But usually
    most server do not have much information for those short period. Consequent the
    generated information is not long enough for extended period. So it is suggested
    to utilize Hourly/Daily charts as source when required.
    3. The real-time upgrading mode upgrades quotes as quickly as possible, however as
    this is achieved via script, and MT will skip calling start() work when
    that your PC is busy and lots of quotes income. Anyhow, this rarely happen,
    and you can at least get 10 upgrades each seconds that's much more
    than sufficient.
    4. The offline chart do not have a bid line revealing in chart, however all data
    in the chart including the indiors is still being updated,
    so don't worry. You can demone the bid line by unclick the offline chart
    alternative in chart properties. But which do not helps considerably and should you overlook
    to check offline chart option prior to exit. It will cause mistakes and
    become empty on next startup. You have to close the window and start
    again from FileOpen offline, which usually do not worth the trouble.

    IV. History:
    2014.03.10 1.6 Altered to encourage construct 600 and after
    2009.08.07 1.5 Added 3 options. (ShiftTiming,GMTShift,OmitD igit)
    2005.12.24 1.4 faster to detect whether data changed by removing float point
    operations, additional support to output CSV file in real time.
    OutputCSVFile = 0 signifies no CSV.
    OutputCSVFile = 1 signifies CSV HST
    OutputCSVFile = 2 CSV only, no HST.
    (helpful if you want to generate CSV to get builtin intervals )
    CSV Filename is going to be the same as HST document except the expansion.
    Added protected assessing for PeriodMultiplier.
    2005.12.04 1.3 Fixed missing information when there is large amount of data
    loaded in several blocks, and encourage auto upgrading
    when new history is filled.
    2005.11.29 1.2 Added fix for missing data and server changing.
    2005.11.29 1.1 Fixed missing partial information after restart.
    Reinitialize after changing data or server corrupted.
    2005.11.28 1.0 Initial release
    */


    extern double Version = 1.6; // code version
    extern series BuildInfo = 2014.03.10 by micclly;
    extern int PeriodMultiplier = 1; // new phase multiplier variable
    extern int OutputCSVFile = 0; // additionally output CSV file?
    Extern int UpdateInterval = 0; // update interval in milliseconds, zero signifies update real-time.
    Extern bool Enabled = true;
    extern bool Debug = false;

    extern int ShiftTiming = 0;//0-3,Using H1Chart and PeriodMultiplier=4;
    //if 1, ServerH4Chart = 00:00/04:00/08:00/12:00...
    // =gt;OfflineH4Chart = 01:00/05:00/09:00/13:00...
    extern int GMTShift = 0;// should 9, ServerTime = GMT 0 OfflineChartTime = GMT 9
    extern int OmitDigit = 0;// if 1, 5Digits 4Digits

    int FileHandle = -1;
    int CSVHandle = -1;
    int NewPeriod = 0;
    series MySymbol =;
    int ShiftBase;
    #define OUTPUT_HST_ONLY 0
    #define OUTPUT_CSV_HST 1
    #define OUTPUT_CSV_ONLY 2


    #define CHART_CMD_UPDATE_DATA 33324

    void DebugMsg(string msg)

    if (Debug) Alert(msg);


    int init()

    ShiftBase = Period() * 60;//sec
    series suffix =;
    if(ShiftTiming ! = 0) suffix =StringConenate(suffix,s,Shift Interval );
    if(GMTShift ! = 0) suffix =StringConenate(suffix,gram,GMTSh ift);
    if(OmitDigit ! = 0) suffix =StringConenate(suffix,o/*,OmitDigit*/);
    MySymbol =Symbol() _ suffix;
    if(StringLen(MySymbol)gt;11)
    MySymbol = StringConenate(StringSubstr(MySy mbol,0,11-StringLen(suffix)),suffix);
    //protected assessing for PeriodMultiplier.
    If (PeriodMultiplier lt;= 1 suffix == )
    //only output CSV file
    PeriodMultiplier = 1;
    OutputCSVFile = 2;

    NewPeriod = Period() * PeriodMultiplier;
    if (OpenHistoryFile() lt; 0) return (-1);
    WriteHistoryHeader();
    UpdateHistoryFile(Bars-1, true);
    UpdateChartWindow();
    return (0);


    void deinit()

    //Close file handle
    if(FileHandle gt;= 0)
    FileClose(FileHandle);
    FileHandle = -1;

    if (CSVHandle gt;= 0)
    FileClose(CSVHandle);
    CSVHandle = -1;




    int OpenHistoryFile()

    series name;
    name = MySymbol NewPeriod;
    if (OutputCSVFile! = OUTPUT_CSV_ONLY) FILE_WRITE
    if (OutputCSVFile ! = OUTPUT_HST_ONLY) FILE_WRITE
    return (0);


    int WriteHistoryHeader()

    series c_copyright;
    int i_digits = Digits-OmitDigit;
    int i_unused[13] = 0;
    int version = 400;

    if (FileHandle lt; 0) return (-1);
    c_copyright = (C)opyright 2003, MetaQuotes Software Corp.;
    FileWriteInteger(FileHandle, version, LONG_VALUE);
    FileWriteString(FileHandle, c_copyright, 64);
    FileWriteString(FileHandle, MySymbol, 12);
    FileWriteInteger(FileHandle, NewPeriod, LONG_VALUE);
    FileWriteInteger(FileHandle, i_digits, LONG_VALUE);
    FileWriteInteger(FileHandle, 0, LONG_VALUE); //timesign
    FileWriteInteger(FileHandle, 0, LONG_VALUE); //last_sync
    FileWriteArray(FileHandle, i_unused, 0, ArraySize(i_unused));
    return (0);



    static double d_open, d_low, d_high, d_close, d_volume;
    static int i_time;

    void WriteHistoryData()
    {
    if (FileHandle gt;= 0) {
    FileWriteInteger(FileHandle, i_time GMTShift*60*60, LONG_VALUE);
    FileWriteDouble(FileHandle, d_open, DOUBLE_VALUE);
    FileWriteDouble(FileHandle, D_low, DOUBLE_VALUE);
    FileWriteDouble(FileHandle, d_high, DOUBLE_VALUE);
    FileWriteDouble(FileHandle, d_close, DOUBLE_VALUE);
    FileWriteDouble(FileHandle, d_volume, DOUBLE_VALUE);
    }
    if (CSVHandle gt;= 0)
    int i_digits = Digits-OmitDigit;
    FileWrite(CSVHandle,
    TimeToStr(i_time, TIME_DATE),
    TimeToStr(i_time, TIME_MINUTES),
    DoubleToStr(d_open, i_digits),
    DoubleToStr(d_high, i_digits),
    DoubleToStr(d_low, i_digits),
    DoubleToStr(d_close, i_digits),
    d_volume);

    }

    int UpdateHistoryFile(int start_pos, bool init = false)

    static int last_fpos, csv_fpos;
    int I, ps;
    // if (FileHandle lt; 0) return (-1);
    // normalize open time
    ps = NewPeriod * 60;
    i_time = (Time[start_pos]-ShiftBase*ShiftTiming)/ps;
    i_time = i_time*ps ShiftBase*ShiftTiming;
    if (init)
    //initial time, init data
    d_open = Open[start_pos];
    d_low = Low[start_pos];
    d_high = High[start_pos];
    d_close = Close[start_pos];
    d_volume = Volume[start_pos];
    I = start_pos - 1;
    if (FileHandle gt;= 0) last_fpos = FileTell(FileHandle);
    if (CSVHandle gt;= 0) csv_fpos = FileTell(CSVHandle);
    else
    Id = start_pos;
    if (FileHandle gt;= 0) FileSeek(FileHandle,last_fpos,SEEK_ SET);
    if (CSVHandle gt;= 0) FileSeek(CSVHandle, csv_fpos, SEEK_SET);

    if (I lt; 0) return (-1);

    int cnt = 0;
    int LastBarTime;
    //processing bars
    while (I gt;= 0)
    LastBarTime = Timing [I];

    //a new bar
    if (LastBarTime gt;= i_time ps)
    //write the pub info
    WriteHistoryData();
    cnt ;
    i_time = (LastBarTime-ShiftBase*ShiftTiming)/ps;
    i_time = i_time*ps ShiftBase*ShiftTiming;
    d_open = Open[I];
    d_low = Low[I];
    d_high = High[I];
    d_close = Close[I];
    d_volume = Volume[I];
    else
    //no new bar
    d_volume = Volume[I];
    if (Low[I]lt;d_non ) d_low = Low[I];
    if (High[I]gt;d_high) d_high = High[I];
    d_close = Close[I];

    I--

    //album last_fpos before composing last pub.
    If (FileHandle gt;= 0) last_fpos = FileTell(FileHandle);
    if (CSVHandle gt;= 0) csv_fpos = FileTell(CSVHandle);
    WriteHistoryData();
    cnt ;
    d_volume -= Volume[0];
    //flush the data writen
    if (FileHandle gt;= 0) FileFlush(FileHandle);
    if (CSVHandle gt;= 0) FileFlush(CSVHandle);
    return (cnt);


    int UpdateChartWindow()

    static int hwnd = 0;

    if (FileHandle lt; 0)
    //without a HST file opened, no need upgrading.
    Return (-1);

    if(hwnd == 0)
    //attempting to detect the chart window for updating
    hwnd = WindowHandle(MySymbol, NewPeriod);

    if(hwnd! = 0)
    if (IsDllsAllowed() == false)
    //DLL calls must be permitted
    DebugMsg(Dll calls have to be permitted );
    return (-1);

    should (PostMessageA(hwnd,WM_COMMAND,CHART _CMD_UPDATE_DATA,0) == 0)
    //PostMessage failed, chart window shut
    hwnd = 0;
    else
    //PostMessage triumph
    return (0);


    //window not found or PostMessage failed
    return (-1);



    /*
    int PerfCheck(bool Start)

    static int StartTime = 0;
    static int Index = 0;
    if (Start)
    StartTime = GetTickCount();
    Index = 0;
    yield (StartTime);

    Index ;
    int diff = GetTickCount() - StartTime;
    Alert(Time used [ Index ]: diff);
    StartTime = GetTickCount();
    yield (diff);

    */

    static int LastStartTime = 0;
    static int LastEndTime = 0;
    static int LastBarCount = 0;

    void reinit()

    deinit();
    init();
    LastStartTime = Timing [Bars-1];
    LastEndTime = Timing [0];
    LastBarCount = Bars;


    bool IsDataChanged()
    LastLow ! = Low[0]

    int CheckNewData()
    Timing [I]! = LastEndTime)
    DebugMsg(End time TimeToStr(LastEndTime) not found);
    reinit();
    return (-1);

    cnt = Bars - I;
    if (cnt! = LastBarCount)
    DebugMsg(Data loaded, cnt is cnt LastBarCount is LastBarCount);
    reinit();
    return (-1);


    //no new data loaded, reunite with LastEndTime position.
    LastBarCount = Bars;
    LastEndTime = Timing [0];
    return (Id );


    // ------------------------------------ ------------------------------
    //| program start function |
    // ------------------------------------ ------------------------------
    int start()

    static int last_time = 0;

    if (! Enabled) return (0);
    //always update or update just after certain interval
    if (UpdateInterval ! = 0)
    int cur_time;
    cur_time = GetTickCount();
    if (MathAbs(cur_time - last_time) lt; UpdateInterval)
    return (0);

    last_time = cur_time;


    //if (Debug) PerfCheck(true);
    int n = CheckNewData();
    //if (Debug) PerfCheck(false);
    if (n lt; 0) return (0);

    //update history with new info
    UpdateHistoryFile(n);
    //refresh chart window
    UpdateChartWindow();
    //if (Debug) PerfCheck(false);
    return(0);


    Attachment indior:
    Attached File
    https://www.nigeriaforextrading.com/...9574793598.mq4 60 KB | 0 downloads

  2. #2
    Would you post some pictures to demone the differences please?

  3. #3
    I am very time-limited so please have a look for yourself.
    Logarithmic Charts available throughout the internet to comßpare to get yourself.Thanks.
    If a few Coder is interested please allow me to know.
    It is obviously far better to work on this Code than Coding a worthless Indior that really helps nobody.
    Thank you for your attention.
    Greeds Zack

  4. #4
    Quote Originally Posted by ;
    I am very time-limited so please have a look on your own. Logarithmic Charts available throughout the net to comßpare to get yourself.Thanks. If a few Coder is interested please let me know. It's obviously far better to work on this Code than Coding a useless Indior that actually helps no one. Thank you for your attention. Greeds Zack
    the indior https://www.nigeriaforextrading.com/...2885342069.mq4 didn't work on my platform. If it's some other bugs in the code. Please fix it.

  5. #5
    However, the .ex4 should be working.It is functioning on my Platform without any limitations.
    Thanks for any advice.
    Z.

  6. #6
    Quote Originally Posted by ;
    However, the .ex4 should be working.It is functioning on my Platform without any limitations. Thank you for any info. Z.
    then could you upload the ex4 Edition of https://www.nigeriaforextrading.com/...le-corner.html Tks

  7. #7

  8. #8
    Quote Originally Posted by ;
    Here it is. Z. file
    quite thanks. Could you gIve explanation of this parameter setting and how to use this indior(offline chart or...?) ?
    Timeshiftadd at hptmm
    periodmultiplier
    ....
    ....
    ...

  9. #9

  10. #10
    hey there. Very nice. I have another thought for you who is much like logarhithmic trendlines but maybe eve better. Gann talked about squaring price with time. He referred to some king of normalization of price to time relationship. He talked about a'price vibration'. He used geometry, but he didn't have the technology we must day. Long story short

    for example, if you measure or example gj and it goes on average of 55 pips each hour its own price vibration could be considered as 55/60.

    There is a renko/time chart hybrid to square price and time, but it just prints if the two states are met and it utilizes renko instead of range pubs. Http://backtothefuturetrading.com/fl...-hybrid-renko/

    Put simply a candle has been drawn every time price does one, goes 55 pips OR 60 minutes moves. Either a range bar is made or a period bar is made. Perhaps there could be usefulness of trendlines on this chart.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.