EMA_WMA EA ECN mode - page 2

 

thank you all for repling

all those ea, but ill not let me do what i need.i try to write today, but with no use. file did not comply can any coder complay this for me.

/+------------------------------------------------------------------+

//| MACD Sample.mq4 |

//| Copyright © 2005, MetaQuotes Software Corp. |

//| MetaTrader 5 Trading Platform / MetaQuotes Software Corp. |

//+------------------------------------------------------------------+

extern double TakeProfit = 50;

extern double Lots = 0.1;

extern double TrailingStop = 30;

extern string Indicator_Setting = "---------- Indicator Setting";

extern int FastMAopenPeriod = 6;

FastMAType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

FastMAPrice = 0, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

FastMAshift = 0,

SlowMAopenPeriod = 26;

SlowMAType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

SlowMAPrice = 0, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

SlowMAshift = 0;

extern string Indicator_exitSetting ="---- Indicator Exit Setting"

extern int FastMAclosePeriod = 6;

FastMAType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

FastMAPrice = 0, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

FastMAshift = 0,

SlowMAclosePeriod =26;

FastMAType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

FastMAPrice = 0, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

FastMAshift = 0,

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int start()

{

int FastMAopenPeriod, SlowMAopenPeriod,

FastMAclosePeriod,SlowMAclosePeriod,

cnt, ticket, total;

// initial data checks

// it is important to make sure that the expert works with a normal

// chart and the user did not make any mistakes setting external

// variables (Lots, StopLoss, TakeProfit,

// TrailingStop) in our case, we check TakeProfit

// on a chart of less than 100 bars

if(Bars<100)

{

Print("bars less than 100");

return(0);

}

if(TakeProfit<10)

{

Print("TakeProfit less than 10");

return(0); // check TakeProfit

}

// to simplify the coding and speed up access

// data are put into internal variables

FastMAopenPeriod=iMA(NULL,FastMAshift,0,FastMAType,1,FastMAPrice,1);

SlowMAopenPeriod=iMA(NULL,SlowMAshift,0,SlowMAType,1,SlowMAPrice,2);

FastMAclosePeriod=iMA(NULL,FastMAshift,0,FastMAType,1,FastMAPrice,1);

SlowMAclosePeriod=iMA(NULL,SlowMAshift,0,SlowMAType,1,SlowMAPrice,3);

total=OrdersTotal();

if(total<1)

{

// no opened orders identified

if(AccountFreeMargin()<(1000*Lots))

{

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

// check for long position (BUY) possibility

if(FastMAopenPeriod<SlowMAopenPeriod)

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

}

// check for short position (SELL) possibility

if(FastMAopenPeriod>SlowMAopenPeriod)

{

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"macd sample",16384,0,Red);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL order : ",GetLastError());

return(0);

}

return(0);

}

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && // check for opened position

OrderSymbol()==Symbol()) // check for symbol

{

if(OrderType()==OP_BUY) // long position is opened

{

// should it be closed?

if(FastMAclosePeriod<SlowMAclosePeriod)

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position

return(0); // exit

}

// check for trailing stop

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

}

}

else // go to short position

{

// should it be closed?

if(FastMAclosePeriod>SlowMAclosePeriod)

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position

return(0); // exit

}

// check for trailing stop

if(TrailingStop>0)

{

if((OrderOpenPrice()-Ask)>(Point*TrailingStop))

{

if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

}

}

return(0);

}

// the end.

second try

 

here is another one i tried.

+------------------------------------------------------------------+

//| MaCross_EA_V3.mq4 |

//| Revised by OldZ 2010-12-27 23:09 |

//| Email: oldz.cn@qq.com |

//| MetaTrader 5 Trading Platform / MetaQuotes Software Corp. |

//+------------------------------------------------------------------+

extern double Lots = 0.1;

extern double StopLoss = 1000;

extern double TakeProfit = 200;

extern double TrailingStop = 40;

extern string Indicator_Setting = "---------- Indicator Setting";

extern int FastMAopenPeriod = 6,

FastMAopenType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

FastMAopenPrice = 1, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

FastMAopenshift = 0,

SlowMAopenPeriod = 20,

SlowMAopenType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

SlowMAopenPrice = 2, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

SlowMAopenshift = 0;

extern string Exit_Setting = "---------- Exit Setting";

extern int FastMAclosePeriod = 6,

FastMAcloseType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

FastMAclosePrice = 1, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

FastMAcloseshift = 0,

SlowMAclosePeriod = 20,

SlowMAcloseType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

SlowMAclosePrice = 3, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

SlowMAcloseshift = 0;

//----------------------- INTER PARAMETER

int start()

{

FastMAopenPeriod, SlowMAopenPeriod, FastMAclosePeriod,SlowMAclosePeriod,

int cnt, ticket, total;

if(Bars<100)

{

Print("bars less than 100");

return(0);

}

if(TakeProfit<10)

{

Print("TakeProfit less than 10");

return(0); // check TakeProfit

}

// define ema

FastMAopenPeriod = iMA(NULL,0,MODE_EMA,PRICE_OPEN,0);

SlowMAopenPeriod = iMA(NULL,0,MODE_EMA,PRICE_OPEN,1);

FastMAclosePeriod = iMA(NULL,0,MODE_EMA,PRICE_OPEN,1);

SlowMAclosePeriod = iMA(NULL,0,MODE_EMA,PRICE_OPEN,0);

total=OrdersTotal();

if(total<1)

{

// no opened orders identified

if(AccountFreeMargin()<(1000*Lots))

{

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

// check for long position (BUY) possibility

if (FastMAopenPeriod<SlowMAopenPeriod) //Buy

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

}

return(0);

}

// it is important to enter the market correctly,

// but it is more important to exit it correctly...

{

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && // check for opened position

OrderSymbol()==Symbol()) // check for symbol

{

if(OrderType()==OP_BUY) // long position is opened

{

// should it be closed?

if (FastMAclosePeriod<SlowMAclosePeriod)

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position

return(0); // exit

}

// check for trailing stop

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

}

}

}

 

second tried at code.

+------------------------------------------------------------------+

//| MaCross_EA_V3.mq4 |

//| Revised by OldZ 2010-12-27 23:09 |

//| Email: oldz.cn@qq.com |

//| MetaTrader 5 Trading Platform / MetaQuotes Software Corp. |

//+------------------------------------------------------------------+

extern double Lots = 0.1;

extern double StopLoss = 1000;

extern double TakeProfit = 200;

extern double TrailingStop = 40;

extern string Indicator_Setting = "---------- Indicator Setting";

extern int FastMAopenPeriod = 6,

FastMAopenType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

FastMAopenPrice = 1, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

FastMAopenshift = 0,

SlowMAopenPeriod = 20,

SlowMAopenType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

SlowMAopenPrice = 2, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

SlowMAopenshift = 0;

extern string Exit_Setting = "---------- Exit Setting";

extern int FastMAclosePeriod = 6,

FastMAcloseType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

FastMAclosePrice = 1, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

FastMAcloseshift = 0,

SlowMAclosePeriod = 20,

SlowMAcloseType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

SlowMAclosePrice = 3, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

SlowMAcloseshift = 0;

//----------------------- INTER PARAMETER

int start()

{

FastMAopenPeriod, SlowMAopenPeriod, FastMAclosePeriod,SlowMAclosePeriod,

int cnt, ticket, total;

if(Bars<100)

{

Print("bars less than 100");

return(0);

}

if(TakeProfit<10)

{

Print("TakeProfit less than 10");

return(0); // check TakeProfit

}

// define ema

FastMAopenPeriod = iMA(NULL,0,MODE_EMA,PRICE_OPEN,0);

SlowMAopenPeriod = iMA(NULL,0,MODE_EMA,PRICE_OPEN,1);

FastMAclosePeriod = iMA(NULL,0,MODE_EMA,PRICE_OPEN,1);

SlowMAclosePeriod = iMA(NULL,0,MODE_EMA,PRICE_OPEN,0);

total=OrdersTotal();

if(total<1)

{

// no opened orders identified

if(AccountFreeMargin()<(1000*Lots))

{

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

// check for long position (BUY) possibility

if (FastMAopenPeriod<SlowMAopenPeriod) //Buy

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

}

return(0);

}

// it is important to enter the market correctly,

// but it is more important to exit it correctly...

{

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && // check for opened position

OrderSymbol()==Symbol()) // check for symbol

{

if(OrderType()==OP_BUY) // long position is opened

{

// should it be closed?

if (FastMAclosePeriod<SlowMAclosePeriod)

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position

return(0); // exit

}

// check for trailing stop

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

}

}

}

 

I tried MA_ExpertProfit_noacc EA - it is bacjktested and trades are opened ...

and ma_expert EA is exactly what you asked: 2 ema entry and 2 ema exit with the parameters changable in the settings (EA's input).

 
cway:
second tried at code.

+------------------------------------------------------------------+

//| MaCross_EA_V3.mq4 |

//| Revised by OldZ 2010-12-27 23:09 |

//| Email: oldz.cn@qq.com |

//| MetaTrader 5 Trading Platform / MetaQuotes Software Corp. |

//+------------------------------------------------------------------+

extern double Lots = 0.1;

extern double StopLoss = 1000;

extern double TakeProfit = 200;

extern double TrailingStop = 40;

extern string Indicator_Setting = "---------- Indicator Setting";

extern int FastMAopenPeriod = 6,

FastMAopenType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

FastMAopenPrice = 1, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

FastMAopenshift = 0,

SlowMAopenPeriod = 20,

SlowMAopenType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

SlowMAopenPrice = 2, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

SlowMAopenshift = 0;

extern string Exit_Setting = "---------- Exit Setting";

extern int FastMAclosePeriod = 6,

FastMAcloseType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

FastMAclosePrice = 1, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

FastMAcloseshift = 0,

SlowMAclosePeriod = 20,

SlowMAcloseType = 1, //0:SMA 1:EMA 2:SMMA 3:LWMA

SlowMAclosePrice = 3, //0:Close 1:Open 2:High 3:Low 4:Median 5:Typical 6:Weighted

SlowMAcloseshift = 0;

//----------------------- INTER PARAMETER

int start()

{

FastMAopenPeriod, SlowMAopenPeriod, FastMAclosePeriod,SlowMAclosePeriod,

int cnt, ticket, total;

if(Bars<100)

{

Print("bars less than 100");

return(0);

}

if(TakeProfit<10)

{

Print("TakeProfit less than 10");

return(0); // check TakeProfit

}

// define ema

FastMAopenPeriod = iMA(NULL,0,MODE_EMA,PRICE_OPEN,0);

SlowMAopenPeriod = iMA(NULL,0,MODE_EMA,PRICE_OPEN,1);

FastMAclosePeriod = iMA(NULL,0,MODE_EMA,PRICE_OPEN,1);

SlowMAclosePeriod = iMA(NULL,0,MODE_EMA,PRICE_OPEN,0);

total=OrdersTotal();

if(total<1)

{

// no opened orders identified

if(AccountFreeMargin()<(1000*Lots))

{

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

// check for long position (BUY) possibility

if (FastMAopenPeriod<SlowMAopenPeriod) //Buy

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

return(0);

}

return(0);

}

// it is important to enter the market correctly,

// but it is more important to exit it correctly...

{

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()<=OP_SELL && // check for opened position

OrderSymbol()==Symbol()) // check for symbol

{

if(OrderType()==OP_BUY) // long position is opened

{

// should it be closed?

if (FastMAclosePeriod<SlowMAclosePeriod)

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position

return(0); // exit

}

// check for trailing stop

if(TrailingStop>0)

{

if(Bid-OrderOpenPrice()>Point*TrailingStop)

{

if(OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);

return(0);

}

}

}

}

}

Hi Cway,

I'll make you an Ea if you don't mind, just tell me exactly what you want and will see what I can do.

 

please

newdigital:
Hi cway,

There are same Eas which I created long time ago using Gordago:

1. ma_expert EA: Enter on 2 ema crossing and exit on 2 ema crossing

2. MA_ExpertProfit EA: it is the same EA but it will close the orders in s/l or t/p only.

3. MA_ExpertProfit_all EA: it will close the order on s/l or t/p, or on the other crossing signal. This EA should work on particular account only. Just change the line "int Account = 111111;" to your account number inside the code. For example your account is 1235463. So this line should be like this:

int Account = 1235463.

4. MA_ExpertProfit_noacc.mq4: it is the same with item # 3. But it may work in any account (i mean account in Metatrader).

And EMA_6_12 EA is the EA coded by Codersguru.

Those EAs were coded long time ago so you can select any version and ask MrTools to improve/correct it for ecn options and 5 digit broker for example.

I have some questions if you can!

For MA_ExpertProfit_noacc.mq4 if change the number of lots from 0.1 to 0.01, I set another moving average, does it work?

And at what time I go to put the other slots?

I'm interested in minilots because otherwise it's too expensive for me.

please, thank you

 
gtudor:
I have some questions if you can!

For MA_ExpertProfit_noacc.mq4 if change the number of lots from 0.1 to 0.01, I set another moving average, does it work?

And at what time I go to put the other slots?

I'm interested in minilots because otherwise it's too expensive for me.

please, thank you

Hello and thanks for the help again, the problem with the MA_ExpertProfit EA is not that is not trading. It works like it was design to do, but I cannot use it with my strategy. MY strategy is base on the cross of 4 different ema, but the pricetype are all not the same. for example 10eam-open crossing the 50eam-High will sell and i will exit when the 10eam-open crossed 50eam-Low. or exit when 20eam on the open cross 140eam-low. So basically i just need to be able to crontol the pricetype in the parameter box. not on the internal parameter. the MA_eperProfit just have the ablelity to change the color?, and 2 eam, not the pricetype of the eam of the two. I just need more control. I had the universal cross ea and it does get the entry right, but the exit i can't control as i want it to. if any one could add a exit option as i mention to that ea and post it here that will be appraciated or help me comply the one i posted.

thanks you

 

Sorry I don't know how long it take to get the Posted so I'm reposting just in case.

Hello gtudor and mrtool,

I post this early, but it never posted so I retype it.

The problem with the MA_expert EA is not that is not working property. It is working as it was design, but I cannot use it for my strategy. My strategy is base on 4 independent eams with 4 price type, for example I will trade like this. When the10eam-on the-opencrosses the50eam-on the-highI will open a sell order and exit when10eam-on the-opencrosses50eam-on the-low orwhenthe20eam-on the-opencrossesthe140eam-on the-typical price.Ineed to be able to control the price-type of all 4eam. So if you could change the MA_expert EA to do this I’ll appreciated. Also I need to be able to make changes on the parameter box (ea properties), not on the internal code source. I have the universal cross ea and I could get it to get the entry perfect, but I can’t control the exit so if you could morify the exit to use 2 eam different front the entry cross that will make the perfect EA. Thank again for the help. P.s. how bad is my EA to make it comply.

needs EA - Mrtool or gtudor if you are making a new EA

4 eam with indepenent setting- able to change on the strategy tester properties box

2 eam will cross for entry

2 will cross for exit

stoploss

takeprofit

breakeven

hours of operation

slippage

maxopentrade

lot

oneentryperbar

trailling stop

ecn -comparable

 

Hi gtudor and cway,

I think - you can use 0.01 lot size.

about additional ema's so we can ask MrTools to evaluate my EAs uploaded here and improve it.

 

Thanks !

newdigital:
Hi gtudor and cway,

I think - you can use 0.01 lot size.

about additional ema's so we can ask MrTools to evaluate my EAs uploaded here and improve it.

thanks very much !

Reason: