Profitable EA, but needs a small change!
Hello,
The following EA based on Moving Average works perfectly on EUR/USD H4 200-6, EUR/USD H4 200-6, EUR/USD, H4 20-6 EUR/USD and AUD/USD H4 200-6. The problem is, that trailing stop is the only thing which closes positions. The code contains an original closing position, but it's inactive. What I would like to do with the code is to employ both trailing stop and the original closing condition. Could you try to make such code? I guarantee a high profitability of such code :-)
Thanks,
Martin
if(CalculateCurrentOrders(Symbol())==0) { CheckForOpen(); } else { Trailing_Stop() ; CheckForClose() ; }Would call both the Trailing Stop and CheckForClose
//---- go trading only for first tiks of new bar if(Volume[0]>1) return;
Volume is unreliable, must use Timestatic datetime Time0; bool newBar = Time0 < Time[0]; if (!newBar)) return(0); Time0 = Time[0];
void CheckForClose() ... for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
You must count DOWN when closing multiple orders or in the presence of multiple EAs/human.for(int i=OrdersTotal()-1; i>=0; i--) if( OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderMagicNumber()-=MAGICMA && OrderSymbol() ==Symbol()) { ...
- Must adjust TP, SL, and slippage on 5 digit brokers
//++++ These are adjusted for 5 digit brokers. double pips2points, // slippage 3 pips 3=points 30=points pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
What he said. Plus:
- Volume is unreliable, must use Time
- You must count DOWN when closing multiple orders or in the presence of multiple EAs/human.
- Must adjust TP, SL, and slippage on 5 digit brokers
Thanks for your advice! I managed to run trailing stop and closing condition at the same time, but I haven't succeeded in changing the 3 points you advised me. I'm a complete novice as a programmer...Could you please rewrite the original code wiht those changes you proposed?
Hello,
The following EA based on Moving Average works perfectly on EUR/USD H4 200-6, EUR/USD H4 200-6, EUR/USD, H4 20-6 EUR/USD and AUD/USD H4 200-6. The problem is, that trailing stop is the only thing which closes positions. The code contains an original closing position, but it's inactive. What I would like to do with the code is to employ both trailing stop and the original closing condition. Could you try to make such code? I guarantee a high profitability of such code :-)
Thanks,
Martin