for example ; our account balance is 10000 usd. there are some trades 0.01 lots, if it's profitable, ea continue trades 0.01 lots. if it is lost, (ex balance will be 9000) ea trades 0.02 lots until balance will be 10000 again.
ea trades 0.01 lots start 10000 usd , it profitable and new balance will be 11000 usd, continue to trade 0.01 lots. if it's loss, (exampe balance will be 9500), ea trades 0.02 lots until balance will be 11000 again.
account balance in starting, is 10000 usd, if ea trades lost, (new balance 9000) it is trade with 0.02 lots and loss again (new balance is 8000) it continue 0.04 lots until balance will be 10000 again.
how can i write this ??
this ea is mixed rampolk and setka robots, in this forum. these are advised me.
help please :(
//+------------------------------------------------------------------+ //| diriliş.mq4 | //| Copyright 2013, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "by Yılmaz KAHYA, thanks to Engin Yorgancıoğlu" // girdiler extern double ylot=0.01 ; extern double klot= 2; //lot katlama sayısı extern double yEnvelope = 0.07; extern int yPips=40; // iki işlem arası pip farkı değeri. 5 digit. spread hariç int OpenOrders=0 ; int myOrderType=0; extern int Ztrades=30 ; //ztrades zıplama işlemi anlamına gelir, bundan sonraki işlemler iki katı hacimde açılır. extern int Plus= 50; //birden çok işlemin kar al seviyesini belirlerken pip cinsinden artı katma değer sağlar. extern int TakeProfit = 300; extern int Slip=2; extern int Magic=1; int cnt=0 ; double LastPrice=0; double BuyPrice=0, SellPrice=0; int LastTicket=0, LastType=0 ; int mode=0 ; double a=0 ; double b=0 ; double c=0 ; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- işleme başlangıç için gerekli envelope ayarları, işlem açıldıktan sonra OpenOrders artırmayı unutma if (OpenOrders<1) { myOrderType=3; //if (iMACD(14,26,9,MODE_MAIN,0)>0 and iMACD(14,26,9,MODE_MAIN,0)>iMACD(14,26,9,MODE_MAIN,1))then OrderType=2; //if ((iEnvelopes(NULL, NULL,15,MODE_SMA,0,PRICE_CLOSE,DeviasiEnvelope,MODE_LOWER,0) > Open[0]) && (iEnvelopes(NULL, NULL,15,MODE_SMA,0,PRICE_CLOSE,DeviasiEnvelope,MODE_LOWER,0) < Bid)) { myOrderType=2; } if (iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,0)>iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1)) { myOrderType=2; } //if (iMACD(14,26,9,MODE_MAIN,0)<0 and iMACD(14,26,9,MODE_MAIN,0)<iMACD(14,26,9,MODE_MAIN,1)) then OrderType=1; //if ((iEnvelopes(NULL, NULL,15,MODE_SMA,0,PRICE_CLOSE,DeviasiEnvelope,MODE_UPPER,0) < Open[0]) && (iEnvelopes(NULL, NULL,15,MODE_SMA,0,PRICE_CLOSE,DeviasiEnvelope,MODE_UPPER,0) > Bid)) { myOrderType=1; } if (iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,0)<iMACD(NULL,0,14,26,9,PRICE_CLOSE,MODE_MAIN,1)) { myOrderType=1; } } //işleme giriş a=AccountBalance () ; if (myOrderType==2 && OrdersTotal()<1 ) { OrderSend(Symbol(),OP_BUY ,ylot,Ask,Slip,0,0,"Buy ",0,0,Green); } //cnt ve bir sonraki işleme geçiş için OpenTrades değerini artırma for(cnt=0;cnt<OrdersTotal();cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol()==Symbol()) { OpenOrders++; } } //30a kadar olan işlemlere giriş LastPrice=OrderOpenPrice(); if ((LastPrice-Ask)>=yPips*Point && OpenOrders>0 ) { OrderSend(Symbol(),OP_BUY,ylot,Ask,Slip,0,0,NULL,0,0,Blue); } //---- tp hesabının yapıldığı yer int total=OrdersTotal(); double nn=0,bb=0; for(int ui=total-1; ui>=0; ui--) { if(OrderSelect(ui,SELECT_BY_POS)) { if(OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY ) { double op=OrderOpenPrice(); double llot=OrderLots(); double itog=op*llot; bb=bb+itog; nn=nn+llot; double factb=bb/nn; } } } } //tp hesabı for(int uui=total-1; uui>=0; uui--) { double CORR=NormalizeDouble(Plus*Point,Digits); if(OrderSelect(uui,SELECT_BY_POS)) { if(OrderSymbol()==Symbol()) { if(OpenOrders>=1 && OrderType()==OP_BUY ) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),factb+CORR,0,Blue); } } } } // işlemlerin kapandığı yer OpenOrders=OrdersTotal() ; if (OpenOrders==Ztrades) { for(cnt=OrdersTotal();cnt>=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); mode=OrderType(); if (OrderSymbol()==Symbol()) { if (mode==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slip,Blue); } } } } b=AccountBalance() ; //i don't know what can i do after there return(0); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
sorry for my bad english :(
i m studying an ea. for example there is five trades close stop loss. i want after five trades will open 2xlots. how can i do this on mql ?
for example ;
1 buy... 0.1 lots
2 buy... 0.1 lots
3 buy 0.1 lots
4 buy 0.1 lots
5 buy 0.1 lots (i can do this with martingale or other methods)
5 close ..
4 close..
3. close
2. close
1. close
6. buy 0.2 lots
7. buy 0.2 lots
8. buy 02. lots
9. buy 0.2 lots
10 buy 0.2 lots
how can i do that ? please help ?