peux tu corriger ce script pour qu'il n'y ait plus d'erreur: //--- input parameters
extern string EASettings = "---------------------------------------------"; //-------- --------
extern int InpMagicNumber = 124656; //Magic Number
extern string TradingSettings = "---------------------------------------------"; //-------- --------
extern double Inpuser_lot = 0.01; //Lots
extern double InpSL_Pips = 3.5; //Stoploss (in Pips)
extern double InpMax_spread = 0.5; //Maximum allowed spread (in Pips) (0 = floating)
extern double InpDynamic_TP = 1.5; //Dynamic Take Profit factor
extern string MoneySettings = "---------------------------------------------"; //-------- --------
extern bool isVolume_Percent = true; //Allow Volume Percent
extern double InpRisk = 3; //Risk Percentage of Balance (%)
extern string TimeSettings = "---------------------------------------------"; //-------- --------
extern bool InpTimeFilter = true; //Trading Time Filter
extern int InpStartHour = 2; //Start Hour
extern int InpStartMinute = 30; //Start Minute
extern int InpEndHour = 21; //End Hour
extern int InpEndMinute = 0; //End Minute
//--- Variables
int Pips2Points; // slippage 3 pips 3=points 30=points
double Pips2Double; // Stoploss 15 pips 0.015 0.0150
int InpMax_slippage = 3; // Maximum slippage allow_Pips.
bool isOrder = false; // just open 1 order
int slippage;
string strComment = "";
int OnInit()
{
// 3 or 5 digits detection
// Pip and point
if (Digits % 2 == 1)
{
Pips2Double = Point * 10;
Pips2Points = 10;
slippage = 10 * InpMax_slippage;
}
else
{
Pips2Double = Point;
Pips2Points = 1;
slippage = InpMax_slippage;
}
return (INIT_SUCCEEDED);
}
void OnTick()
{
if (IsTradeAllowed() == false)
{
Comment("AK-47 EA\nTrade not allowed.");
return;
}
MqlDateTime structTime;
TimeCurrent(structTime);
structTime.sec = 0;
// Set starting time
structTime.hour = InpStartHour;
structTime.min = InpStartMinute;
datetime timeStart = TimeToStruct(structTime);
// Set Ending time
structTime.hour = InpEndHour;
structTime.min = InpEndMinute;
datetime timeEnd = TimeToStruct(structTime);
double acSpread = MarketInfo(Symbol(), MODE_SPREAD);
int StopLevel = MarketInfo(Symbol(), MODE_STOPLEVEL);
strComment = "\nAK-47 Scalper EA - v." + DoubleToString(Version(), 2);
strComment += "\nGMT time = " + TimeToString(TimeGMT(), TIME_DATE | TIME_SECONDS);
strComment += "\nTrading time = [" + TimeToString(timeStart, TIME_MINUTES) + " --> " + TimeToString(timeEnd, TIME_MINUTES) + "]";
strComment += "\nCurrent Spread = " + DoubleToString(acSpread, Digits) + " Points";
strComment += "\nCurrent stoplevel = " + IntegerToString(StopLevel) + " Points";
Comment(strComment);
UpdateOrders();
TrailingStop();
if (InpTimeFilter)
{
if (TimeCurrent() >= timeStart && TimeCurrent() < timeEnd)
{
if (!isOrder)
OpenOrder();
}
}
else
{
if (!isOrder)
OpenOrder();
}
}
void OpenOrder()
{
double TP = 0;
double SL = 0;
string comment = "AK-47 Scalper EA";
double lot1 = CalculateVolume();
double OpenPrice = NormalizeDouble(Bid - (StopLevel * Point) - (InpSL_Pips / 2) * Pips2Double, Digits);
SL = NormalizeDouble(Ask + StopLevel * Point + InpSL_Pips / 2 * Pips2Double, Digits);
if (CheckSpreadAllow())
{
int ticket = OrderSend(Symbol(), OP_SELLSTOP, lot1, OpenPrice, slippage, SL, TP, comment, InpMagicNumber, 0, clrRed);
if (ticket > 0)
{
Print("SellStop order opened. Ticket =", ticket);
}
else
{
Print("Error opening SellStop order. Error code =", GetLastError());
}
}
}
double CalculateVolume()
{
double LotSize = 0;
if (isVolume_Percent == false)
{
LotSize = Inpuser_lot;
}
else
{
double maxLot = MarketInfo(Symbol(), MODE_MAXLOT);
double minLot = MarketInfo(Symbol(), MODE_MINLOT);
LotSize = (InpRisk * AccountFreeMargin()) / 100000;
double n = MathFloor(LotSize / Inpuser_lot);
LotSize = n * Inpuser_lot;
if (LotSize < Inpuser_lot)
LotSize = Inpuser_lot;
if (LotSize > maxLot)
LotSize = maxLot;
if (LotSize < minLot)
LotSize = minLot;
}
return LotSize;
}
bool CheckSpreadAllow()
{
double currentSpread = MarketInfo(Symbol(), MODE_SPREAD);
if (currentSpread <= InpMax_spread || InpMax_spread == 0)
return true;
else
return false;
}
void TrailingStop()
{
for (int i = OrdersTotal() - 1; i >= 0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderMagicNumber() == InpMagicNumber && OrderSymbol() == Symbol())
{
double SL_in_Pip = (OrderStopLoss() - Ask) / Pips2Double;
if (SL_in_Pip < InpSL_Pips / 2)
{
double newOP = NormalizeDouble(Bid - (StopLevel * Point) - (InpSL_Pips / 2) * Pips2Double, Digits);
double newSL = NormalizeDouble(Ask + (StopLevel * Point) + (InpSL_Pips / 2) * Pips2Double, Digits);
bool result = OrderModify(OrderTicket(), newOP, newSL, OrderTakeProfit(), 0, clrRed);
if (!result)
{
Print("Error modifying SellStop order. Error code =", GetLastError());
}
}
}
}
}
}