Momentum Trading EA Help

 

Hi Guys,

I have been trading on OANDA for years but am new to Autotrading platforms. I want to write an EA that will do the following but I have no idea where to start:

  • After 5consecutivepositive ticks (5 green 1-second candles), It should enter a long trade with the maximum units available (based on my current balance). With a TP of 3% (of current balance) and SL of -10% (of current balance).  
  • After 5 consecutive negative ticks (5 red 1-second candles), It should enter a short trade with the maximum units available (based on my current balance). With a TP of 3% (of current balance) and SL of -10% (of current balance).
There are a couple of things I want to mention/ask.

  • Yes I know 3% TP and -10% SL sounds crazy and is a massive negative risk-reward ratio, but I have run backtesting on millions of lines of historical 1 second data through VBA coding and the strategy is very profitable, as on a micro time-frame after a small trend is established the probability of reaching 3% TP is exponentially higher than hitting -10%, provided you use a leverage of no more than 50 and enter themaximum available unitson every trade. 
  • As I have always used OANDA, I am used to trading custom amount of units and not standard lots, mini lots etc. I have been playing around with MT4 and seen that you can't customise the exact amount of units (for example 4351 units, if that's what is available with your current balance in your account.) This is a serious drawback to my strategy and the only way to counter this is have the EA calculate what the maximum amount of micro lots can be traded with the current account balance and calculate where to place TP and SL levels so that combined the trades make up either 3% or -10%. Unless ofcourse there is any possible way to write the EA to use the available lots?? If not, then once a buy/sell entry parameter is reached, the EA should trade as many of the smallest lots (I'm assuming micro lots) as possible at the same time.
  • If the maximum available units (or as close to as possible) are not used, then to reach a target of 3%, the TP would have to be placed too far away from the entry point, cancelling out the effect of the short term trend.
  • As the idea would be to use (almost) all available units per trade, it should not be possible to enter short trade while a long trade is still open.
  • I want to trade EUR/USD primarily as it is the most liquid, but wish to later diversify across currencies, commodities and indices.  
  • I know that MT4 does not provide 1-second charts but have found some that people have created for MT4 online but cannot get them to work.
  • The maximum available units are calculated as (Current Balance in your account Current price ofEUR/USD) xLeverage- 1 
I would really appreciate any help on this as to where to start or even maybe a template from which to work from as I am proficient in coding R and VBA so I'll pick it up relatively easy.

Thanks in advance and happy trading!

Kind regards,

Anton. 

 
C0mput3r:

Hi Guys,

I have been trading on OANDA for years but am new to Autotrading platforms. I want to write an EA that will do the following but I have no idea where to start:

  • After 5consecutivepositive ticks (5 green 1-second candles), It should enter a long trade with the maximum units available (based on my current balance). With a TP of 3% (of current balance) and SL of -10% (of current balance).  
  • After 5 consecutive negative ticks (5 red 1-second candles), It should enter a short trade with the maximum units available (based on my current balance). With a TP of 3% (of current balance) and SL of -10% (of current balance).
There are a couple of things I want to mention/ask.

  • Yes I know 3% TP and -10% SL sounds crazy and is a massive negative risk-reward ratio, but I have run backtesting on millions of lines of historical 1 second data through VBA coding and the strategy is very profitable, as on a micro time-frame after a small trend is established the probability of reaching 3% TP is exponentially higher than hitting -10%, provided you use a leverage of no more than 50 and enter themaximum available unitson every trade. 
  • As I have always used OANDA, I am used to trading custom amount of units and not standard lots, mini lots etc. I have been playing around with MT4 and seen that you can't customise the exact amount of units (for example 4351 units, if that's what is available with your current balance in your account.) This is a serious drawback to my strategy and the only way to counter this is have the EA calculate what the maximum amount of micro lots can be traded with the current account balance and calculate where to place TP and SL levels so that combined the trades make up either 3% or -10%. Unless ofcourse there is any possible way to write the EA to use the available lots?? If not, then once a buy/sell entry parameter is reached, the EA should trade as many of the smallest lots (I'm assuming micro lots) as possible at the same time.
  • If the maximum available units (or as close to as possible) are not used, then to reach a target of 3%, the TP would have to be placed too far away from the entry point, cancelling out the effect of the short term trend.
  • As the idea would be to use (almost) all available units per trade, it should not be possible to enter short trade while a long trade is still open.
  • I want to trade EUR/USD primarily as it is the most liquid, but wish to later diversify across currencies, commodities and indices.  
  • I know that MT4 does not provide 1-second charts but have found some that people have created for MT4 online but cannot get them to work.
  • The maximum available units are calculated as (Current Balance in your account Current price ofEUR/USD) xLeverage- 1 
I would really appreciate any help on this as to where to start or even maybe a template from which to work from as I am proficient in coding R and VBA so I'll pick it up relatively easy.

Thanks in advance and happy trading!

Kind regards,

Anton. 

Very cool C0mput3r, have you tried this on different timeframe?
 

Hi Anton,

Getting the system coded by a freelancer here for mt4 is relatively simple and would be inexpensive, $100 for something so simple. Hooshang there has been good to me on a recent job.

MT4 will allow u to input whatever lot size u want...or am I missing something ? Why the MX amount of micro lots..why not one later order? and why the MAX, u leave urself no room for pullback if u use every bit of margin, I must be missing something.

I say mt4 v MT5 coz its more commonly used and more likely ur going to be getting better pricing on spread/vol commiss. Me not much idea about Oanda cept to say its my belief MT4 auto trade system are more commonly/easily built.

You say ticks, but in brackets 1 second bars, which is it......there can be multiple ticks in 1 second, and different feeds have greatly varying amounts of ticks. Surely such a system would have be tested and traded on tick data versus 1 second bars wouldn't it ? With 1 seconds bars u have so less data points of reference, much easier to curve fit and create profitable backtest...where as in real life its every tick you are dealing with....I used to build 1min and 5 min bar open systems but have moved away from it because of reason above.

You are going to want a good broker with genuine no spread markups or dodgy mt4 server side slips trading tick.

Interesting and simple concept, I like it....if it works, good luck :)

Cheers, Adam