fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Memory stuff

    Questions & Answers
    2
    23
    5012
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      edwardseer last edited by

      hi, i was collecting data on forward testing, and i used the draw function in subwindow to show the values of for the indicator i used in the ea for the current time as a representation of the signal the ea is looking at. however each time i restart or mt4 crash, the collected data/line is gone. i was thinking of maybe writing the time and the value of each candle into a file while forward testing and using the ea to redraw them out whenever it restarts. will there be a some kind of read from file function or is there another way to store the memory of the data collected.

      1 Reply Last reply Reply Quote 0
      • fxDreema
        fxDreema last edited by

        Storing information in file will be slow and who knows what bugs can appear because of that. It's possible to read from files, but there is no block for this, I have to write some.
        If you want to store only few values, not whole arrays with data, then I can suggest this block "Set Global Variables in MT4". There variables are actually stored in files, similar to browser cookies. Then you can get their data in Condition. And you can see them all in MetaTrader, just hit F3.

        1 Reply Last reply Reply Quote 0
        • E
          edwardseer last edited by

          the data im collecting is an array as it collect each candle and the value obtained by the ea. global variable cannot be an option :(. im collecting the data so that i can visually see what are the total indicator values showing at each current time as i assign a value to each indicator value.
          something like this i think.
          https://fxdreema.com/shared/PLE4uEYkd

          1 Reply Last reply Reply Quote 0
          • fxDreema
            fxDreema last edited by

            It will be hard to do in an EA and the result will be heavy most probably. Collecting array of data and visualizing it is what indicators do, this is the right thing to do 🙂

            1 Reply Last reply Reply Quote 0
            • E
              edwardseer last edited by

              unfortunately im a noob at mql :(. the only easy way out for me is by using fxdreema to collect the multiple indicator data and output the values calculated by a formula to a excel then maybe read the values from the excel output to show data collected on the chart
              i hope that you can include a block to read from excel based on the write to file function of fxdreema. Thank you.

              1 Reply Last reply Reply Quote 0
              • fxDreema
                fxDreema last edited by

                This idea is even worse - read indicators, writing data to a file, then read it and draw tens of objects on the chart. And doing that on every tick. This is SLOW. There is a short way - custom indicator. But fxDreema is not indicators builder 🙂

                In a custom indicator you can set some options - colors, buffers, the way indicator looks - and then put some mathematical calculations. I will suggest to get some simple indicator and play with it for a while. If nothing else, it's funny and you will learn something new 🙂

                http://book.mql4.com/samples/icustom

                1 Reply Last reply Reply Quote 0
                • E
                  edwardseer last edited by

                  the excel thing is only for oninit so that whenever the chart is loaded, it can show me whats previous the indicator was saying using the excel file it has stored. something like a tick collector ea in the market.
                  i need the data to be stored as i need the collected data on the live chart as the indicator used may repaint in live scenario so i wanted to collect the data as it goes in time and i only stored the values into the excel after that candle is confirmed.
                  i will look into creating custom indicator though. thanks.

                  1 Reply Last reply Reply Quote 0
                  • fxDreema
                    fxDreema last edited by

                    Sometimes I must admit that fxDreema can't help. But I found some custom indicator as an example of how it should be done: https://www.mql5.com/en/code/10102 This is 2 indicators - one to write the data and another to read it and print it.

                    And I'm not even convinced of doing this using EAs. Evene if I create a block to read the data and print it with lines, this will be only imitation of what a normal indicator is supposed to do.
                    If we are talking about arrays... if you have some idea how to make it easier for people to work with arrays, knowing that many of them does not even know what the word "variable" means 🙂
                    The truth is that I should create a custom indicators bulder, but I always end up doing something else 🙂 At the moment I am preparing the website to move it to a new server 😮

                    1 Reply Last reply Reply Quote 0
                    • E
                      edwardseer last edited by

                      a custom indicator builder would be nice 🙂 thanks for the info.
                      im not too sure how to work with arrays either ><. for end user like me who do not know much about mql, i think its good if it works thats all. This is why we feel that your product is good as it is so easy to use when we just started and work as well for us. more advance stuff can be learned as we use. like mql codes can be inserted into the adjust field in variables etc after we get used to the more basic stuff of fxdreema (which already covers most uses). efficiency issues comes later when it becomes really a problem.
                      Anyway, do not be bothered too much with my request, i created another solution to temporary fulfill my needs by taking screenshots of the lines drawn at regular intervals. the purpose of the ea i created for this is just to collect data and see whether the system works or find areas to improve.

                      1 Reply Last reply Reply Quote 0
                      • E
                        edwardseer last edited by

                        erm could you look into creating a block to read from file lol? or suggest another way for me to store the information 😛 i uploaded another file id mt4-1788. it was using global variable to store the memory but if mt4 crashes the global variable are not saved. so another method i think of to saving is still to write to file lol. then oninit read the values from file.

                        1 Reply Last reply Reply Quote 0
                        • E
                          edwardseer last edited by

                          also, i seen in the ea code that the code set the global variable to empty variable when theres no value in it if i remember correctly. this somehow resulted in the glboal variable keep being assigned to the EMPTY_VALUE and when i call that global variable into the ea it would my ea problem has im using the stored global variable in the calculation and empty_value somehow in this case is a value(21...) that was used into the calculation.

                          1 Reply Last reply Reply Quote 0
                          • E
                            edwardseer last edited by

                            Bumpy.

                            1 Reply Last reply Reply Quote 0
                            • fxDreema
                              fxDreema last edited by

                              What are you trying to do? I saw your project and you have Variables, GV and flags sharing the same name and controlling the same thing. Maybe your mindset is always telling you to convert data from one way to another. I think there must be a better and simpler way of doing whatever you are trying to do.

                              If you store values in Variables, they are lost when the EA goes down.
                              If you store values in Global (Terminal) Variables, they are probably not lost, but they can be already old when you open the EA hours later. The EA still needs to run most of the time, otherwise it will lose synchronization.
                              If you store values in a file, it's the same story. Terminal variables are actually written in files.
                              If you store values in chart objects, then you are limited to the chart only. And again, the data can become old.

                              In all this situations you can lost data or use wrong data.

                              At the end, you are controlling trades. The best way to store information regarding trades is to store in right inside them. Well, unfortunately we don't have many custom fields to write data in, the only one is the Comment. Also SL, TP, Lot size and Magic Number are used for trailing stop and money managements.

                              1 Reply Last reply Reply Quote 0
                              • E
                                edwardseer last edited by

                                that modify variable was added after my main ea was already finished after i decided it was better to include whether it was on or off in the comments to facilitate bug fixing etc. the only use for the variable was just to show in the comments. i did not see where to put status of flags in the comments section so if there is, please let me know as i avoid the use of flags because of this issue after i built this ea. .

                                i added the GV to try and save the current flag status in the ea so that when the ea restart, it will continue where the flags position were previously at. true or false. it doesnt matter even if the status was old. as i just need to to continue where it was when it closed. it was only added after the main code was completed already but i realised i need a way to save the state of the ea when it closed.

                                it worked fine if it was closed normally. but i would like to have a further safety precaution as i would not want to manually close all the position it opened in the event of a crash which happened recently on my computer. the GV tat was written to MT4 was not saved so i had to manually closed the position myself.
                                of course i would want to directly use the trade comments but i do not know how to use and its quite complicated to know define which history to include and which trade it was at and what it was suppose to do next with just the trade alone. since there is some trade which i considered as a long entry and some trades which are long are considered hedging against a sell currently opened and in turn affects what the ea gonna do. and if hedge are closed it might still be considered working towards breakeven etc. so i felt it was better to just save the state of the ea to prevent new bugs.

                                edit: i reread ur comments, so you are saying even if i choose to write to file the file will also be gone like global variable even in crash like mt4?

                                1 Reply Last reply Reply Quote 0
                                • fxDreema
                                  fxDreema last edited by

                                  Let's talk about trading. Can you explain the strategy itself, what do you want to do with the trades?

                                  1 Reply Last reply Reply Quote 0
                                  • E
                                    edwardseer last edited by

                                    i rearranged the layout to maybe make it a bit more clearer.
                                    the first line is the current open trade checker and it included previously closed trade. each direction is like an independent ea. so im just talking about sell now.
                                    it checks if the signal for sell is valid and all valid is sell just like in the initial sell. the trade management is the tricky part. theres a recovery portion and hedge portion.
                                    if it drop more then a certain pips and a buy occur it will just make another buy in the same direction and now it will start to look for break even.

                                    the normal close flags are added just as a precaution and reset everything back to false.
                                    when it has a sell and one of the signal changes direction to a buy, it will immediately open a hedge trade, until the all signals align for a sell again then it will close the hedge trade. and set the flag for hedge to true. when the hedge closes, it sets another hedgecloseflag to true so that it would start looking for a breakeven trade.
                                    the recovery checks whether hedge is currently running through the flags. so it would not make a sell trade during hedge.
                                    when hedge close, a variable will store the closed hedge amount. the purpose of doing this is because there are possibly 2 direction running so i cant check for number of closed trade before and it can close an uncertain amount of hedge before it will close at a breakeven in total. so the hedge will carry on as long as its has not breakeven.

                                    speaking of this, oninit the global variable was checked to be empty or something and it output to EMPTY_VALUE to my variable and i cant find a way to solve this. for now a condition checks whether its more than a certain value but during live it keeps getting 21437... oninit. for now its working fine on strategy tester though. i think when it checks and there is no global variable it automatically assigned a EMPTY VALUE to that global variable.EMPTY_VALUE becomes a real value 214......... in this way.

                                    so the same is done for the buy direction and they operate mostly independent of each other.

                                    1 Reply Last reply Reply Quote 0
                                    • fxDreema
                                      fxDreema last edited by

                                      There are 2 things that I really don't like in trading strategies - Zig Zag and the idea of "hedging". Now I'm sure that your project is overcomplicated, starting with the idea to "hedge". You will eventually realize that it's not a good idea to use reverse trades instead of SL and that "hedging" is just a way to make things progressively complicated. By "hedging" I mean opening reverse trade in the same market.

                                      I will check what is going on with this EMPTY_VALUE...

                                      1 Reply Last reply Reply Quote 0
                                      • fxDreema
                                        fxDreema last edited by

                                        I think it's all fine with GV. Yes, if the requested GV does not exists, it returns EMPTY_VALUE (the biggest 32 bit integer), not 0. This value is also used by indicators to say that there is no value. I also decided that this value will be returned from requested graphical object that does not exists. So, in short, EMPTY_VALUE means that the thing you are looking for does not exists.

                                        But how this can be used? I recently modified "Condition" block, so if one of it's operands equals to EMPTY_VALUE, the block will not pass. The idea is that if you are searching for something (GV, indicator value, object) that does not exists, there is no reason for the Condition block to pass, one of it's operands is missing and everything should stop at this point. When the thing that you are searching for is available, Condition will do it's work normally.
                                        Well, not all blocks care if some value is EMPTY_VALUE, so most of the other blocks will do their job normally.

                                        1 Reply Last reply Reply Quote 0
                                        • fxDreema
                                          fxDreema last edited by

                                          Also you are looking for troubles when using "on Trade" event to count something. This will only work fine if the EA is working without interruptions. This can be desired sometimes, but in most cases we don't want that and we restart/close EAs many many times. Here you decided to store this information in some persistent memory. What happens now if you lost connection for 1 hour? The market will continue working and everything in the world will change. Your variables are still available, because they are stored in a file, but now they are 1-hour old. They represent a snapshot that is 1-hour old, but now the picture is totally different. There are movements of 400 pips in 1 hour 😮

                                          Magic Number, SL, TP, Lot size, Comment - these are also storage areas and what's best is that they are stored on the server. Magic Number will work best in your case I think. Let's say that the presence of a trade with Group # = 3 means that you are in stage X of the strategy (Group # is related to the Magic Number). You don't need to write and read files, use Variables, and GVariables, and have 200 extra blocks only to keep things in some order.

                                          When the EA is added to the chart, it can detect if trade with Group # = 3 exists, which means that the EA is in stage 3 (for example). If there is a trade with Group # = 4, then the EA is in stage 4. You can collect data from closed trades as well. Also from currently running trades. Also from pending orders. So I believe that you can do everything in a much simpler way. And when you stop believing that "hedging" leads to success, even simpler way 🙂

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 1 / 2
                                          • First post
                                            Last post

                                          Online Users

                                          Z
                                          T
                                          B
                                          A
                                          P

                                          11
                                          Online

                                          146.7k
                                          Users

                                          22.4k
                                          Topics

                                          122.6k
                                          Posts

                                          Powered by NodeBB Forums | Contributors