| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Modifying an Indicator on the fly https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=1000 |
Page 1 of 1 |
| Author: | gaheitman [ Sat Nov 17, 2012 6:46 am ] |
| Post subject: | Modifying an Indicator on the fly |
Attached is a version of the BasketEquityLive indicator that allows for virtual trades to be added on the fly. I'm posting it here because I was hoping to discuss the way it works and not immediately how to use it in trading. Instead of using the Inputs dialog to add virtual trades, I decided to create a control interface into the indicator via messages embedded in global variables. The commands the indicator currently "knows" are: GET_EQU - return the current equity GET_VER - return the indicator version GET_RDY - test whether all data is available and equity calculation is valid SET_MAP - change the Moving Average period SET_MAT - change the Moving Average type SET_RDW - force a redraw of the indicator SET_BUY - add a buy trade SET_SEL - add a sell trade SET_RST - delete all virtual trades and reset indicator When the indicator sees a new command, it does the following actions:
Code: Select all The saved copy is the same as the command, but is prefixed by an asterisk instead of a question mark. Code: Select all Code: Select all So, an example conversation to get the current equity would be: Requester creates a global variable: Code: Select all Code: Select all A more complex example is the setting of a virtual trade. This requires passing the Direction, Symbol, Open Price, Lots and Open Time The command looks like this: Code: Select all Code: Select all I still need to add commands to get the current MA value and the current Equity-MA value. I may also add commands to delete trades, but we'll see. This may be nothing more than idle hands coding a solution in search of a problem. It wouldn't be the first time. George |
|
| Author: | dietcoke [ Sat Nov 17, 2012 9:15 pm ] |
| Post subject: | Re: Modifying an Indicator on the fly |
It's certainly an idea worth investigating George. I use a GV to switch logging on/off in flight. I can think of plenty of situations where you might want to change an EA in flight, particularly in multipair ea's where you only want to change a global setting for one pair or CCY code. eg. temporarily stopping trading. changing stops or targets from their normal settings However, I find GV's frustratingly incomplete. eg, The value must be a number. It's quite clumsy looking through them and manipulating them as they do not integrate well into MQL's other data structures. One thing I found was that there is a bug in GV's where you are unable to delete a variable with more than a certain number of chars in the name. I think it allows you to create a gv with 64 characters but you cannot delete it. A GV with 63 characters appears to be the longest that can be removed. I came across this during an attempt to use GV's to hold delimited lists in the same way you are using them, so you need to be careful not to make the commands too long. |
|
| Author: | gaheitman [ Sun Nov 18, 2012 12:18 am ] |
| Post subject: | Re: Modifying an Indicator on the fly |
Another option was using text labels off screen, but they would only be available to that chart. There is a generic implementation of that at mql4.com. I agree that the limitations are frustrating. Why would they make it so you can only use numbers? I don't think the 63 characters will be too big of a deal, but thanks for bringing it up. I have hit that limit on text labels before, and it was very annoying. George |
|
| Author: | Radar [ Sun Nov 18, 2012 3:07 am ] |
| Post subject: | Re: Modifying an Indicator on the fly |
Hey George, Have you looked at MT4i's QuickChannel for communication between EA's, scripts, and indicators in either the same instance of Empty4, or across multiple instances on the same machine? Check it out here... http://www.mt4i.com/appstore/category.a ... popularity Have fun! Radar =8^) |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|