Petit capital...très nombreux gains ...gagnant a 100%...tout petit programme ....lot a ajustement progressif.
Code
//+------------------------------------------------------------------+
//| eaxtwoependingaorders.mq4 |
//| Copyright 2019, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
//#property strict
extern int MagicNumber=20100807; //magic
extern double LotFactor =50; //lotsize factor
double lot;
extern double Ecart = 50;
extern double stop_loss = 00;
extern double take_profit = 80;
extern int last_bar = 0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start(){
double MyPoint=Point;
if(Digits==3 || Digits==5) MyPoint=Point*10;
new_del () ;
if (last_bar == Bars ) return ( 0 );
last_bar = Bars ;
if ( OrdersTotal () == 0 ) {
int buystop= OrderSend ( Symbol (), OP_BUYSTOP, NR(Lot_Volume()), Ask + Ecart * Point , 3 , Ask + Ecart * Point - stop_loss * Point , Bid + Ecart * Point + take_profit * Point ,"eaxtwoependingaorders",MagicNumber, 0 , Blue);
int sellstop =OrderSend ( Symbol (), OP_SELLSTOP, NR(Lot_Volume()), Bid - Ecart * Point , 3 , Bid - Ecart * Point + stop_loss * Point, Ask - Ecart * Point - take_profit * Point ,"eaxtwoependingaorders", MagicNumber, 0 , Red);
}
return ( 0 );
}
//-------------------- ( to close pending order) ---------------
int new_del()
{
int i,a;
int total = OrdersTotal();
string comentario,par;
for (i=total-1; i >=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if (OrderType()==OP_BUY || OrderType()==OP_SELL)
{
for (a=total-1; a >=0; a--)
{
if(OrderSelect(a,SELECT_BY_POS,MODE_TRADES))
comentario=OrderComment();
par=StringSubstr(comentario,0,6);
//
if(OrderType()==OP_SELLSTOP)
{
bool modify1= OrderDelete(OrderTicket());
Print("Deleting SELL_STOP"," Ordertype:",OrderType());
return(1);
}
//
if(OrderType()==OP_BUYSTOP)
{
bool modify2= OrderDelete(OrderTicket());
Print("Deleting BUY_STOP"," Ordertype:",OrderType());
return(1);
}
}
}
}
return ( 0 );
}
//+------------------------------------------------------------------+
//insuring its a new candle function
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//Calculates Lot Size based on balance and factor
double NR(double thelot)
{
double maxlots=MarketInfo(Symbol(),MODE_MAXLOT),
minilot=MarketInfo(Symbol(),MODE_MINLOT),
lstep=MarketInfo(Symbol(),MODE_LOTSTEP);
double lots=lstep*NormalizeDouble(thelot/lstep,0);
lots=MathMax(MathMin(maxlots,lots),minilot);
return (lots);
}
int TotalOrdersCount()
{
int result=0;
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS ,MODE_TRADES))
if (OrderMagicNumber()==MagicNumber) result++;
}
return (result);
}
//+------------------------------------------------------------------+
double Lot_Volume()
{
lot=AccountBalance() * 0.01 /LotFactor ;
return(lot);
}
//+------------------------------------------------------------------+