Bonjour à tous,
Je me permets ce message car j'ai un message d'erreur sur l'EA que j'ai codé quand j'essaie de l'importer sur mon graphique MT4, alors que je n'ai aucune erreurs ou messages d'avertissements après compilation.
Le message d'erreur : " is not expert and cannot be executed "
Vous trouverez le script ci-dessous :
Si quelqu'un à une idée ou une réponse, je suis preneur. Merci d'avance !
Je me permets ce message car j'ai un message d'erreur sur l'EA que j'ai codé quand j'essaie de l'importer sur mon graphique MT4, alors que je n'ai aucune erreurs ou messages d'avertissements après compilation.
Le message d'erreur : " is not expert and cannot be executed "
Vous trouverez le script ci-dessous :
Code
//+------------------------------------------------------------------+
//| ichimoku 22012023.mq4 |
//| Copyright 2023, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Red // Tenkan-sen
#property indicator_color2 Blue // Kijun-sen
#property indicator_color3 SandyBrown // Up Kumo
#property indicator_color4 Thistle // Down Kumo
#property indicator_color5 Lime // Chikou Span
#property indicator_color6 SandyBrown // Up Kumo bounding line
#property indicator_color7 Thistle // Down Kumo bounding line
//--- input parameters
input int InpTenkan=9; // Tenkan-sen
input int InpKijun=26; // Kijun-sen
input int InpSenkou=52; // Senkou Span B
//--- buffers
double ExtTenkanBuffer[];
double ExtKijunBuffer[];
double ExtSpanA_Buffer[];
double ExtSpanB_Buffer[];
double ExtChikouBuffer[];
double ExtSpanA2_Buffer[];
double ExtSpanB2_Buffer[];
//---
int ExtBegin;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
IndicatorDigits(Digits);
//---
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtTenkanBuffer);
SetIndexDrawBegin(0,InpTenkan-1);
SetIndexLabel(0,"Tenkan Sen");
//---
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtKijunBuffer);
SetIndexDrawBegin(1,InpKijun-1);
SetIndexLabel(1,"Kijun Sen");
//---
ExtBegin=InpKijun;
if(ExtBegin<InpTenkan)
ExtBegin=InpTenkan;
//---
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_DOT);
SetIndexBuffer(2,ExtSpanA_Buffer);
SetIndexDrawBegin(2,InpKijun+ExtBegin-1);
SetIndexShift(2,InpKijun);
SetIndexLabel(2,NULL);
SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(5,ExtSpanA2_Buffer);
SetIndexDrawBegin(5,InpKijun+ExtBegin-1);
SetIndexShift(5,InpKijun);
SetIndexLabel(5,"Senkou Span A");
//---
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_DOT);
SetIndexBuffer(3,ExtSpanB_Buffer);
SetIndexDrawBegin(3,InpKijun+InpSenkou-1);
SetIndexShift(3,InpKijun);
SetIndexLabel(3,NULL);
SetIndexStyle(6,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(6,ExtSpanB2_Buffer);
SetIndexDrawBegin(6,InpKijun+InpSenkou-1);
SetIndexShift(6,InpKijun);
SetIndexLabel(6,"Senkou Span B");
//---
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,ExtChikouBuffer);
SetIndexShift(4,-InpKijun);
SetIndexLabel(4,"Chikou Span");
//--- initialization done
}
//+------------------------------------------------------------------+
//| Ichimoku Kinko Hyo |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int i,k,pos;
double high_value,low_value;
//---
if(rates_total<=InpTenkan || rates_total<=InpKijun || rates_total<=InpSenkou)
return(0);
//--- counting from 0 to rates_total
ArraySetAsSeries(ExtTenkanBuffer,false);
ArraySetAsSeries(ExtKijunBuffer,false);
ArraySetAsSeries(ExtSpanA_Buffer,false);
ArraySetAsSeries(ExtSpanB_Buffer,false);
ArraySetAsSeries(ExtChikouBuffer,false);
ArraySetAsSeries(ExtSpanA2_Buffer,false);
ArraySetAsSeries(ExtSpanB2_Buffer,false);
ArraySetAsSeries(open,false);
ArraySetAsSeries(high,false);
ArraySetAsSeries(low,false);
ArraySetAsSeries(close,false);
//--- initial zero
if(prev_calculated<1)
{
for(i=0; i<InpTenkan; i++)
ExtTenkanBuffer[i]=0.0;
for(i=0; i<InpKijun; i++)
ExtKijunBuffer[i]=0.0;
for(i=0; i<ExtBegin; i++)
{
ExtSpanA_Buffer[i]=0.0;
ExtSpanA2_Buffer[i]=0.0;
}
for(i=0; i<InpSenkou; i++)
{
ExtSpanB_Buffer[i]=0.0;
ExtSpanB2_Buffer[i]=0.0;
}
}
//--- Tenkan Sen
pos=InpTenkan-1;
if(prev_calculated>InpTenkan)
pos=prev_calculated-1;
for(i=pos; i<rates_total; i++)
{
high_value=high[i];
low_value=low[i];
k=i+1-InpTenkan;
while(k<=i)
{
if(high_value<high[k])
high_value=high[k];
if(low_value>low[k])
low_value=low[k];
k++;
}
ExtTenkanBuffer[i]=(high_value+low_value)/2;
}
//--- Kijun Sen
pos=InpKijun-1;
if(prev_calculated>InpKijun)
pos=prev_calculated-1;
for(i=pos; i<rates_total; i++)
{
high_value=high[i];
low_value=low[i];
k=i+1-InpKijun;
while(k<=i)
{
if(high_value<high[k])
high_value=high[k];
if(low_value>low[k])
low_value=low[k];
k++;
}
ExtKijunBuffer[i]=(high_value+low_value)/2;
}
//--- Senkou Span A
pos=ExtBegin-1;
if(prev_calculated>ExtBegin)
pos=prev_calculated-1;
for(i=pos; i<rates_total; i++)
{
ExtSpanA_Buffer[i]=(ExtKijunBuffer[i]+ExtTenkanBuffer[i])/2;
ExtSpanA2_Buffer[i]=ExtSpanA_Buffer[i];
}
//--- Senkou Span B
pos=InpSenkou-1;
if(prev_calculated>InpSenkou)
pos=prev_calculated-1;
for(i=pos; i<rates_total; i++)
{
high_value=high[i];
low_value=low[i];
k=i+1-InpSenkou;
while(k<=i)
{
if(high_value<high[k])
high_value=high[k];
if(low_value>low[k])
low_value=low[k];
k++;
}
ExtSpanB_Buffer[i]=(high_value+low_value)/2;
ExtSpanB2_Buffer[i]=ExtSpanB_Buffer[i];
}
//--- Chikou Span
pos=0;
if(prev_calculated>1)
pos=prev_calculated-1;
for(i=pos; i<rates_total; i++)
ExtChikouBuffer[i]=close[i];
//---
return(rates_total);
}
//+------------------------------------------------------------------+
// Variables pour le stop loss, take profit, trailing stop, taille de lot et perte maximale journalière
double stop_loss = ExtSpanA_Buffer[0];
double take_profit = stop_loss + (stop_loss * 3); // 3 fois le stop loss
double trailing_stop = (stop_loss - Ask) / Point; // différence de pips entre le point d'ouverture et le stop loss
double lot_size = AccountBalance() * 0.005; // 0.5% du capital
double max_daily_loss = AccountBalance() * 0.025; // 2.5% du capital
// Fonction de trading
void CheckForOpen()
{
// Condition 1 : Tendance haussière
if (ExtTenkanBuffer[0] > ExtKijunBuffer[0] && ExtSpanA_Buffer[0] > ExtSpanB_Buffer[0])
{
// Condition 2 : Kumo haussier
if (Close[0] > ExtSpanA_Buffer[0] && Close[0] > ExtSpanB_Buffer[0])
{
// Condition 3 : Kijun casse le prix à la hausse
if (Close[0] > ExtKijunBuffer[0])
{
// Condition 4 : Clôture de la bougie se fait au-dessus du Kumo
if (Close[0] > ExtSpanA_Buffer[0] && Close[0] > ExtSpanB_Buffer[0])
{
// Entrée en position d'achat
int ticket=OrderSend(Symbol(),OP_BUY,lot_size,Ask,3,Ask-stop_loss*Point,Ask+take_profit*Point,"My order",16384,0,Green);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
}
else
Print("OrderSend placed successfully");
}
}
}
}
// Fonction de trading
// Condition 1 : Tendance baissière
if (ExtTenkanBuffer[0] < ExtKijunBuffer[0] && ExtSpanA_Buffer[0] < ExtSpanB_Buffer[0])
{
// Condition 2 : Kumo baissier
if (Close[0] < ExtSpanA_Buffer[0] && Close[0] < ExtSpanB_Buffer[0])
{
// Condition 3 : Kijun casse le prix à la baisse
if (Close[0] < ExtKijunBuffer[0])
{
// Condition 4 : Clôture de la bougie se fait en dessous du Kumo
if (Close[0] < ExtSpanA_Buffer[0] && Close[0] < ExtSpanB_Buffer[0])
{
// Entrée en position de vente
int ticket=OrderSend(Symbol(),OP_SELL,lot_size,Bid,3,Bid+stop_loss*Point,Bid-take_profit*Point,"My order",16384,0,Red);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
}
else
Print("OrderSend placed successfully");
}
}
}
}
}
// Vérifier si une position d'achat est ouverte
void CheckForClose()
{
if(OrderSelect(OrderTicket(), SELECT_BY_TICKET, MODE_TRADES))
{
if(OrderType() == OP_BUY)
{
// Condition 1 : Touché le take profit
if(OrderProfit() >= take_profit*Point)
{
int ticket=OrderClose(OrderTicket(), OrderLots(), Bid, 3, clrNONE);
}
// Condition 2 : Touché le stop loss
if(OrderProfit() <= -stop_loss*Point)
{
int ticket=OrderClose(OrderTicket(), OrderLots(), Bid, 3, clrNONE);
}
// Condition 3 : Cassure inverse du prix par la Kijun à la clôture de la bougie
if(Close[0] < ExtKijunBuffer[0])
{
int ticket=OrderClose(OrderTicket(), OrderLots(), Bid, 3, clrNONE);
if(ticket<0)
{
Print("OrderClose failed with error #",GetLastError());
}
else
Print("OrderClose placed successfully");
}
}
}
// Vérifier si une position de vente est ouverte
if(OrderSelect(OrderTicket(), SELECT_BY_TICKET, MODE_TRADES))
{
if(OrderType() == OP_SELL)
{
// Condition 1 : Touché le take profit
if(OrderProfit() >= take_profit*Point)
{
int ticket=OrderClose(OrderTicket(), OrderLots(), Ask, 3, clrNONE);
}
// Condition 2 : Touché le stop loss
if(OrderProfit() <= -stop_loss*Point)
{
int ticket=OrderClose(OrderTicket(), OrderLots(), Ask, 3, clrNONE);
}
// Condition 3 : Cassure inverse du prix par la Kijun à la clôture de la bougie
if(Close[0] > ExtKijunBuffer[0])
{
int ticket=OrderClose(OrderTicket(), OrderLots(), Ask, 3, clrNONE);
if(ticket<0)
{
Print("OrderClose failed with error #",GetLastError());
}
else
Print("OrderClose placed successfully");
}
}
}
}
Si quelqu'un à une idée ou une réponse, je suis preneur. Merci d'avance !
Modifié le 2023-01-23 15:07:25 par
AliX
: [Code] [/code]