You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
When and how often do you want a buy signal? Once an hour?
If you are using running on a H1 chart, the above code will generate one buy signal per hour.
One signal per hour when the conditions are true should be enough. I need to stop the signals coming through every hour (EVEN WHEN THE CONDITIONS ARE NOT TRUE ANY MORE!)
That is right. The signal comes through every hour even when the test for the signal to be generated is not true any more!
One signal per hour when the conditions are true should be enough. I need to stop the signals coming through every hour (EVEN WHEN THE CONDITIONS ARE NOT TRUE ANY MORE!)
My test code above will allow at most only one buy signal per hour if it is run on a H1 chart. See the following results
12:59:39 TestingEA test started
12:59:39 2013.10.14 00:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 00:00
12:59:41 2013.10.14 01:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 01:00
12:59:41 2013.10.14 02:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 02:00
12:59:41 2013.10.14 03:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 03:00
12:59:41 2013.10.14 04:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 04:00
12:59:41 2013.10.14 05:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 05:00
12:59:41 2013.10.14 06:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 06:00
12:59:41 2013.10.14 07:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 07:00
12:59:41 2013.10.14 08:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 08:00
12:59:41 2013.10.14 09:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 09:00
12:59:41 2013.10.14 10:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 10:00
12:59:41 2013.10.14 11:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 11:00
12:59:41 2013.10.14 12:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 12:00
12:59:41 2013.10.14 13:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 13:00
12:59:41 2013.10.14 14:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 14:00
12:59:41 2013.10.14 15:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 15:00
12:59:41 2013.10.14 16:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 16:00
12:59:41 2013.10.14 17:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 17:00
12:59:41 2013.10.14 18:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 18:00
12:59:41 2013.10.14 19:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 19:00
12:59:41 2013.10.14 20:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 20:00
12:59:41 2013.10.14 21:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 21:00
12:59:41 2013.10.14 22:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 22:00
12:59:41 2013.10.14 23:00 TestingEA EURUSD,H1: BUY EURUSD at 2013.10.14 23:00
My test code above will allow at most only one buy signal per hour if it is run on a H1 chart. See the following results
Just to be clear on this. I need only ONE signal (the first one) to come through. Thereafter all other signals every hour should be stopped. I don't want the SAME signal coming through every hour.
This is what has been happening EVEN WHEN THE CONDITION OR TEST FOR GENERATING THE SIGNAL IS NO LONGER TRUE - THE SIGNAL CONTINUES TO COME THROUGH EVERY HOUR!
At what point (time) do you want a new signal to come through?
It will depend on the price movement, but if I HAVE to set a time it would be six hours. But I do not want those SAME signals starting up again after six hours!
At what point (time) do you want a new signal to come through?
It will depend on the price movement, but if I HAVE to set a time it would be six hours. But I do not want those SAME signals starting up again after six hours!
If it depends on price movement, then use price. Right now, you are using time; in fact, your code is saying that at most one buy signal is valid for each bar of the current chart. So, if you have your code running on a H1 chart, you will get at most one buy signal each hour; likewise, if your code is running on a D1 chart, you will get at most one buy signal each day. This is due to your use of iTime().
So, the answer to your original post is: no, there doesn't appear to be something wrong in the snippet of code you posted, but there could be something wrong with your logic to solve the issue you are experiencing.
If it depends on price movement, then use price. Right now, you are using time; in fact, your code is saying that at most one buy signal is valid for each bar of the current chart. So, if you have your code running on a H1 chart, you will get at most one buy signal each hour; likewise, if your code is running on a D1 chart, you will get at most one buy signal each day. This is due to your use of iTime().
So, the answer to your original post is: no, there doesn't appear to be something wrong in the snippet of code you posted, but there could be something wrong with your logic to solve the issue you are experiencing.
There may not be anything wrong with my code if I want the same signal sent every hour, but I still don't know what I must do to prevent the multiple signals since I require only ONE signal sent (the first one) and then all the others repressed/stopped.
Price movement determines when the signal must be generated but afterwards some other code must stop this signal to be sent every hour and this cannot be done based on price movement.
I need some guidance of how I can accomplish my objective of only one signal.
There may not be anything wrong with my code if I want the same signal sent every hour, but I still don't know what I must do to prevent the multiple signals since I require only ONE signal sent (the first one) and then all the others repressed/stopped.
Price movement determines when the signal must be generated but afterwards some other code must stop this signal to be sent every hour and this cannot be done based on price movement.
I need some guidance of how I can accomplish my objective of only one signal.
First, you are the primary arbiter of what constitutes a valid signal. Determine what you want a valid signal to be and then create the programming logic which implements it.
Second, while I'm sure there are many ways to discriminate valid signals from supposedly invalid signals, I can think of two ideas: (a) a signal is valid if it is materially different from the previous signal--i.e., has a different buy/sell price or has different sl/tp parameters; and (b) a signal is valid if it occurs after a certain amount of time from the previous signal. A third idea combines the first two--i.e., a signal is valid if it is materially different from the previous signal and has occurred after a given amount of time from the previous signal. It appears you have coded the second idea. But you may think about a variant of the third: a signal is valid if it is materially different from the previous signal or has occurred after a given amount if time from the previous signal. But, again, you are the only one who can determine what is or isn't a valid signal.
There may not be anything wrong with my code if I want the same signal sent every hour, but I still don't know what I must do to prevent the multiple signals since I require only ONE signal sent (the first one) and then all the others repressed/stopped.
Price movement determines when the signal must be generated but afterwards some other code must stop this signal to be sent every hour and this cannot be done based on price movement.
I need some guidance of how I can accomplish my objective of only one signal.
Then you need to do something with the variables Trade and/or Buy
Maybe only send a signal when the variable was false the previous tick/bar and true this current tick/bar.
Then you need to do something with the variables Trade and/or Buy
Maybe only send a signal when the variable was false the previous tick/bar and true this current tick/bar.
That sounds to me the best way to go. I know how to distinguish between the values of two different shifts in an indicator, but how do I do that with a variable based on the previous tick/bar?
Please be patient with this beginner programmer!