هذا هو الكود
//+------------------------------------------------------------------+
//| TradeReboot.mq4 |
//| Copyright 2023, MetaQuotes Software Corp. |
//|
https://www.metaquotes.net |
//+------------------------------------------------------------------+
#property strict
// إعدادات الدخول
input double lotSize = 0.01;
input double takeProfit = 0; // هدف الأرباح (0 = غير مفعّل)
input double stopLoss = 0; // وقف الخسارة (0 = غير مفعّل)
// إعدادات المؤشرات
input int zigsDepth1 = 12;
input int zigsDepth2 = 5;
input int sarStep = 0.02;
input int sarMaximum = 0.2;
input int rsiPeriod = 14;
input int rsiLevel1 = 20;
input int rsiLevel2 = 30;
input int rsiLevel3 = 80;
input int rsiLevel4 = 90;
//+------------------------------------------------------------------+
//| المبادئ التوجيهية للمستشار الخبير |
//+------------------------------------------------------------------+
void OnTick()
{
if (ConditionsForBuy())
{
Buy();
}
else if (ConditionsForSell())
{
Sell();
}
}
//+------------------------------------------------------------------+
//| الشروط للشراء |
//+------------------------------------------------------------------+
bool ConditionsForBuy()
{
double currentZigzag1 = iCustom(_Symbol, 0, "ZigZag", zigsDepth1, 0, 3, 0, 0);
double previousZigzag1 = iCustom(_Symbol, 0, "ZigZag", zigsDepth1, 0, 3, 1, 0);
double currentZigzag2 = iCustom(_Symbol, 0, "ZigZag", zigsDepth2, 0, 3, 0, 0);
double previousZigzag2 = iCustom(_Symbol, 0, "ZigZag", zigsDepth2, 0, 3, 1, 0);
double sar = iCustom(_Symbol, 0, "SAR", sarStep, sarMaximum, 0, 0);
double rsi = iRSI(_Symbol, 0, rsiPeriod, PRICE_CLOSE, 0);
bool zigzagCondition = currentZigzag1 > previousZigzag1 && currentZigzag2 == High[1];
bool sarCondition = sar < High[1] && sar > Low[1];
bool rsiCondition = iRSI(_Symbol, 0, rsiPeriod, PRICE_CLOSE, 1) > rsiLevel1 && iRSI(_Symbol, 0, rsiPeriod, PRICE_CLOSE, 1) < rsiLevel2;
return zigzagCondition && sarCondition && rsiCondition;
}
//+------------------------------------------------------------------+
//| الشروط للبيع |
//+------------------------------------------------------------------+
bool ConditionsForSell()
{
double currentZigzag1 = iCustom(_Symbol, 0, "ZigZag", zigsDepth