Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
Hello all,
I have an EA that has a number of different types of entry signals. I can toggle them on and off with true/false inputs. Meaning, if I have #1 and #5 set to true, entry signals will only be generated when both #1 and #5's conditions are met to open a trade and all other signals (or lack thereof) will be ignored.
The problem is, The entry signal has to be generated from both signals on the exact same bar to get an entry. How can I get the EA to remember one of the entry signals for a period of bars while waiting for a possible signal from the other. In other words, if I had an entry signal from #1 in the last "X" bars and am now getting an entry signal from #5 on the last bar (but the last bar didn't give a signal for #1), open a trade anyway. If the signal from #1 was too many bars ago, don't open a trade.
Here is the coding I used for one of the signals. All the others are in the same basic format. I want the time (bar) stipulation to be usable no matter which combination of signals I may or may not be using. Example; I am using signals #1,#4, and #9. I get an entry signal only if all three generated a signal sometime within the last X bars.
I am pretty sure that I need to use the "for" operator like this in some way;
int i;
for(i=0;i<=MaxBars-1;i++)
But, I am not sure how to put it in. If someone could show me what they would add to the first signal, I can use the same format for all the others I have added.
You could user a timer, basically setting a trade time variable and comparing current time to it. Or you can use iBarShift ( http://docs.mql4.com/series/iBarShift ) which returns the bar with the exact or closest time of a given date/time given.
ex:
datetime lastTradeTime = --whatever the last trade time was--;
int theBarIWant = iBarShift(Symbol(), PERIOD_H1, lastTradeTime, false);
Open[theBarIWant];
Close[theBarIWant];
...whatever...
I don't really understand your problem (because of my English), but I think you can use:
double MA1=iMA(NULL,0,MA1Period,0,0,0,X);
for X bar.
No, that will just allow me to adjust the shift of the bar that is used to do the calculations. What I want, is for an entry signal from one of the different signals I use to remain valid for a certain period of bars. That way, I can get an entry signal if both signals are generated within a given number of bars, not just if they both happen on the same bar.
I think I have it though. I can declare a global variable for each signal, set it to a high number and then add conditions in each individual signal part. If the global is greater than the span of bars I want to cover (which will always be true the first time around), the calculations are done, if not, the entry signal is set to true. If the calculations are done and trigger an entry signal, the global variable is reset to the current bar (using iBarShift) and an entry signal is given.
The first time through, calculations will always be done. If an entry signal is generated, the global will be reset to 0 and the next time through, it will bypass the calculations (because it is now lower than the span of bars I want to cover) and keep the entry signal as true. After each bar is generated, the global will increase by one. When the global value exceeds the span of bars I want to cover, it will be just like it was at the start (the global being greater than said span of bars) and it will go back to doing calculations. If another signal is triggered, it will repeat the process.
I think it should work but, I could be missing something (wouldn't be the first time, nor the last).
Thanks for the help guys. It would have taken me a while to find ibarShift. I am still very wet behind the ears when it comes to programming.
Well, either my idea is right and my coding is wrong or my idea is wrong and my coding is right or both my idea and my coding is wrong. Either way, it doesn't appear to be working.