I have created a simple EA that looks at the daily stick sizes and opens a trade after a daily stick that is the biggest among the last “N”. N can be any number that you can set as part of the input parameters. I had good results with N = 5 but you can try with different ratings. Trade is opened in the direction of the last stick. The EA then automatically puts a trailing stop at a specified amount. This trailing stop can also be specified as part of the import parameters. I usually set to 100 points (usually 100 points equals 10 pips). The EA closes the trade after X number of seconds if the trade is still open. I usually set this to 84390 seconds (almost 24 hours period).
Most important: The EA was tested on OANDA demo account (see testing results section below). The EA did not work well on other providers like FXCM. May be this is because of the open and close time of the sticks. On OANDA , the sticks are opened during midnight of each day as per Eastern Standard time (USA east coast). I am not sure but this seems to be the reason. So, in other words, use the trading platform where the new sticks are opened during USA midnight. This must be impacted by the trading hours on major currency pairs but again … I am not entirely sure what this is happening. Please be careful and test this well before you put this on the live account.
I have setup a Forex Factory Trade Explorer for this EA. You can check it at this location – http://www.forexfactory.com/schopade/91
First and foremost – this EA must be run on multiple currencies at a time. The currency pairs I am using can be found at the trade explorer shown under the testing results section above. Also, do not run on any time frame other than daily as the results may be unexpected.
MaxOrders: This is the maximum number of orders you want the EA to open per symbol. Leave it at 1 as I have not designed it to work with more than 1 order per symbol. I have also not tested it on how it behaves when you change this setting. So leave it at 1 please.
referenceInterval: This is interval in number of seconds. This is put in as a precaution to avoid multiple executions of the code under certain circumstances. Leave it to 1440. As long as it is less than the number of seconds per stick, it should be fine.
InitialAccBal: This is the account balance in the base currency at the start of the account. Set this to the amount you started with. This is put in place so the money management can be done effectively.
LotSize: No need to explain this. It is the lot size used per trade. This gets adjusted by a factor depending on the money management flag is set or not. You can set it to the initial value that you want to start with.
StopLoss: This is the stop loss value to be used per trade in points. Note that this is in points and not in pips. Usually all major currency pairs, 10 points is 1 pip but it can vary depending on the currency pair and trading platform or broker.
TakeProfit: This is same as above but for take profit side.
TrailingTPOrig: This is a critical parameter for the success of this EA. Please set this carefully. This is the trailing stop the EA puts on every order in points. Note that again … this is not in PIPs. This is in points.
SecsToClose: These are the seconds from the start of the trade to that the EA will keep the trade open for. After this much time is passed and if the trade is still open, the EA will close it. When I am running this EA on the daily sticks, I usually set it to just below the total number of seconds a day has i.e. 84400. I usually set it to 84390. This way the orders don’t remain open if the broker closes trading a few seconds before the end of day on Friday. You can play around with it and see what makes most sense.
ArraySizeForCurr: This is another very critical parameter. This dictates the size of the array that holds the stick sizes. I usually set it to 5 as setting any low gives bad results and setting any higher gives very few trading opportunities. You are free to play with it and see what works best.
MoneyManagementFlag: This flag decides if the lot sizes are to be altered by the current profit in the account. For example, if the account balance has grown as compared to the initial account balance and if this flag is set, it increases the lot size in proportion to the profit. Same for the loss. This is another way of maximizing profit but note that this is a double-edged sword so use it carefully.
maxSpread: This is the maximum spread that the EA will tolerate. This is set in points (not in pips). This is a security measure to protect against the trading conditions when the spreads are too high like in case of holiday periods, weekend periods. I got reasonable results with 100 as my maxSpread.
CCI_ parameters: Leave these alone. They are not being used in the EA anymore.