Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Just Another Martingale EA (Just Another Martingale EA)

author EAcpu | 5 reads | 0 comments |
Mr. Xilitang ’s post made me inspired again by the promised EA system ..

So here I am continuing the martingale strategy development from the old code I have (see this thread needing 3060EA and backtesting help )

Time frame: H1
Currency pair: GBP/USD, USD/CHF Deposit: 10,000

First purchase transaction conditions:

inserted code
 if(MFI<=0      
      && MFID>50 
      && CountOrder.Buy()==0
      && bid>ema50
      && bid>ema20
      && Bid>Lowest price[iLowest(NULL,0,MODE_LOW,3,0)]+100*points)

First sale transaction conditions:

inserted code
 if(MFI>=100       
      && MFID<50
      && CountOrder.Sell()==0
      && bid>ema50
      && Bid<ema20 
      && Bid +100*points<highest price[iHighest(NULL,0,MODE_HIGH,3,0)]
      )

MFI=Money Flow Index, H1, Bar[0]
MFID=Money Flow Index, day, bar[0]
ema... = exp moving average

When the "first" trade is taken, the trailing stop takes over the rest.
If there is a loss, another transaction is opened and the profit is recovered with a certain offset amount.
I use 2xATR (twice the average true range) for offset - about 20-60 points depending on how wild the market is.

inserted code
 Double ATR=iATR(NULL,0,14,0);

The lot sizes of the second, third, and fourth orders are larger and lower/higher than the first opening transaction. The calculation formula is:

inserted code
  
LotBuy=startlot*MathPow(1.4,CountOrder.Buy());
LotSell=startlot*MathPow(1.4,CountOrder.Sell());

The concept of trailing stops is the same as SteveHopwood's MPTM (I didn't copy, just thought he did the same thing before in this link: http://www.stevehopwoodforex.com/php....php?f=21&t=64)

Trigger 1 is the distance (in points) to the open price/stop, when touched it will move the stop up/down (relative to buy/sell) by 1 point
inserted code
 External integer trigger 1=150;
external int move1=30;

Trying to optimize these two numbers can give you a variety of results. I never do that. Feel free to spend your CPU time on it.

Well, I didn't do the forward testing because I just finished it an hour ago before writing this.

My ultimate goal (for Martingale) is to "deposit $100 and start running on the GBPUSD currency pair using the Martinale strategy, Standard account, 0.01 lot"...but I'm not there yet.

P.S. English is very poor, I
Capture.PNG
Capture.PNG
Capture.PNG
Capture.PNG
Capture.PNG
Capture.PNG

Attachment to original post (2)

Verification code Refresh