MyCodeCorner
1 2 3

thread: MyCodeCorner

  1. #1

    MyCodeCorner

    I have been composing mql indiors for a long time now and while searching through my group I thought it'd be nice to collect the interesting pieces and put it into one place.

    Notice:
    I put all of my code out here publicly for free (Open Source!) However, I do not guarantee that what works without defects and I do not take responsibility for injury. If you find any bugs or have improvements don't hesitate to contact me. There is no reason for me to maintain the code and I annotate it as much as possible since I want the time that went to be of assistance for others. Might help individuals if my code might not be the coding design searching at examples. All in all please please post the mql4 document if you want to distribute anything posted here and maintain the copy right notice in the document. I will only leave and keep everything for myself if I find.


    Table of contentCodeCustomChartScale ScreenSynchronization SimpleChartNavigation PABacktester ChartSetup






    Whats up following Assist the File xxx does not work. Mt4 navigational tips Ranting about programming requests
    Upcoming releases: (Whenever I have time)CommonFunctionLibrary MoneyManagement course OfflineChartFramework Java Mt4 Bridge API Mql4 video capture support Greasymonkey script (FF) mql4 code syntax highlighting ----------------------------------------------------------------------------------------------------------------------------------------------------

    CustomChartScale

    Sort:Indior

    JensG asked if there is a possibility to increse the font size of the price scale for better visibility. (https://www.cliqforex.com/trading-sy...g-gu-wave.html)
    The code hides the charts first price scale as well as the grid and brings a new customizable scale and grid in the chart.
    If the chart height or width varies because of resizing it needs little time to readjust the foundation of the scale. Scrolling back and forth assists.

    Parameters

    clrNone usually means use the chart default colour

    ------Label Settings------
    color Label Color | Shade of the price tags
    uint Font Size
    int xLabelOffset | Left and right modification
    int yLabelOffset | Up and down alterations

    The greater the value the farther off. The counter also has corrected automatically with the font size and screen width. . Negative values are permitted to change in the other direction.

    ------Price Background -------
    colour backgroundColor;
    colour borderColor; | in pixel
    int widthScale = 110;

    ------Grid Settings------
    colour Grid Colory;
    ENUM_LINE_STYLE Line Style
    int Grid Line Width
    int Number Grid Lines | number tag lines


    Preview:

    Inserted Video

    https://www.cliqforex.com/attachment...1101963304.mq4
    ----------------------------------------------------------------------------------------------------------------------------------------------------

    ScreenSynchronization

    Sort:Indior

    This is a really really simple indior which mirrors the chart scrolling of one chart to specified other charts. It attempts to place the open time of the right most candle equivalent on all charts. Due to mql counting half candles around the chart and occasionally not here could be a counter of 1 2 pubs occasionally.
    The code Isn't fancy or nice but it's doing it's job

    Parameters

    enum ChartSelection

    ALL_CHARTS,SAME_CURRENCY,SAME_CURRENCY_AND_TF,SAME _TF;

    ChartSelection syncronize = ALL_CHARTS;

    Preview:

    Inserted Video

    https://www.cliqforex.com/attachment...1946679451.mq4
    ----------------------------------------------------------------------------------------------------------------------------------------------------

    SimpleChartNavigation Widget

    Sort:Indior

    I'm trading news events and locating the exact time on a chart could be bothersome. (You can press input and enter the emblem and time but I never really liked that feature) Simply add the desired time emblem and timeframe along with the widget will move the chart there. I just completed it and it was one of the occasions I worked with the mt4 gui.


    Parameters:

    bool autoDisableAutoScrolling //Customize Autoscrolling After Jump
    bool markJumpWithTrendline // Draw Trendline At Destination
    colour trendlineColor /Trendline Color
    int tWidth //Trendline Width


    Preview

    Inserted Video

    https://www.cliqforex.com/attachment...1212787824.mq4
    ----------------------------------------------------------------------------------------------------------------------------------------------------

    PA Backtester

    Sort:Indior

    A few years ago Tyoon asked to an indior which could conceal parts of the screen (https://www.cliqforex.com/trading-sy...evolution.html) A couple of days ago I was asked by a member of the forum if I could make it support leaping between multiple timeframes and decided to rewrite the entire thing.
    It all does it shifting a massive lable above the candles in the desirable rate enabling you to practice pa throughout the weekend or maybe to have a look at charts and compare your prediction with fact in a simple manner. You can do exactly the same but you can't seem at time frames that are distinct or establish the rate to what you desire. I am not sure whether it's useful or not but I leaned a lot about gui programming if creating it.

    Parameters:

    clrNONE = chart background colour

    colour hideAreaColor
    colour trendlineColor //Border Color
    int initialMSSpeed //Scroll Delay Speed

    Inserted Video

    https://www.cliqforex.com/general-fo...ion-forex.html

    Changelog:01.06.15 V3 Fixed a bug that covered half the last candle. 25.05.15 V2 Indior currently also hides the indior window. (See https://www.cliqforex.com/trading-sy...r-ea-free.html to your first version). Everything appears to work fine until you put in a new indior after the PA_Backtester has been added to the chart. This appears to break this indior but because of me being on holiday tomorrow and before you have to live with this for today, me wanting to release this version. Attachment 1681059

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

    ChartSetup

    Sort:Script

    That is a two line script which lets you conceal the price and time scale. I have not found a way to do this with no script. (I guess here is no copyright needed ).

    Parameters
    bool showTimeScale;
    bool showPriceScale;

    https://www.cliqforex.com/attachment...1534630689.mq4
    ----------------------

    Up

    CommonFunctionLibrary:

    Sort:IncludeFile

    This seems roughly like s ordinary library but with less string functions and much more attention to object orientation, byte and network support.
    I believe very useful is the implemented of hashtables which lets you save Key/Value pairs. For that all primitive data types are wrapped into a personal course.


    MoneyManagement library.

    Sort:IncludeFile

    This is probably one of the most useful code selections I have. It performs exactly the tp sl and lot calculation based on specified values. It is possible to switch between four or five different currency management models like risk based,fractional,fixed fractional, (anti/martingale (possibly I take this out)) etc. .

    OfflineChartFramework.

    Sort:IncludeFile

    Offline charts are simply charts whose information feed is written by ourselves significance we push what ever values we want into the candle every time we desire. This enables us the production of renko tick and all kinds of other charts which act exactly like normal charts.

    If you have a lot of distinct offline charts writing the hist document is probably the most annoying task to do which is precisely the same for all kinds of offline charts so I decided to create a framework for it.

    The superclass takes care of all the file handling as well as the emulation of the upgrade commands.

    Every custom chart type has a subclasses which has to take care about what happens with the current data every tick. If a custom pub opening distinct in the chart is desired this affliction has likewise be said.

    In depth documentation will be published when released and this one is cleaner and much more commented compared to everything else I have posted here.

    Example to implement a personal chart which shows how the spread changed during the summertime:



    Red: An indior with 3 lines of self written code needs to be applied to the chart.

    Orange: TickManipulation: The logic regarding what information should be shown in the current bar.

    And you're basically done. You get a chart which shows you how the spread changed and you could analyze it together with moving averages or your own macd in the event that you wanted.



    Already employed and ready to use

    TICK_CHART = 1, (with Number of ticks/chart as input)
    RENKO_CHART = 2,
    SPREAD_CHART = 3,
    BASKET_CHART = 4, (multi currency)
    CUSTOM_RENKO_CHART = 5, respectively (taking vertain properties of tf established and renko charts and combining them)
    PERIOD_CHART = 6, (12 min chart? No problem)
    RANDOM_CHART = 7; (simple randomly gaus number generated chart with xpercent likelihood to raise and 100 - x% probability to decrease every tick)

    I need a ranged bar chart too but it's not finished yet.

    Java bridge and api: Not much to say, I like programming in Java

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

    Assist the code does not operate

    While there may be bugs in the code that the indior should generally initialize and run at your terminal. I did my very best to test everything before releasing it but if you discover any bugs don't hesitate to post them.
    If you set the file in the correct folder and it does not run there may be some important include files missing which should usually already be included in the default installation of your terminal. You try to compile it and open the indior on your metaeditor if you experience this issue.

    At the bottom warnings and errors displayed. It is possible to dismiss everything but the code won't run, if there is a red circle. Keep an eye out for something that states

    can not open....

    .

    It tells us that the file DateDropList.mqh can't be discovered and opened. To repair this you have to place the file in the directory and you should be good.
    Here are files that could be missing at your terminal (if you can not find a specific file only tell me and I will upload it).

    Https://www.cliqforex.com/attachment...6136814817.rar



    Mt4 navigational hints:

    While these may be evident for regular traders I've only found those tiny arrow recently (or discovered them earlier and forgot about them ).



    1: if you allowed the chart shift it's possible to drag the small arrow at the top of the chart to ascertain how much space you've got at the border of the chart.
    Two: this arrow has been hiding from me for quite a while. If you disable! Autoscrolling you can drag this arrow into some place on the chart along with also the bar that's at precisely the same height as this arrow is going to be the fix point for zooming. It will always remain these 300 px from the side if bar A is 300 px from the left side of the screen.



    Please for the sake of programming asks:

    Creating a ribbon about mql4 conveys the risk that people send pms asking to program eas to them. As ago has thought me that this is wasted time, I am not interested in creating EAs. It took me roughly 15 months of designing testing and coding my ea and years of prep. There is no such thing while showering, as you having a good idea and it's magically working if enter code. Either you've got a concept and can prove it for a long timeframe (not simply eyeballing) or it's probably not going to work. Do your homework before contacting somebody you want to work for free for you.
    Somebody here on the forum said that a person who can invent requirements can program himself, and sadly this is true generally. I have never noticed a mechanical EA request which could be interpreted 1:1 into code. Gems include the ea must distinguish between breakouts and spikes or if the price moves to much away do some thing.
    While this is a tiny bit of topic a couple of words to system design. You should make up your mind about it may work and what could work.
    I've seen a lot of eas being write which got greatly curve fitted into the past. It's essentially the same thing for example telling the ea that the timestamps it must take trades for evaluation purpose. Either it works like you planned from the beginning or it's probably not going to work at all.
    If you begin to incorporate filters to allow it to be profitable you may want to stop already and try to consider another way to achieve your goal. I've seen so many many have enhanced them and filters asks being made to present eas? 0!
    The best suggestion I can give you would be to focus on money management. When it cannot turn into an unprofitable system into a profitable one (like martingale folks are claiming!) It will have the biggest impact on your trading success.

    Additionally I do not create indiors or just add an alert. I love to write utility code which distinguishes from the mass of indiors that is present. Basically things which can be advantageous in 1 way or another besides telling you where the price is about. Indiors get asked, it requires a very long time and then they are thrown out after a couple of minutes of testing. Next step would be to add an alert and then a mtf and dash support is filtered by another. I've had no luck using indiors but only with a blend of technical and fundamentals and believe I have coded indiors myself as most of you have probably tried out on your trading carrier.

  2. #2
    Hi Kilian, Can you make the PA Backtester hide as well as the bottom indior window? In this case RSI. Dragan picture
    that's a pretty good idea. I haven't thought about it because I do not use indiors with indior windows but I'll see what I can do to solve this issue.
    We will have to produce a label for each and every sub window we have but it's defiantly potential.

    I also think about releasing a code snipped which extends the trunk test summary by a equity and equilibrium chart based on time instead of on transactions. This allows us to observe equilibrium and the equity changes during the times and not just after closed transactions. E.g. this highlights how awful martingale egies really are. .

  3. #3
    I'll install the new variant PA Backtester variation in another second.



    Here I will attach the old original version if for any reason the new one does not work. (I achieved the upload limit to the post). Please see the change log.
    https://www.cliqforex.com/attachment...1426277706.mq4

  4. #4
    Member miva's Avatar
    44
    Hi Kilian,

    Tried to load the PA Backtester V2, Revealing errors as below:


  5. #5
    Junior Member Bavel's Avatar
    8
    Thank You Kilian

    But I can't make it work, something about Variety :

    'hideAreaArray' - undeclared identifier PABacktesterV2.mq4 262 19
    'hideAreaArray' - array required PABacktesterV2.mq4 262 19


    Regards,

    Dragan

  6. #6
    Thanks Kilian However, I can not make it work, something about array :'hideAreaArray' - undeclared identifier PABacktesterV2.mq4 262 19'hideAreaArray' - array necessary PABacktesterV2.mq4 262 19 Regards, Dragan
    Oh there might have slipped something when I cleaned up the code. I am going to have a peek at it and upload a revised version later this nighttime
    In the interim, you could delete line 262 and it might do the job. No time to right now

  7. #7
    Junior Member Bavel's Avatar
    8
    quote Oh there might have slipped something once I cleaned the code up. I will have a look at it and upload a revised version after this nighttime In the meantime you simply could delete line 262 and it may work. No time to chekc right now
    I have deleted the line and it functions

    When you check it out, please see border color. It doesn't work.

    Dragan

  8. #8
    quote I've deleted the line and it functions When you check it out, please see border colour. It doesn't do the job. Dragan
    Tiny mistake . Please try it

  9. #9
    Junior Member Bavel's Avatar
    8
    Great, it works. The border color also

    Thank you very much.

    Dragan


  10. #10
    Greatit works. The border color additionally Thank you very much. Dragan image
    Okay. During the week I will execute the trade attribute and release it here also be somewhat active after that although I'll be gone until the end of the week and. Happy trading.

  •