Aide au codage - page 507

 
tristantsh:
Merci mntiwana et malden. mais pourquoi dois-je acheter à nouveau ? Pouvez-vous envoyer ces indicateurs dans des messages

Envoyez l'email original avec un lien que vous avez reçu lorsque vous avez acheté cet indicateur à support@forex-tsd.com et, si tout est correct, vous recevrez une version mise à jour.

 

Ok mlanden. mais l'indicateur avant nmc semble plus intéressant qu'après nmc . Est-ce que c'est juste mon sentiment ?

 
tristantsh:
Ok mlanden. mais l'indicateur avant nmc semble plus intéressant qu'après nmc . Est-ce que c'est juste mon sentiment ?

Les résultats de la version "nmc" ne sont pas du tout modifiés par rapport à la version "pre-nmc". "nmc" signifie "new metatrader compatible".

tous les meilleurs

 

Pourquoi ?

Mladen,

S'il vous plaît pouvez-vous me donner la raison pour laquelle cette ea ne fonctionne pas.

//----------------------- PARAMÈTRE DE L'EA

chaîne externe

Expert_Name = "---------- Pending Order EA v1",

Expert_Name2 = "---------- For current price set EntryLevel = 0" ;

extern double

EntryLevel = 1.8600,

Distance = 100,

StopLoss = 50,

TakeProfit = 50,

TrailingStop = 50 ;

chaîne externe

Order_Setting = "---------- Order Setting" ;

extern int

NumberOfTries = 5,

Slippage = 5,

MagicNumber = 1234 ;

chaîne externe

MM_Parameters = "---------- Money Management" ;

extern double

Lots =0.01 ;

extern bool

MM = false, //Utilise Money Management ou non

AccountIsMicro = true ; //Utiliser le micro-compte ou non

extern int

Risk = 0 ; //10 %.

extern string

Testing_Parameters= "---------- Back Test Parameter" ;

extern bool

Show_Settings = true ;

//----------------------- VARIABLE GLOBALE

static int

TimeFrame = 0 ;

chaîne de caractères

TicketComment = "PendingOrderEA v2",

LastTrade ;

bool

TradeAllow = true,

EntryAllow = true ;

//+------------------------------------------------------------------+

//| fonction d'initialisation de l'expert

//+------------------------------------------------------------------+

int init()

{

//----------------------- GÉNÉRER LE NUMÉRO MAGIQUE ET LE COMMENTAIRE DU TICKET

//----------------------- SOURCE : PENGIE

MagicNumber = subGenerateMagicNumber(MagicNumber, Symbol(), Period()) ;

TicketComment = StringConcatenate(TicketComment, "-", Symbol(), "-", Period()) ;

//----------------------- MONTRER LE PARAMÈTRE EA SUR LE GRAPHIQUE

//----------------------- SOURCE : CODERSGURU

if(Show_Settings) subPrintDetails() ;

else Comment("") ;

return(0) ;

}

//+------------------------------------------------------------------+

//| fonction de désinitialisation experte |

//+------------------------------------------------------------------+

int deinit()

{

//----------------------- EMPÊCHER LE RECOMPTAGE LORSQUE L'UTILISATEUR CHANGE DE PÉRIODE DE TEMPS

//----------------------- SOURCE : CODERSGURU

TimeFrame=Period() ;

retour(0) ;

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int start()

{

double

// BuyLevel,

SellLevel ;

int

cnt,

ticket,

total ;

//----------------------- fixer le prix d'achat et de vente

if(EntryLevel==0) EntryLevel = Bid ;

// Niveau d'achat = Niveau d'entrée + Distance*Point ;

Niveau de vente = Niveau d'entrée - Distance*Point ;

// if((BuyLevel-Ask)<10*Point || (Bid-SellLevel)<10*Point)

// {

// Comment("Prix d'entrée ou distance invalide") ;

// return(0) ;

// }

//----------------------- AJUSTER LES LOTS SI VOUS UTILISEZ LE MONEY MANAGEMENT

if(MM) Lots = subLotSize() ;

//----------------------- ENTRY

//----------------------- TOTAL DE L'ORDRE BASÉ SUR LE NUMÉRO MAGIQUE ET LE SYMBOLE

total = subTotalTrade() ;

//----------------------- N'ÉTABLIT L'ORDRE QU'UNE SEULE FOIS

if(TradeAllow)

{

//----------------------- IF NO TRADE

if(total<1 && EntryAllow)

{

ticket = OrderSend(Symbol(),OP_SELLSTOP,Lots,SellLevel,Slippage,SellLevel+StopLoss*Point,SellLevel-TakeProfit*Point,TicketComment,MagicNumber,0,Red) ;

// ticket = OrderSend(Symbol(),OP_BUYSTOP,Lots,BuyLevel,Slippage,BuyLevel-StopLoss*Point,BuyLevel+TakeProfit*Point,TicketComment,MagicNumber,0,Green) ;

EntryAllow = false ;

retour(0) ;

}

si(total==1)

{

subDeleteOrder() ;

TradeAllow = false ;

}

}

//----------------------- SECTION DE TRAILING STOP

si(TrailingStop>0 && subTotalTrade()>0)

{

total = OrdersTotal() ;

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) ;

si(OrderType()<=OP_SELL &&

OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber)

{

subTrailingStop(OrderType()) ;

retour(0) ;

}

}

}

return(0) ;

}

//----------------------- END PROGRAM

//+------------------------------------------------------------------+

//| DÉFINITIONS DES FONCTIONS

//+------------------------------------------------------------------+

//----------------------- FONCTION DE GESTION DE L'ARGENT

//----------------------- SOURCE : CODERSGURU

double subLotSize()

{

double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100 ;

if(AccountIsMicro==false) //compte normal

{

if(lotMM < 0.1) lotMM = Lots ;

if((lotMM > 0.5) && (lotMM < 1)) lotMM = 0.5 ;

if(lotMM > 1.0) lotMM = MathCeil(lotMM) ;

si(lotMM > 100) lotMM = 100 ;

}

else //micro compte

{

if(lotMM < 0.01) lotMM = Lots ;

if(lotMM > 1.0) lotMM = MathCeil(lotMM) ;

if(lotMM > 100) lotMM = 100 ;

}

return (lotMM) ;

}

//----------------------- NOMBRE D'ORDRE BASÉ SUR LE SYMBOLE ET LA FONCTION MAGICNUMBER

int subTotalTrade()

{

int

cnt,

total = 0 ;

for(cnt=0;cnt<OrdersTotal();cnt++)

{

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES) ;

si(OrderType()<=OP_SELL &&

OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber) total++ ;

}

return(total) ;

}

//----------------------- FONCTION DE SUPPRESSION DE LA COMMANDE

void subDeleteOrder()

{

int

cnt,

total = 0 ;

total = OrdersTotal() ;

for(cnt=total-1;cnt>=0;cnt--)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) ;

if(OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber)

{

switch(OrderType())

{

// cas OP_BUYLIMIT :

// cas OP_BUYSTOP :

cas OP_SELLLIMIT :

cas OP_SELLSTOP :

OrderDelete(OrderTicket()) ;

}

}

}

}

//----------------------- FONCTION DE TRAILING STOP

//----------------------- SOURCE : CODERSGURU

//----------------------- MODIFIÉ : FIREDAVE

void subTrailingStop(int Type)

{

if(Type==OP_BUY) // la position d'achat est ouverte

{

if(Bid-OrderOpenPrice()>Point*TrailingStop &&

OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green) ;

retour(0) ;

}

}

if(Type==OP_SELL) // une position de vente est ouverte

{

if(OrderOpenPrice()-Ask>Point*TrailingStop)

{

if(OrderStopLoss()>Ask+Point*TrailingStop || OrderStopLoss()==0)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red) ;

retour(0) ;

}

}

}

}

//----------------------- GÉNÉRER LE NOMBRE MAGIQUE EN FONCTION DU SYMBOLE ET DE LA FONCTION DE LA TRAME TEMPORELLE.

//----------------------- SOURCE : PENGIE

//----------------------- MODIFIÉ : FIREDAVE

int subGenerateMagicNumber(int MagicNumber, string symbol, int timeFrame)

{

int isymbol = 0 ;

si (symbol == "EURUSD") isymbol = 1 ;

else if (symbol == "GBPUSD") isymbol = 2 ;

sinon si (symbole == "USDJPY") isymbol = 3 ;

autre si (symbole == "AUDCAD") isymbol = 4 ;

autre si (symbole == "AUDUSD") isymbol = 5 ;

autre si (symbol == "USDCAD") isymbol = 6 ;

sinon si (symbole == "EURGBP") isymbol = 7 ;

sinon si (symbole == "EURJPY") isymbol = 8 ;

sinon si (symbole == "EURCHF") isymbol = 9 ;

sinon si (symbole == "EURAUD") isymbol = 10 ;

sinon si (symbole == "EURCAD") isymbol = 11 ;

autre si (symbol == "GBPUSD") isymbol = 12 ;

autre si (symbol == "GBPJPY") isymbol = 13 ;

autre si (symbol == "GBPCHF") isymbol = 14 ;

autre si (symbol == "GBPAUD") isymbol = 15 ;

autre si (symbol == "GBPCAD") isymbol = 16 ;

sinon isymbol = 17 ;

if(isymbol<10) MagicNumber = MagicNumber * 10 ;

return (StrToInteger(StringConcatenate(MagicNumber, isymbol, timeFrame)) ;)

}

//----------------------- IMPRIMER LA FONCTION DE COMMENTAIRE

//----------------------- SOURCE : CODERSGURU

void subPrintDetails()

{

string sComment = "" ;

string sp = "----------------------------------------\n" ;

string NL = "\n" ;

sComment = sp ;

sComment = sComment + "TakeProfit=" + DoubleToStr(TakeProfit,0) + " | " ;

sComment = sComment + "TrailingStop=" + DoubleToStr(TrailingStop,0) + " | " ;

sComment = sComment + "StopLoss=" + DoubleToStr(StopLoss,0) + NL ;

sComment = sComment + sp ;

sComment = sComment + "Lots=" + DoubleToStr(Lots,2) + " | " ;

sComment = sComment + "MM=" + subBoolToStr(MM) + " | " ;

sComment = sComment + "Risk=" + DoubleToStr(Risk,0) + "%" + NL ;

sComment = sComment + sp ;

Commentaire(sComment) ;

}

//----------------------- VARIABLE BOOLEN VERS FONCTION STRING

//----------------------- SOURCE : CODERSGURU

string subBoolToStr ( bool value )

{

if(value) return ("True") ;

sinon retour ("False") ;

}

//----------------------- FONCTION DE FIN

Merci d'avance.

Jo

 

mladen,

J'espère que vous allez bien. Le fichier ci-dessous contient deux erreurs de compilation. Veuillez m'aider.

Dossiers :
 
candyman752:
mladen, j'espère que vous allez bien. Le programme ci-dessous a deux erreurs de compilation.

candyman752

Essayez-le maintenant : rstochalert-4tf_1.mq4

Dossiers :
 

Très cher MLADEN,

(mes questions concernent toujours l'aide à la réparation plus que l'aide au codage)

j'ai une demande à comprendre.....voyez les 2 images que j'ai ajoutées, la 1ère est avec 1 erreur et 2 avertissements concernant les lignes 70 et 72.... comme vous pouvez le voir dans la 2ème image, j'ai remplacé et 1 erreur et 1 avertissement ont été enlevés...... ma question est...est-ce bien de faire de cette façon.... et deuxième question concernant le 2ème avertissement qui est toujours derrière à la ligne 80...si laissé comme il est, pas de problème de fonctionnement?

Salutations

mntiwana

 
mntiwana:
Très cher MLADEN,

(mes questions concernent toujours l'aide à la réparation plus que l'aide au codage)

j'ai une demande à comprendre.....voyez les 2 images que j'ai ajoutées, la 1ère est avec 1 erreur et 2 avertissements concernant les lignes 70 et 72.... comme vous pouvez le voir dans la 2ème image, je l'ai remplacée et 1 erreur et 1 avertissement ont été enlevés...... ma question est...est-ce bien de faire de cette façon.... et deuxième question concernant le 2ème avertissement qui est toujours derrière à la ligne 80...si laissé tel quel, pas de problème de fonctionnement ?

Salutations

mntiwana

mntiwana

de cette façon tout est OK. vous avez fait les changements OK

 
mladen:
mntiwana de cette façon tout est OK. vous avez fait les changements OK

donc merci beaucoup grand patron d'encourager un étudiant curieux.

mes meilleures salutations

 
Jovager:
Mladen,

Pouvez-vous me donner la raison pour laquelle cette ea ne fonctionne pas.

//----------------------- PARAMÈTRE EA

chaîne externe

Expert_Name = "---------- Pending Order EA v1",

Expert_Name2 = "---------- For current price set EntryLevel = 0" ;

extern double

EntryLevel = 1.8600,

Distance = 100,

StopLoss = 50,

TakeProfit = 50,

TrailingStop = 50 ;

chaîne externe

Order_Setting = "---------- Order Setting" ;

extern int

NumberOfTries = 5,

Slippage = 5,

MagicNumber = 1234 ;

chaîne externe

MM_Parameters = "---------- Money Management" ;

extern double

Lots =0.01 ;

extern bool

MM = false, //Utilise Money Management ou non

AccountIsMicro = true ; //Utiliser le micro-compte ou non

extern int

Risk = 0 ; //10 %.

extern string

Testing_Parameters= "---------- Back Test Parameter" ;

extern bool

Show_Settings = true ;

//----------------------- VARIABLE GLOBALE

static int

TimeFrame = 0 ;

chaîne de caractères

TicketComment = "PendingOrderEA v2",

LastTrade ;

bool

TradeAllow = true,

EntryAllow = true ;

//+------------------------------------------------------------------+

//| fonction d'initialisation de l'expert

//+------------------------------------------------------------------+

int init()

{

//----------------------- GÉNÉRER LE NUMÉRO MAGIQUE ET LE COMMENTAIRE DU TICKET

//----------------------- SOURCE : PENGIE

MagicNumber = subGenerateMagicNumber(MagicNumber, Symbol(), Period()) ;

TicketComment = StringConcatenate(TicketComment, "-", Symbol(), "-", Period()) ;

//----------------------- MONTRER LE PARAMÈTRE EA SUR LE GRAPHIQUE

//----------------------- SOURCE : CODERSGURU

if(Show_Settings) subPrintDetails() ;

else Comment("") ;

return(0) ;

}

//+------------------------------------------------------------------+

//| fonction de désinitialisation experte |

//+------------------------------------------------------------------+

int deinit()

{

//----------------------- EMPÊCHER LE RECOMPTAGE LORSQUE L'UTILISATEUR CHANGE DE PÉRIODE DE TEMPS

//----------------------- SOURCE : CODERSGURU

TimeFrame=Period() ;

retour(0) ;

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int start()

{

double

// BuyLevel,

SellLevel ;

int

cnt,

ticket,

total ;

//----------------------- fixer le prix d'achat et de vente

if(EntryLevel==0) EntryLevel = Bid ;

// Niveau d'achat = Niveau d'entrée + Distance*Point ;

Niveau de vente = Niveau d'entrée - Distance*Point ;

// if((BuyLevel-Ask)<10*Point || (Bid-SellLevel)<10*Point)

// {

// Comment("Prix d'entrée ou distance invalide") ;

// return(0) ;

// }

//----------------------- AJUSTER LES LOTS SI VOUS UTILISEZ LE MONEY MANAGEMENT

if(MM) Lots = subLotSize() ;

//----------------------- ENTRY

//----------------------- TOTAL DE L'ORDRE BASÉ SUR LE NUMÉRO MAGIQUE ET LE SYMBOLE

total = subTotalTrade() ;

//----------------------- N'ÉTABLIT L'ORDRE QU'UNE SEULE FOIS

if(TradeAllow)

{

//----------------------- IF NO TRADE

if(total<1 && EntryAllow)

{

ticket = OrderSend(Symbol(),OP_SELLSTOP,Lots,SellLevel,Slippage,SellLevel+StopLoss*Point,SellLevel-TakeProfit*Point,TicketComment,MagicNumber,0,Red) ;

// ticket = OrderSend(Symbol(),OP_BUYSTOP,Lots,BuyLevel,Slippage,BuyLevel-StopLoss*Point,BuyLevel+TakeProfit*Point,TicketComment,MagicNumber,0,Green) ;

EntryAllow = false ;

retour(0) ;

}

si(total==1)

{

subDeleteOrder() ;

TradeAllow = false ;

}

}

//----------------------- SECTION DE TRAILING STOP

si(TrailingStop>0 && subTotalTrade()>0)

{

total = OrdersTotal() ;

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) ;

si(OrderType()<=OP_SELL &&

OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber)

{

subTrailingStop(OrderType()) ;

retour(0) ;

}

}

}

return(0) ;

}

//----------------------- END PROGRAM

//+------------------------------------------------------------------+

//| DÉFINITIONS DES FONCTIONS

//+------------------------------------------------------------------+

//----------------------- FONCTION DE GESTION DE L'ARGENT

//----------------------- SOURCE : CODERSGURU

double subLotSize()

{

double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000) / 100 ;

if(AccountIsMicro==false) //compte normal

{

if(lotMM < 0.1) lotMM = Lots ;

if((lotMM > 0.5) && (lotMM < 1)) lotMM = 0.5 ;

if(lotMM > 1.0) lotMM = MathCeil(lotMM) ;

si(lotMM > 100) lotMM = 100 ;

}

else //micro compte

{

if(lotMM < 0.01) lotMM = Lots ;

if(lotMM > 1.0) lotMM = MathCeil(lotMM) ;

if(lotMM > 100) lotMM = 100 ;

}

return (lotMM) ;

}

//----------------------- NOMBRE D'ORDRE BASÉ SUR LE SYMBOLE ET LA FONCTION MAGICNUMBER

int subTotalTrade()

{

int

cnt,

total = 0 ;

for(cnt=0;cnt<OrdersTotal();cnt++)

{

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES) ;

si(OrderType()<=OP_SELL &&

OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber) total++ ;

}

return(total) ;

}

//----------------------- FONCTION DE SUPPRESSION DE LA COMMANDE

void subDeleteOrder()

{

int

cnt,

total = 0 ;

total = OrdersTotal() ;

for(cnt=total-1;cnt>=0;cnt--)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) ;

if(OrderSymbol()==Symbol() &&

OrderMagicNumber()==MagicNumber)

{

switch(OrderType())

{

// cas OP_BUYLIMIT :

// cas OP_BUYSTOP :

cas OP_SELLLIMIT :

cas OP_SELLSTOP :

OrderDelete(OrderTicket()) ;

}

}

}

}

//----------------------- FONCTION DE TRAILING STOP

//----------------------- SOURCE : CODERSGURU

//----------------------- MODIFIÉ : FIREDAVE

void subTrailingStop(int Type)

{

if(Type==OP_BUY) // la position d'achat est ouverte

{

if(Bid-OrderOpenPrice()>Point*TrailingStop &&

OrderStopLoss()<Bid-Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green) ;

retour(0) ;

}

}

if(Type==OP_SELL) // une position de vente est ouverte

{

if(OrderOpenPrice()-Ask>Point*TrailingStop)

{

if(OrderStopLoss()>Ask+Point*TrailingStop || OrderStopLoss()==0)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red) ;

retour(0) ;

}

}

}

}

//----------------------- GÉNÉRER LE NOMBRE MAGIQUE EN FONCTION DU SYMBOLE ET DE LA FONCTION DE L'INTERVALLE DE TEMPS.

//----------------------- SOURCE : PENGIE

//----------------------- MODIFIÉ : FIREDAVE

int subGenerateMagicNumber(int MagicNumber, string symbol, int timeFrame)

{

int isymbol = 0 ;

si (symbol == "EURUSD") isymbol = 1 ;

else if (symbol == "GBPUSD") isymbol = 2 ;

sinon si (symbole == "USDJPY") isymbol = 3 ;

autre si (symbole == "AUDCAD") isymbol = 4 ;

autre si (symbole == "AUDUSD") isymbol = 5 ;

autre si (symbol == "USDCAD") isymbol = 6 ;

sinon si (symbole == "EURGBP") isymbol = 7 ;

sinon si (symbole == "EURJPY") isymbol = 8 ;

sinon si (symbole == "EURCHF") isymbol = 9 ;

sinon si (symbole == "EURAUD") isymbol = 10 ;

autre si (symbole == "EURCAD") isymbol = 11 ;

autre si (symbol == "GBPUSD") isymbol = 12 ;

autre si (symbol == "GBPJPY") isymbol = 13 ;

autre si (symbol == "GBPCHF") isymbol = 14 ;

autre si (symbol == "GBPAUD") isymbol = 15 ;

autre si (symbol == "GBPCAD") isymbol = 16 ;

sinon isymbol = 17 ;

if(isymbol<10) MagicNumber = MagicNumber * 10 ;

return (StrToInteger(StringConcatenate(MagicNumber, isymbol, timeFrame)) ;)

}

//----------------------- IMPRIMER LA FONCTION DE COMMENTAIRE

//----------------------- SOURCE : CODERSGURU

void subPrintDetails()

{

string sComment = "" ;

string sp = "----------------------------------------\n" ;

string NL = "\n" ;

sComment = sp ;

sComment = sComment + "TakeProfit=" + DoubleToStr(TakeProfit,0) + " | " ;

sComment = sComment + "TrailingStop=" + DoubleToStr(TrailingStop,0) + " | " ;

sComment = sComment + "StopLoss=" + DoubleToStr(StopLoss,0) + NL ;

sComment = sComment + sp ;

sComment = sComment + "Lots=" + DoubleToStr(Lots,2) + " | " ;

sComment = sComment + "MM=" + subBoolToStr(MM) + " | " ;

sComment = sComment + "Risk=" + DoubleToStr(Risk,0) + "%" + NL ;

sComment = sComment + sp ;

Commentaire(sComment) ;

}

//----------------------- VARIABLE BOOLEN VERS FONCTION STRING

//----------------------- SOURCE : CODERSGURU

string subBoolToStr ( bool value )

{

if(value) return ("True") ;

sinon retour ("False") ;

}

//----------------------- FONCTION DE FIN

Merci d'avance.

Jo

Jo,

Pouvez-vous joindre le fichier mq4 ? Il est très difficile de le tester de cette façon.