Coding an EA

 

Could some code the following into an EA for me

I will write in terms of long trades of course short trades uses the reverse of the logic.

Long Trades

1. Opening Positions

Suppose that a bull candle [LC] has just closed. The EA takes a trade on the new candle [NC], X pips above the closed price of [LC]. The stop loss is set Y pips below the closed price of [LC]. The EA must not trade a particle candle more than once.

If the current trade is still open the EA should take the next trade if the above conditions occur in the same direction if the last trade is in profit by P (P=0 means take the trade if not in profit). Otherwise, the EA closes all open trades and open the new trade in the reverse direction.

The maximum open trades should be set at some N( by me.)

2. Lot Size

Three options

a. L_u set by user ,or

b. L_r computed based on r% of balance(not equity), or

c. L=min[L_u,L_r]

3. Trailing Stops(Two options)

After BE pips the initial stop loss is moved to Entry price +L pips and triggers trailing.

opt 1(Individual Trailing stop)

Actual trailing is done by step trailing. That is trail until profit is TT pips and jump by JJ pips, wait again until profit reaches TT pips then jump again. When JJ=1 we get usual trailing stop

opt2(Common Trailing stop)

All previous stops are moved to the stoploss of new position and trail as individual trailing above.

4. Take Profit: TP

Scale out v1% of lot size at TP1

v2% of lot size at TP2

rest of lot size at TP3

5. Stochastic Filter

No long trades when Stochastic (r,s,t) on time frame TF is above level LH and below level LL.

6.EA Should trade between time xxxx and zzzz.

EA must work fast on all time frames

Please let me know

Reason: