a_r_n_v2-1

a_r_n_v2-1

更新日期:2022-11-16分类标签: 语言:中文平台:没限制

45 人已下载 手机查看

a_r_n_v2-1

 

//+——————————————————————+
//| A_R_N.mq4 |
//| Copyright 2014, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+——————————————————————+
//+——————————————————————+
#property copyright “GGG Mâcon France”
#property link “free ”
#property version “1.00”
#property strict

extern int MagicNumber = 562148;
extern double lot = 0.1;
extern double step = 100;

double Lots[15] = { 0.05, 0.1, 0.2, 0.4, 0.8, 1.6, 3.2, 6.4 };
int max_loss[50], max_win[50];
//+——————————————————————+
//| Expert initialization function |
//+——————————————————————+
int OnInit()
{
//—

//—
return(INIT_SUCCEEDED);
}
//+——————————————————————+
//| Expert deinitialization function |
//+——————————————————————+
void OnDeinit(const int reason)
{
//—

}
//+——————————————————————+
//| Expert tick function |
//+——————————————————————+
void OnTick()
{
//—
// ResetLastError();

if( GetLastError() == 134 ) return;//

int consecutive_win =0, consecutive_loss = 0, typ_last_win = -1;
double last_LOT = 0, last_WIN = 0, last_OOP = 0;;
int last_OCT_win = -1 , last_number = -1;
int typ_last_loss = -1, last_OCT_loss = -1;

for(int i=0; i <OrdersHistoryTotal(); i++)
{
if( OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true &&
OrderMagicNumber() == MagicNumber )
{
if( OrderProfit() > 0 )
{
consecutive_win ++;
consecutive_loss = 0;
typ_last_win = OrderType() ;
last_LOT = OrderLots();
last_WIN = OrderProfit();
last_OCT_win = OrderCloseTime();
last_OOP = OrderOpenPrice();
last_number = i+1;
}
if( OrderProfit() < 0 )
{
consecutive_loss ++;
consecutive_win = 0;
typ_last_loss = OrderType() ;
last_LOT = OrderLots();
last_WIN = OrderProfit();
last_OCT_loss = OrderCloseTime();
last_OOP = OrderOpenPrice();
last_number = i+1;
}
}
}

if( last_number == 100 ) OnDeinit(134);

if( max_loss[0] < consecutive_loss) max_loss[0] = consecutive_loss;
if( max_win[0] < consecutive_win) max_win[0] = consecutive_win;

string way;
if( typ_last_loss == 0 ) way = “buy”; else if( typ_last_loss == 1) way = “sell”;
string Nom_EA =”GGG_Macon”;
ObjectDelete (Nom_EA+”LOSS” );
ObjectCreate (Nom_EA+”LOSS” , OBJ_LABEL, 0 ,0,0);
ObjectSet (Nom_EA+”LOSS” , OBJPROP_XDISTANCE, 520 );
ObjectSet (Nom_EA+”LOSS” , OBJPROP_YDISTANCE,25 );
ObjectSetText(Nom_EA+”LOSS”, “LOSS “+ (string) consecutive_loss + ” WIN “+(string)consecutive_win , 8, “Arial Black”, Coral );
ObjectsRedraw();
ObjectDelete (Nom_EA+”MAX” );
ObjectCreate (Nom_EA+”MAX” , OBJ_LABEL, 0 ,0,0);
ObjectSet (Nom_EA+”MAX” , OBJPROP_XDISTANCE, 520 );
ObjectSet (Nom_EA+”MAX” , OBJPROP_YDISTANCE,55 );
ObjectSetText(Nom_EA+”MAX”, “Max_Loss “+ (string) max_loss[0] + ” Max_WIN “+(string) max_win[0] , 8, “Arial Black”, Violet );
ObjectsRedraw();
//———————————————————–
string last_order, genre;

// last order win or loss ?
if( last_OCT_win > last_OCT_loss ) // if it was a win
{ // was it a buy or a sell ?
last_order = “Win “;
if(typ_last_win == 0 ) { genre =”Buy “; Open_Order( OP_BUY, lot ); }
if(typ_last_win == 1 ) { genre = “Sell “; Open_Order( OP_SELL, lot ); }
}
if( last_OCT_win < last_OCT_loss )
{
last_order = “Loss “;
if( typ_last_loss == 0 ) { genre =” Buy “; Open_Order( OP_SELL, Lots[ consecutive_loss + 1]); }
if( typ_last_loss == 1 ) { genre = ” Sell “; Open_Order( OP_BUY, Lots[ consecutive_loss + 1]); }
}
// ————— INFO ——————————-
ObjectDelete (Nom_EA+”last_order” );
ObjectCreate (Nom_EA+”last_order” , OBJ_LABEL, 0 ,0,0);
ObjectSet (Nom_EA+”last_order” , OBJPROP_XDISTANCE, 50 );
ObjectSet (Nom_EA+”last_order” , OBJPROP_YDISTANCE,200 );
ObjectSetText(Nom_EA+”last_order”, “”+(string)last_number+” “+”last_order “+ last_order +genre , 8, “Arial Black”, YellowGreen );
ObjectsRedraw();
ObjectDelete (Nom_EA+”lots” );
ObjectCreate (Nom_EA+”lots” , OBJ_LABEL, 0 ,0,0);
ObjectSet (Nom_EA+”lots” , OBJPROP_XDISTANCE, 50 );
ObjectSet (Nom_EA+”lots” , OBJPROP_YDISTANCE,150 );
ObjectSetText(Nom_EA+”lots”, “step ” + (string)step + ” lots “+(string) Lots[ consecutive_loss + 1], 8, “Arial Black”, PaleGreen );
ObjectsRedraw();
//======== first order ===============================================
double AO = iAO(NULL,0,1);
if( OrdersTotal() == 0 )
{
if( AO > 0 ) Open_Order( OP_BUY, lot );
if( AO < 0 ) Open_Order( OP_SELL, lot );
}
//=================================================================
int buy = 0, sell = 0; double profit_buy = 0, profit_sell = 0;
int j=-1, i= -1; double tot_oop_buy = 0, tot_oop_sell = 0;
//==================================================================
j=OrdersTotal()-1;
for (i=j;i>=0;i–) {
if( OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) continue;
if(OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol())
{ if( OrderType()== OP_BUY )
{ buy++; profit_buy += OrderProfit(); tot_oop_buy += OrderOpenPrice(); }
if( OrderType()== OP_SELL )
{ sell++; profit_sell += OrderProfit(); tot_oop_sell += OrderOpenPrice(); }
} }
//——————————————————————————
string PROF_BUY, PROF_SELL; PROF_BUY = DoubleToStr(profit_buy, 0);PROF_SELL = DoubleToStr(profit_sell, 0);

ObjectDelete (Nom_EA+”profit” );
ObjectCreate (Nom_EA+”profit” , OBJ_LABEL, 0 ,0,0);
ObjectSet (Nom_EA+”profit” , OBJPROP_XDISTANCE, 50 );
ObjectSet (Nom_EA+”profit” , OBJPROP_YDISTANCE,100 );
ObjectSetText(Nom_EA+”profit”, ” buy “+(string)buy+” €”+PROF_BUY+” sell “+(string)sell+” €”+PROF_SELL, 8, “Arial Black”, PaleGreen );
ObjectsRedraw();

//———-
return;
}
//+——————————————————————+

//===================================================================
int Open_Order( int tip, double llots )
{
int ticket = -1;
double spread=-1;spread = MarketInfo(Symbol(), MODE_SPREAD);
double max_lot; max_lot = MarketInfo(Symbol(), MODE_MAXLOT);
if( llots > max_lot ) llots = NormalizeDouble( (max_lot-1), Digits);
if( OrdersTotal() == 0 )
{
if( tip == 0 )
{
while( ticket == -1)
{
ticket = OrderSend(Symbol(),OP_BUY, llots,Ask,3, Bid – step*Point, Bid + (1*step*Point+2*spread*Point), “Project moon v1.00″,MagicNumber,0, PaleGreen );
if( ticket > -1 ) break;
else if( GetLastError() == 134 ) break;
else if( GetLastError() == 4051 ) break;
else Sleep(10000);
} }

if( tip == 1 )
{
ticket = -1;
while( ticket == -1)
{
ticket =OrderSend(Symbol(),OP_SELL,llots,Bid,3,Ask+step*Point,Ask-(1*step*Point+2*spread*Point),”Project moon v1.00”,MagicNumber,0, Red);
if( ticket > -1 ) break;
else if( GetLastError() == 134 ) break;
else if( GetLastError() == 4051 ) break;
else Sleep(10000);
} }
}
//———–
return(0);
}

如果你对文件有了解,请帮助投票!

If you are familiar with the file, please help vote!

平均评分 0 / 5. 投票数: 0

到目前为止还没有投票!成为第一位投票人。

相关资源

暂无评论

暂无评论...