![MQL5 - Langage des stratégies de trading intégré au terminal client MetaTrader 5](https://c.mql5.com/i/registerlandings/logo-2.png)
Vous manquez des opportunités de trading :
- Applications de trading gratuites
- Plus de 8 000 signaux à copier
- Actualités économiques pour explorer les marchés financiers
Inscription
Se connecter
Vous acceptez la politique du site Web et les conditions d'utilisation
Si vous n'avez pas de compte, veuillez vous inscrire
Vladimir, j'ai tout compris, j'ai réussi à le faire fonctionner. Où puis-je échanger des ordres de vente avec des ordres d'achat ici ?
Chaque module de signaux a deux fonctions, qui sont utilisées pour émettre des signaux d'achat ou de vente. Il s'agit de "LongCondition" et "ShortCondition".
Chaque module de signaux a deux fonctions, qui sont utilisées pour émettre des signaux d'achat ou de vente. Il s'agit de "LongCondition" et "ShortCondition".
Je comprends que dans votre EA ce sont :
{
int result=0;
int idx=StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
if(m_reverse)
if(DiffCloseMA(idx)>0.0)
{
//--- the close price is above the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
}
if(!m_reverse)
if(DiffCloseMA(idx)<0.0)
{
//--- the close price is below the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
}
//--- return the result
return(result);
}
//+------------------------------------------------------------------+
//| "Voting" that price will fall. |
//+------------------------------------------------------------------+
int CSignalMA::ShortCondition(void)
{
int result=0;
int idx =StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
if(m_reverse)
if(DiffCloseMA(idx)<0.0)
{
//--- the close price is below the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
}
if(!m_reverse)
if(DiffCloseMA(idx)>0.0)
{
//--- the close price is above the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
}
//--- return the result
return(result);
}
//+------------------------------------------------------------------+
et où se situe la ligne qui est responsable de l'action ? Et comment puis-je modifier cette propriété ?
Je comprends que dans votre EA c'est :
{
int result=0;
int idx=StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
if(m_reverse)
if(DiffCloseMA(idx)>0.0)
{
//--- the close price is above the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
}
if(!m_reverse)
if(DiffCloseMA(idx)<0.0)
{
//--- the close price is below the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
}
//--- return the result
return(result);
}
//+------------------------------------------------------------------+
//| "Voting" that price will fall. |
//+------------------------------------------------------------------+
int CSignalMA::ShortCondition(void)
{
int result=0;
int idx =StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
if(m_reverse)
if(DiffCloseMA(idx)<0.0)
{
//--- the close price is below the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
}
if(!m_reverse)
if(DiffCloseMA(idx)>0.0)
{
//--- the close price is above the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
}
//--- return the result
return(result);
}
//+------------------------------------------------------------------+
et où se situe la ligne qui est responsable de l'action ? Et comment puis-je modifier cette propriété ?
Veuillez insérer le code correctement :Insérer le code correctement dans le forum
Vous avez cité le code NON PAS DANS LE CODE, mais dans le MODULE SIGNAUX.
Vous n'avez pas besoin de modifier quoi que ce soit dans mon module pour changer la direction du signal, car il a un paramètre "Reverse" - selon la valeur qu'il a (vrai ou faux) les signaux peuvent être inversés directement.
En utilisant l'exemple de "LongCondition" :
si l'inverse ("m_reverse") est vrai et que le prix de clôture moins la valeur de l'indicateur est supérieur à zéro - alors nous donnons le signal "Long" (Achat, achat)
{
int result=0;
int idx=StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
if(m_reverse)
if(DiffCloseMA(idx)>0.0)
{
//--- the close price is above the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
}
if(!m_reverse)
if(DiffCloseMA(idx)<0.0)
{
//--- the close price is below the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
}
//--- return the result
return(result);
}
Veuillez insérer le code correctement :Insérer le code correctement dans le forum
Vous n'avez PAS collé le code du CONSEILLER, mais celui du MODULE SIGNAL.
Vous n'avez pas besoin de modifier quoi que ce soit pour changer la direction du signal dans mon module, car il dispose du paramètre "Reverse" - selon la valeur qu'il a (true ou false), les signaux peuvent être inversés directement.
En utilisant l'exemple de "LongCondition" :
si "m_reverse" est vrai et que le prix de clôture moins la valeur de l'indicateur est supérieur à zéro - alors le signal "Long" (Achat, achat) est donné.
{
int result=0;
int idx=StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
if(m_reverse)
if(DiffCloseMA(idx)>0.0)
{
//--- the close price is above the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
}
if(!m_reverse)
if(DiffCloseMA(idx)<0.0)
{
//--- the close price is below the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
}
//--- return the result
return(result);
}
Vladimir, il y a un nouveau problème. Votre conseiller expert a été compilé, mais lorsque j'essaie de le faire glisser sur le graphique et d'accepter les paramètres. Je vois une icône dans le coin droit montrant que le conseiller expert a été lancé. Puis il disparaît aussitôt. Quelle peut en être la raison ? Ce revers est bon. Comment peut-on l'appliquer dans d'autres EE ?
Vladimir, il y a un nouveau problème. Votre EA a été compilé, mais lorsque j'essaie de le faire glisser sur un graphique et d'accepter les paramètres. Je vois une icône dans le coin droit indiquant que l'EA est en cours d'exécution pendant un certain temps. Puis il disparaît aussitôt. Quelle peut en être la raison ? Ce revers est bon. Comment peut-on l'appliquer à d'autres EE ?
Recherchez les messages d'erreur dans la fenêtre "Toolbox" du terminal dans les onglets "Experts" et "Journal"...
Je comprends que c'est la section qui est responsable de l'ouverture d'une position si "le prix va augmenter" dans le fichier SignalMA.mqh ?
//| "Voting" that price will grow. |
//+------------------------------------------------------------------+
int CSignalMA::LongCondition(void)
{
int result=0;
int idx =StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
if(DiffCloseMA(idx)<0.0)
{
//--- the close price is below the indicator
if(IS_PATTERN_USAGE(1) && DiffOpenMA(idx)>0.0 && DiffMA(idx)>0.0)
{
//--- the open price is above the indicator (i.e. there was an intersection), but the indicator is directed upwards
result=m_pattern_1;
//--- consider that this is an unformed "piercing" and suggest to enter the market at the current price
m_base_price=0.0;
}
}
else
{
//--- the close price is above the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
//--- if the indicator is directed upwards
if(DiffMA(idx)>0.0)
{
if(DiffOpenMA(idx)<0.0)
{
//--- if the model 2 is used
if(IS_PATTERN_USAGE(2))
{
//--- the open price is below the indicator (i.e. there was an intersection)
result=m_pattern_2;
//--- suggest to enter the market at the "roll back"
m_base_price=m_symbol.NormalizePrice(MA(idx));
}
}
else
{
//--- if the model 3 is used and the open price is above the indicator
if(IS_PATTERN_USAGE(3) && DiffLowMA(idx)<0.0)
{
//--- the low price is below the indicator
result=m_pattern_3;
//--- consider that this is a formed "piercing" and suggest to enter the market at the current price
m_base_price=0.0;
}
}
}
}
//--- return the result
return(result);
}
Et si vous remplacez ce code par celui de votre module, cela fonctionnera-t-il correctement ? Le fait est que le contenu est légèrement différent du vôtre. Il y a plus de code ici... hmm.
Je comprends que c'est la section qui est responsable de l'ouverture d'une position si "le prix va augmenter" dans le fichier SignalMA.mqh ?
//| "Voting" that price will grow. |
//+------------------------------------------------------------------+
int CSignalMA::LongCondition(void)
{
int result=0;
int idx =StartIndex();
//--- analyze positional relationship of the close price and the indicator at the first analyzed bar
if(DiffCloseMA(idx)<0.0)
{
//--- the close price is below the indicator
if(IS_PATTERN_USAGE(1) && DiffOpenMA(idx)>0.0 && DiffMA(idx)>0.0)
{
//--- the open price is above the indicator (i.e. there was an intersection), but the indicator is directed upwards
result=m_pattern_1;
//--- consider that this is an unformed "piercing" and suggest to enter the market at the current price
m_base_price=0.0;
}
}
else
{
//--- the close price is above the indicator (the indicator has no objections to buying)
if(IS_PATTERN_USAGE(0))
result=m_pattern_0;
//--- if the indicator is directed upwards
if(DiffMA(idx)>0.0)
{
if(DiffOpenMA(idx)<0.0)
{
//--- if the model 2 is used
if(IS_PATTERN_USAGE(2))
{
//--- the open price is below the indicator (i.e. there was an intersection)
result=m_pattern_2;
//--- suggest to enter the market at the "roll back"
m_base_price=m_symbol.NormalizePrice(MA(idx));
}
}
else
{
//--- if the model 3 is used and the open price is above the indicator
if(IS_PATTERN_USAGE(3) && DiffLowMA(idx)<0.0)
{
//--- the low price is below the indicator
result=m_pattern_3;
//--- consider that this is a formed "piercing" and suggest to enter the market at the current price
m_base_price=0.0;
}
}
}
}
//--- return the result
return(result);
}
Et si vous remplacez ce code par celui de votre module, cela fonctionnera-t-il correctement ? Le fait est que le contenu est légèrement différent du vôtre. Il y a plus de code ici... hmm.
Si vous prenez mon code et le collez ici, ça ne marchera pas.
Si vous prenez mon code et le collez ici, ça ne marchera pas.
Si vous prenez mon code et le collez ici, il ne fonctionnera pas.
Vladimir, où devons-nous coller l'inverse pour que cela fonctionne ?
En clair, vous devrez créer une copie du fichier, et changer le nom de cet inlude.
Si vous voulez changer les signaux pour les inverser dans le module de signal standard :
//+------------------------------------------------------------------+
//| Description of the class |
//| Title=*** |
//| Type=SignalAdvanced |
//| Name=Moving Average |
Si vous voulez changer les signaux pour les inverser dans le module de signal standard :
//+------------------------------------------------------------------+
//| Description of the class |
//| Title=*** |
//| Type=SignalAdvanced |
//| Name=Moving Average |
Vladimir, merci, vous avez été très utile. Il reste maintenant à savoir comment réaliser les ordres Take Profit et Stop Loss que l'EA place. Comment faire pour les limiter ?