fxDreema

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

    Output from Custom Block to variable

    Questions & Answers
    2
    6
    1271
    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.
    • M
      monsterfly last edited by

      Hi,

      I created a custom block that grabs data from another chart which can be used on the current chart. I would like to convert that output to a variable that can be used on other blocks. Not sure how to do this with custom block.

      In the attached image I am using a constant to set the check avg pip profit amount but want to use the output of the custom block. Any suggestions?

      Thanks.

      http://prntscr.com/a2uhnv

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

        Blocks does not have outputs. I mean, in the code they are functions, but they does not return, they only call other functions.

        You know, I think Ihave to see what can I do in the blocks like "For each Object" so an object from other subwindows or charts can be read.

        It's not very intuitive to export global variales like that. There is an option to define global variable in the smaller field below the code, but I don't remember how this fits with Variables in the project. The thing is that when in any block you write the name of a Variable, this name is then prepended with v::, because Variables are coming from a class with name v. It's weird.

        Isn't there a way to have that object on the current chart, so at least it's description can be get? Then it's not that hard to use StringSubstr in any block.

        1 Reply Last reply Reply Quote 0
        • M
          monsterfly last edited by

          Thanks for the feedback. I am opening a basket of currencies from an index chart and the object I need to read from is on different spot forex chart. The indicators I am using do not output the necessary information on the index chart....unfortunately. For the time being I will just manually place the variable where I need it in the code.

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

            Hopefully it will work. There are few scenarios:

            • to create the variable with the block itself. I mentioned this additional field where things like global variables and imports can be defined. When generating the EA, the generator gets the information of all blocks that are used and decides what global variables to put.
            • to create the Variable in the project and somehow to put it into the custom block.

            The issue here is that I sometimes experiment with Constants and Variables. Right now they they are little complicated, they are two static classes - c:: and v:: - and these classes contain only variables. The idea is to separate Variables which are created in the fxDreema project with the real global variables. If you use a custom block and you define global variable "abc" and you use this block in a project where in Variables you have another variable with name "abc", both will be different things.

            http://prntscr.com/a3xeo1

            http://i.imgur.com/dysvgST.png

            As you can see, both variables even have different data type.

            I tested this now and of course there are no compile errors, because Variables and global variables in the custom block are different things. The question is what will happen if you write the word "abc" somewhere in the blocks... And what happens is that either "abc" or "v::abc" will be used, depending on what exists. If both exists, "v::abc" is used.

            In short, do it in the first way - define the variable in the bottom of the custom blocks, then just use it in the project, do not define that as Variable in the project.

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

              There is also another way, to work with functions and local static variables in them. I'm actually using this way for the system blocks and functions I created. So you can have a function that contain local static variable => by calling the function you can get or modify that variable, and doing other stuff as well.

              In the project when somewhere you write some function call, for example "MyFunction()", then this will refer to your custom function. Or, if such does not exists, to a system function (created by me).... but I don't recommend to anyone to use my functions, because I often change them.

              1 Reply Last reply Reply Quote 0
              • M
                monsterfly last edited by

                Thanks for the detailed explanation. The block flow is fairly straight forward and making sure any particular block has access to an available variable is exactly what I am trying to do. Manually placing the code for my object description find in the int start() and making sure the variable is declared seems to work for what I am doing. Of course being able to define the variables in a custom block and select which ones would be global would be a nice feature. Anyway, thanks again for the explanation.

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

                Online Users

                F
                S
                L
                J

                14
                Online

                146.7k
                Users

                22.4k
                Topics

                122.6k
                Posts

                Powered by NodeBB Forums | Contributors