passing values between programs

Post Reply
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

passing values between programs

Post by jjasper7 »

would someone please explain how to place a value calculated by an indicator somewhere so the ea can pick it up an use it? I am thinking of running the indi to calculate and chart recent values, and if the ea is running, instead of calling the indi to run and re-calculate the value for each tick, it uses storage that can be common to any program, and would just pick it up and use the last value calculated... and, probably, should have some way to confirm that the indi has run recently. for example, if i wanted to run the stochastic indicator or the timeslope indi, instead of running the indi for each value needed, to have the ea be able to pick up the last calculated value and test it for the condition i need. as fast as these computers are nowdays, it would not save that much processing time, but could simplify/shorten the length (and consequent debugging) of any other program that needs to find that value (rather than needing to add the code into the program or make an icustom call).
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: passing values between programs

Post by gaheitman »

jjasper7 wrote:would someone please explain how to place a value calculated by an indicator somewhere so the ea can pick it up an use it? I am thinking of running the indi to calculate and chart recent values, and if the ea is running, instead of calling the indi to run and re-calculate the value for each tick, it uses storage that can be common to any program, and would just pick it up and use the last value calculated... and, probably, should have some way to confirm that the indi has run recently. for example, if i wanted to run the stochastic indicator or the timeslope indi, instead of running the indi for each value needed, to have the ea be able to pick up the last calculated value and test it for the condition i need. as fast as these computers are nowdays, it would not save that much processing time, but could simplify/shorten the length (and consequent debugging) of any other program that needs to find that value (rather than needing to add the code into the program or make an icustom call).
You could come up with a bunch of ways to write a value and read it again either in memory via DLL or on disk. You could also write/read values to global variables. None of these will be as reliable as using iCustom() and they all require MUCH more time to implement correctly. If the code doesn't bog down your system running via indicator, I would recommend using iCustom().

BTW, most indicators don't really need to recalculate the values on each tick, it may be that you can optimize the indicator so that it's less of a strain in the first place.

George
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

Re: passing values between programs

Post by jjasper7 »

thank you, george. i have no idea how to generate a dll, and can understand that other options would not be simple and therefore not simplify. i appreciate the explanation, thanks for the help
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

Re: passing values between programs

Post by jjasper7 »

another question, how do you visually label a point that will stay with the contract's chart structure (vs a position on the screen)? i.e. label a price at time, so that it marks a significant bar, and stays relavent (like drawing an arrow) as time passes or the time period is changed.
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: passing values between programs

Post by gaheitman »

jjasper7 wrote:another question, how do you visually label a point that will stay with the contract's chart structure (vs a position on the screen)? i.e. label a price at time, so that it marks a significant bar, and stays relavent (like drawing an arrow) as time passes or the time period is changed.
There are two kinds of "labels" you can add to the chart with the ObjectCreate() function. OBJ_TEXT moves with the chart, OBJ_LABEL stays on the same screen X/Y position. The ObjectCreate() online help entry gives an example of using both. As usual, it's not a great example, but you can see that the OBJ_TEXT object type takes a Date and Price coordinate and the OBJ_LABEL object type needs the second step to move it to the correct X/Y coordinate.

http://docs.mql4.com/objects/ObjectCreate

George
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

Re: passing values between programs

Post by jjasper7 »

thank you
Post Reply

Return to “Coders Hangout”