عرض مشاركة واحدة
قديم 04-02-2016, 05:26 PM   المشاركة رقم: 5
الكاتب
sal_moh85
عضو جديد

البيانات
تاريخ التسجيل: Dec 2012
رقم العضوية: 12726
العمر: 38
المشاركات: 115
بمعدل : 0.03 يوميا

الإتصالات
الحالة:
sal_moh85 غير متواجد حالياً
وسائل الإتصال:

كاتب الموضوع : sal_moh85 المنتدى : منتدى المؤشرات و الاكسبيرتات
افتراضي رد: الى استاذ اسلام ارجو المساعده


#property link "sal_moh85@hotmail.com"

#include <stdlib.mqh>
#include <WinUser32.mqh>

// exported variables
extern double Lots = 1;
extern int Stoploss = 30;
extern int Takeprofit = 50;
extern int TrailingStop14 = 12;
extern int NewTakeProfit14 = 30;
extern int TrailingGap14 = 7;


// local variables
double PipValue=1; // this variable is here to support 5-digit brokers
bool Terminated = false;
string LF = "\n"; // use this in custom or utility blocks where you need line feeds
int NDigits = 4; // used mostly for NormalizeDouble in Flex type blocks
int ObjCount = 0; // count of all objects created on the chart, allows creation of objects with unique names
int current = 0;



int init()
{
NDigits = Digits;

ObjectsDeleteAll(); // clear the chart


Comment(""); // clear the chart
}

// Expert start
int start()
{
if (Bars < 10)
{
Comment("Not enough bars");
return (0);
}
if (Terminated == true)
{
Comment("EA Terminated.");
return (0);
}

OnEveryTick26();

}

void OnEveryTick26()
{
if (true == false && true) PipValue = 10;
if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10;

TechnicalAnalysis30();
TechnicalAnalysis27();
TechnicalAnalysis22();
TechnicalAnalysis37();
TechnicalAnalysis39();
TrailingStop14();
TechnicalAnalysis35();

}

void TechnicalAnalysis30()
{
if (iRSI(NULL, NULL,14,PRICE_CLOSE,1) < 50)
{
TechnicalAnalysis29();

}
}

void TechnicalAnalysis29()
{
if (iADX(NULL, NULL,9,PRICE_CLOSE,MODE_MAIN,1) > 20)
{
TechnicalAnalysis2x38();

}
}

void TechnicalAnalysis2x38()
{
if ((iCustom(NULL, NULL, "mohamad",180,1,5,1,current+2) < 0) && (iCustom(NULL, NULL, "mohamad",180,1,5,1,current+1) > 0))
{
IfOrderDoesNotExist7();

}
}

void IfOrderDoesNotExist7()
{
bool exists = false;
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
exists = true;
}
}
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}

if (exists == false)
{
SellOrder33();

}
}

void SellOrder33()
{
double SL = Bid + Stoploss*PipValue*Point;
if (Stoploss == 0) SL = 0;
double TP = Bid - Takeprofit*PipValue*Point;
if (Takeprofit == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 4, 0, 0, "My Expert", 1, 0, Red);
else
ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 4, SL, TP, "My Expert", 1, 0, Red);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
if (ret == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}

}
else
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}
}

void TechnicalAnalysis27()
{
if (iRSI(NULL, NULL,14,PRICE_CLOSE,1) > 50)
{
TechnicalAnalysis28();

}
}

void TechnicalAnalysis28()
{
if (iADX(NULL, NULL,9,PRICE_CLOSE,MODE_MAIN,1) > 20)
{
TechnicalAnalysis2x34();

}
}

void TechnicalAnalysis2x34()
{
if ((iCustom(NULL, NULL, "mohamad",180,1,5,0,current+2) > 0) && (iCustom(NULL, NULL, "mohamad",180,1,5,0,current+1) > 0))
{
IfOrderDoesNotExist31();

}
}

void IfOrderDoesNotExist31()
{
bool exists = false;
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
exists = true;
}
}
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}

if (exists == false)
{
BuyOrder32();

}
}

void BuyOrder32()
{
double SL = Ask - Stoploss*PipValue*Point;
if (Stoploss == 0) SL = 0;
double TP = Ask + Takeprofit*PipValue*Point;
if (Takeprofit == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 4, 0, 0, "My Expert", 1, 0, Blue);
else
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 4, SL, TP, "My Expert", 1, 0, Blue);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}

}
else
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}
}

void TechnicalAnalysis22()
{
if (iADX(NULL, NULL,9,PRICE_CLOSE,MODE_MAIN,1) < 20)
{
CloseOrder8();

}
}

void CloseOrder8()
{
int orderstotal = OrdersTotal();
int orders = 0;
int ordticket[90][2];
for (int i = 0; i < orderstotal; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
{
continue;
}
ordticket[orders][0] = OrderOpenTime();
ordticket[orders][1] = OrderTicket();
orders++;
}
if (orders > 1)
{
ArrayResize(ordticket,orders);
ArraySort(ordticket);
}
for (i = 0; i < orders; i++)
{
if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
{
bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 4, Red);
if (ret == false)
Print("OrderClose() error - ", ErrorDescription(GetLastError()));
}
}

}

void TechnicalAnalysis37()
{
if (iCustom(NULL, NULL, "mohamad",180,1,5,0,current+1) > 0)
{
CloseOrder9();

}
}

void CloseOrder9()
{
int orderstotal = OrdersTotal();
int orders = 0;
int ordticket[90][2];
for (int i = 0; i < orderstotal; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
{
continue;
}
ordticket[orders][0] = OrderOpenTime();
ordticket[orders][1] = OrderTicket();
orders++;
}
if (orders > 1)
{
ArrayResize(ordticket,orders);
ArraySort(ordticket);
}
for (i = 0; i < orders; i++)
{
if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
{
bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 4, Red);
if (ret == false)
Print("OrderClose() error - ", ErrorDescription(GetLastError()));
}
}

}

void TechnicalAnalysis39()
{
if (iCustom(NULL, NULL, "mohamad",180,1,5,1,current+1) < 0)
{
CloseOrder36();

}
}

void CloseOrder36()
{
int orderstotal = OrdersTotal();
int orders = 0;
int ordticket[90][2];
for (int i = 0; i < orderstotal; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
{
continue;
}
ordticket[orders][0] = OrderOpenTime();
ordticket[orders][1] = OrderTicket();
orders++;
}
if (orders > 1)
{
ArrayResize(ordticket,orders);
ArraySort(ordticket);
}
for (i = 0; i < orders; i++)
{
if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
{
bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 4, Red);
if (ret == false)
Print("OrderClose() error - ", ErrorDescription(GetLastError()));
}
}

}

void TrailingStop14()
{
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
double takeprofit = OrderTakeProfit();

if (OrderType() == OP_BUY && Ask - OrderOpenPrice() > TrailingStop14*PipValue*Point)
{
if (OrderStopLoss() < Ask-(TrailingStop14+TrailingGap14)*PipValue*Point)
{
if (NewTakeProfit14 != 0) takeprofit = Ask+(NewTakeProfit14 + TrailingStop14)*PipValue*Point;
bool ret1 = OrderModify(OrderTicket(), OrderOpenPrice(), Ask-TrailingStop14*PipValue*Point, takeprofit, OrderExpiration(), White);
if (ret1 == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}
}
if (OrderType() == OP_SELL && OrderOpenPrice() - Bid > TrailingStop14*PipValue*Point)
{
if (OrderStopLoss() > Bid+(TrailingStop14+TrailingGap14)*PipValue*Point)
{
if (NewTakeProfit14 != 0) takeprofit = Bid-(NewTakeProfit14 + TrailingStop14)*PipValue*Point;
bool ret2 = OrderModify(OrderTicket(), OrderOpenPrice(), Bid+TrailingStop14*PipValue*Point, takeprofit, OrderExpiration(), White);
if (ret2 == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}
}
}
}
else
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

}

void TechnicalAnalysis35()
{
if (iADX(NULL, NULL,9,PRICE_CLOSE,MODE_MAIN,1) < 20)
{
CloseOrder25();

}
}

void CloseOrder25()
{
int orderstotal = OrdersTotal();
int orders = 0;
int ordticket[90][2];
for (int i = 0; i < orderstotal; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
{
continue;
}
ordticket[orders][0] = OrderOpenTime();
ordticket[orders][1] = OrderTicket();
orders++;
}
if (orders > 1)
{
ArrayResize(ordticket,orders);
ArraySort(ordticket);
}
for (i = 0; i < orders; i++)
{
if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
{
bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 4, Red);
if (ret == false)
Print("OrderClose() error - ", ErrorDescription(GetLastError()));
}
}

}



int deinit()
{
if (false) ObjectsDeleteAll();


}



عرض البوم صور sal_moh85  
رد مع اقتباس
  #5  
قديم 04-02-2016, 05:26 PM
sal_moh85 sal_moh85 غير متواجد حالياً
عضو جديد
افتراضي رد: الى استاذ اسلام ارجو المساعده


#property link "sal_moh85@hotmail.com"

#include <stdlib.mqh>
#include <WinUser32.mqh>

// exported variables
extern double Lots = 1;
extern int Stoploss = 30;
extern int Takeprofit = 50;
extern int TrailingStop14 = 12;
extern int NewTakeProfit14 = 30;
extern int TrailingGap14 = 7;


// local variables
double PipValue=1; // this variable is here to support 5-digit brokers
bool Terminated = false;
string LF = "\n"; // use this in custom or utility blocks where you need line feeds
int NDigits = 4; // used mostly for NormalizeDouble in Flex type blocks
int ObjCount = 0; // count of all objects created on the chart, allows creation of objects with unique names
int current = 0;



int init()
{
NDigits = Digits;

ObjectsDeleteAll(); // clear the chart


Comment(""); // clear the chart
}

// Expert start
int start()
{
if (Bars < 10)
{
Comment("Not enough bars");
return (0);
}
if (Terminated == true)
{
Comment("EA Terminated.");
return (0);
}

OnEveryTick26();

}

void OnEveryTick26()
{
if (true == false && true) PipValue = 10;
if (true && (NDigits == 3 || NDigits == 5)) PipValue = 10;

TechnicalAnalysis30();
TechnicalAnalysis27();
TechnicalAnalysis22();
TechnicalAnalysis37();
TechnicalAnalysis39();
TrailingStop14();
TechnicalAnalysis35();

}

void TechnicalAnalysis30()
{
if (iRSI(NULL, NULL,14,PRICE_CLOSE,1) < 50)
{
TechnicalAnalysis29();

}
}

void TechnicalAnalysis29()
{
if (iADX(NULL, NULL,9,PRICE_CLOSE,MODE_MAIN,1) > 20)
{
TechnicalAnalysis2x38();

}
}

void TechnicalAnalysis2x38()
{
if ((iCustom(NULL, NULL, "mohamad",180,1,5,1,current+2) < 0) && (iCustom(NULL, NULL, "mohamad",180,1,5,1,current+1) > 0))
{
IfOrderDoesNotExist7();

}
}

void IfOrderDoesNotExist7()
{
bool exists = false;
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
exists = true;
}
}
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}

if (exists == false)
{
SellOrder33();

}
}

void SellOrder33()
{
double SL = Bid + Stoploss*PipValue*Point;
if (Stoploss == 0) SL = 0;
double TP = Bid - Takeprofit*PipValue*Point;
if (Takeprofit == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 4, 0, 0, "My Expert", 1, 0, Red);
else
ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 4, SL, TP, "My Expert", 1, 0, Red);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
if (ret == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}

}
else
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}
}

void TechnicalAnalysis27()
{
if (iRSI(NULL, NULL,14,PRICE_CLOSE,1) > 50)
{
TechnicalAnalysis28();

}
}

void TechnicalAnalysis28()
{
if (iADX(NULL, NULL,9,PRICE_CLOSE,MODE_MAIN,1) > 20)
{
TechnicalAnalysis2x34();

}
}

void TechnicalAnalysis2x34()
{
if ((iCustom(NULL, NULL, "mohamad",180,1,5,0,current+2) > 0) && (iCustom(NULL, NULL, "mohamad",180,1,5,0,current+1) > 0))
{
IfOrderDoesNotExist31();

}
}

void IfOrderDoesNotExist31()
{
bool exists = false;
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
exists = true;
}
}
else
{
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}

if (exists == false)
{
BuyOrder32();

}
}

void BuyOrder32()
{
double SL = Ask - Stoploss*PipValue*Point;
if (Stoploss == 0) SL = 0;
double TP = Ask + Takeprofit*PipValue*Point;
if (Takeprofit == 0) TP = 0;
int ticket = -1;
if (true)
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 4, 0, 0, "My Expert", 1, 0, Blue);
else
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 4, SL, TP, "My Expert", 1, 0, Blue);
if (ticket > -1)
{
if (true)
{
OrderSelect(ticket, SELECT_BY_TICKET);
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}

}
else
{
Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}
}

void TechnicalAnalysis22()
{
if (iADX(NULL, NULL,9,PRICE_CLOSE,MODE_MAIN,1) < 20)
{
CloseOrder8();

}
}

void CloseOrder8()
{
int orderstotal = OrdersTotal();
int orders = 0;
int ordticket[90][2];
for (int i = 0; i < orderstotal; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
{
continue;
}
ordticket[orders][0] = OrderOpenTime();
ordticket[orders][1] = OrderTicket();
orders++;
}
if (orders > 1)
{
ArrayResize(ordticket,orders);
ArraySort(ordticket);
}
for (i = 0; i < orders; i++)
{
if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
{
bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 4, Red);
if (ret == false)
Print("OrderClose() error - ", ErrorDescription(GetLastError()));
}
}

}

void TechnicalAnalysis37()
{
if (iCustom(NULL, NULL, "mohamad",180,1,5,0,current+1) > 0)
{
CloseOrder9();

}
}

void CloseOrder9()
{
int orderstotal = OrdersTotal();
int orders = 0;
int ordticket[90][2];
for (int i = 0; i < orderstotal; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
{
continue;
}
ordticket[orders][0] = OrderOpenTime();
ordticket[orders][1] = OrderTicket();
orders++;
}
if (orders > 1)
{
ArrayResize(ordticket,orders);
ArraySort(ordticket);
}
for (i = 0; i < orders; i++)
{
if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
{
bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 4, Red);
if (ret == false)
Print("OrderClose() error - ", ErrorDescription(GetLastError()));
}
}

}

void TechnicalAnalysis39()
{
if (iCustom(NULL, NULL, "mohamad",180,1,5,1,current+1) < 0)
{
CloseOrder36();

}
}

void CloseOrder36()
{
int orderstotal = OrdersTotal();
int orders = 0;
int ordticket[90][2];
for (int i = 0; i < orderstotal; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
{
continue;
}
ordticket[orders][0] = OrderOpenTime();
ordticket[orders][1] = OrderTicket();
orders++;
}
if (orders > 1)
{
ArrayResize(ordticket,orders);
ArraySort(ordticket);
}
for (i = 0; i < orders; i++)
{
if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
{
bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 4, Red);
if (ret == false)
Print("OrderClose() error - ", ErrorDescription(GetLastError()));
}
}

}

void TrailingStop14()
{
for (int i=OrdersTotal()-1; i >= 0; i--)
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
{
double takeprofit = OrderTakeProfit();

if (OrderType() == OP_BUY && Ask - OrderOpenPrice() > TrailingStop14*PipValue*Point)
{
if (OrderStopLoss() < Ask-(TrailingStop14+TrailingGap14)*PipValue*Point)
{
if (NewTakeProfit14 != 0) takeprofit = Ask+(NewTakeProfit14 + TrailingStop14)*PipValue*Point;
bool ret1 = OrderModify(OrderTicket(), OrderOpenPrice(), Ask-TrailingStop14*PipValue*Point, takeprofit, OrderExpiration(), White);
if (ret1 == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}
}
if (OrderType() == OP_SELL && OrderOpenPrice() - Bid > TrailingStop14*PipValue*Point)
{
if (OrderStopLoss() > Bid+(TrailingStop14+TrailingGap14)*PipValue*Point)
{
if (NewTakeProfit14 != 0) takeprofit = Bid-(NewTakeProfit14 + TrailingStop14)*PipValue*Point;
bool ret2 = OrderModify(OrderTicket(), OrderOpenPrice(), Bid+TrailingStop14*PipValue*Point, takeprofit, OrderExpiration(), White);
if (ret2 == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}
}
}
}
else
Print("OrderSelect() error - ", ErrorDescription(GetLastError()));

}

void TechnicalAnalysis35()
{
if (iADX(NULL, NULL,9,PRICE_CLOSE,MODE_MAIN,1) < 20)
{
CloseOrder25();

}
}

void CloseOrder25()
{
int orderstotal = OrdersTotal();
int orders = 0;
int ordticket[90][2];
for (int i = 0; i < orderstotal; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
{
continue;
}
ordticket[orders][0] = OrderOpenTime();
ordticket[orders][1] = OrderTicket();
orders++;
}
if (orders > 1)
{
ArrayResize(ordticket,orders);
ArraySort(ordticket);
}
for (i = 0; i < orders; i++)
{
if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
{
bool ret = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 4, Red);
if (ret == false)
Print("OrderClose() error - ", ErrorDescription(GetLastError()));
}
}

}



int deinit()
{
if (false) ObjectsDeleteAll();


}





رد مع اقتباس