المشاركة الأصلية كتبت بواسطة stop1
اخي الكريم
وظعت الشرط الثاني
ولكن عندما اظغط على Compile يخبرني بوجود خطء MagicNumber
ارجو منك ان تلقي نظرة عليه وتصحح الخطء
جزاك الله الف خير
[PHP]//================================//
extern int magic = 8945;
extern int slipage = 3;
//--------------------------------//
extern int MA_Shift = 0;
extern int MA_Period = 25;
//--------------------------------//
extern int Step =50;
extern double Lots = 0.01;
//--------------------------------//
extern double StopLoss = 50;
extern double TakeProfit = 50;
//================================//
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//===//
double ma_h,ma_l;
//------------------- --------------------//
ma_h=iMA(NULL,0,MA_Period,MA_Shift,MODE_SMMA,PRICE _HIGH,0);
ma_l=iMA(NULL,0,MA_Period,MA_Shift,MODE_SMMA,PRICE _LOW,0);
//================================================== ===========//
if( Bid>( ma_h+(Step*Point) ) && OrdersTotal()==0 )
{
//===//
OrderSend(Symbol(),OP_SELL ,Lots ,Bid ,slipage,Bid+(StopLoss*Point) ,Bid-(TakeProfit*Point) ,"thank",magic,0,Red);
OrderSend(Symbol(),OP_SELLLIMIT,Lots*( 2),Bid+(StopLoss*Point) ,slipage,Bid+(StopLoss*Point)* 2,Bid ,"thank",magic,0,Red);
OrderSend(Symbol(),OP_SELLLIMIT,Lots*( 3),Bid+(StopLoss*Point)*2,slipage,Bid+(StopLoss*Po int)* 3,Bid+(TakeProfit*Point) ,"thank",magic,0,Red);
OrderSend(Symbol(),OP_SELLLIMIT,Lots*( 4),Bid+(StopLoss*Point)*3,slipage,Bid+(StopLoss*Po int)* 4,Bid+(TakeProfit*Point)*2,"thank",magic,0,Red);
OrderSend(Symbol(),OP_SELLLIMIT,Lots*( 5),Bid+(StopLoss*Point)*4,slipage,Bid+(StopLoss*Po int)* 5,Bid+(TakeProfit*Point)*3,"thank",magic,0,Red);
OrderSend(Symbol(),OP_SELLLIMIT,Lots*( 6),Bid+(StopLoss*Point)*5,slipage,Bid+(StopLoss*Po int)* 6,Bid+(TakeProfit*Point)*4,"thank",magic,0,Red);
OrderSend(Symbol(),OP_SELLLIMIT,Lots*( 7),Bid+(StopLoss*Point)*6,slipage,Bid+(StopLoss*Po int)* 7,Bid+(TakeProfit*Point)*5,"thank",magic,0,Red);
OrderSend(Symbol(),OP_SELLLIMIT,Lots*( 8),Bid+(StopLoss*Point)*7,slipage,Bid+(StopLoss*Po int)* 8,Bid+(TakeProfit*Point)*6,"thank",magic,0,Red);
OrderSend(Symbol(),OP_SELLLIMIT,Lots*( 9),Bid+(StopLoss*Point)*8,slipage,Bid+(StopLoss*Po int)* 9,Bid+(TakeProfit*Point)*7,"thank",magic,0,Red);
OrderSend(Symbol(),OP_SELLLIMIT,Lots*(10),Bid+(Sto pLoss*Point)*9,slipage,Bid+(StopLoss*Point)*10,Bid +(TakeProfit*Point)*8,"thank",magic,0,Red);
//===//
}
//-------------------------------------------------------------//
//================================================== ===========//
if( Ask<( ma_l-(Step*Point) )&& OrdersTotal()==0 )
{
//===//
OrderSend(Symbol(),OP_BUY ,Lots ,Ask ,slipage,Ask-(StopLoss*Point) ,Ask+(TakeProfit*Point) ,"thank",magic,0,Blue);
OrderSend(Symbol(),OP_BUYLIMIT,Lots*( 2),Ask-(StopLoss*Point) ,slipage,Ask-(StopLoss*Point)* 2,Ask ,"thank",magic,0,Blue);
OrderSend(Symbol(),OP_BUYLIMIT,Lots*( 3),Ask-(StopLoss*Point)*2,slipage,Ask-(StopLoss*Point)* 3,Ask-(TakeProfit*Point) ,"thank",magic,0,Blue);
OrderSend(Symbol(),OP_BUYLIMIT,Lots*( 4),Ask-(StopLoss*Point)*3,slipage,Ask-(StopLoss*Point)* 4,Ask-(TakeProfit*Point)*2,"thank",magic,0,Blue);
OrderSend(Symbol(),OP_BUYLIMIT,Lots*( 5),Ask-(StopLoss*Point)*4,slipage,Ask-(StopLoss*Point)* 5,Ask-(TakeProfit*Point)*3,"thank",magic,0,Blue);
OrderSend(Symbol(),OP_BUYLIMIT,Lots*( 6),Ask-(StopLoss*Point)*5,slipage,Ask-(StopLoss*Point)* 6,Ask-(TakeProfit*Point)*4,"thank",magic,0,Blue);
OrderSend(Symbol(),OP_BUYLIMIT,Lots*( 7),Ask-(StopLoss*Point)*6,slipage,Ask-(StopLoss*Point)* 7,Ask-(TakeProfit*Point)*5,"thank",magic,0,Blue);
OrderSend(Symbol(),OP_BUYLIMIT,Lots*( 8),Ask-(StopLoss*Point)*7,slipage,Ask-(StopLoss*Point)* 8,Ask-(TakeProfit*Point)*6,"thank",magic,0,Blue);
OrderSend(Symbol(),OP_BUYLIMIT,Lots*( 9),Ask-(StopLoss*Point)*8,slipage,Ask-(StopLoss*Point)* 9,Ask-(TakeProfit*Point)*7,"thank",magic,0,Blue);
OrderSend(Symbol(),OP_BUYLIMIT,Lots*(10),Ask-(StopLoss*Point)*9,slipage,Ask-(StopLoss*Point)*10,Ask-(TakeProfit*Point)*8,"thank",magic,0,Blue);
//===//
}
//-------------------------------------------------------------//
if(OrdersTotal()<5&&LastOrderProfit())CloseOrders( );
//================================================== ===========//
}
void CloseOrders()
{
for (int cnt = 0 ; cnt < OrdersTotal() ; cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots(),NormalizeDoub le(Bid,Digits),30);
}
if(OrderType()==OP_SELL)
{
OrderClose(OrderTicket(),OrderLots(),NormalizeDoub le(Ask,Digits),30);
}
if(OrderType()>OP_SELL)OrderDelete(OrderTicket());
}
}
//================================================== =============//
bool LastOrderProfit()
{
for(int i=OrdersHistoryTotal();i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Ma gicNumber)
{
if(OrderProfit()>0)return(true);
else return(false);
}
}
return(true);
}
[PHP]