gPointPow erreur
1 réponses
anemosbr
il y a 3 ans #266917
Je veux interrompre les ordres lorsque l'ea atteint un certain profit et j'ai vu le code ci-dessous dans un autre message sur le forum :
double sqGetPLInPipsToday() {
string todayTime = TimeToStr( TimeCurrent(), TIME_DATE) ;
double plToday = 0 ;
for(int i=0;i<OrdersHistoryTotal();i++) {
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true && OrderSymbol() == Symbol()) {
if(OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLLIMIT || OrderType() == OP_SELLSTOP) {
// Sauter les ordres en cours
continuer ;
}
if(TimeToStr( OrderOpenTime(), TIME_DATE) == todayTime) {
Log("Comparing ", TimeToStr( OrderOpenTime(), TIME_DATE), " = ", todayTime) ;
if(OrderType() == OP_BUY) {
plToday += OrderClosePrice() - OrderOpenPrice() ;
} else {
plToday += OrderOpenPrice() - OrderClosePrice() ;
}
}
}
}
for (int cc = OrdersTotal() - 1 ; cc >= 0 ; cc-) {
if (OrderSelect(cc, SELECT_BY_POS) && OrderSymbol() == Symbol()) {
if(OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLLIMIT || OrderType() == OP_SELLSTOP) {
// Sauter les ordres en cours
continuer ;
}
if(TimeToStr( OrderOpenTime(), TIME_DATE) == todayTime) {
if(OrderType() == OP_BUY) {
plToday += sqGetBid(OrderSymbol()) - OrderOpenPrice() ;
} else {
plToday += OrderOpenPrice() - sqGetAsk(OrderSymbol()) ;
}
}
}
}
return (plToday*gPointPow) ;
}
Cependant, lorsque j'essaie d'insérer le code ci-dessous dans la ligne de codes générée dans AlgoWizard, j'obtiens le message d'erreur suivant :
gPointPow" - identifiant non déclaré
Comment puis-je corriger cette erreur ? Dois-je ajouter quelque chose ?
tomas262
il y a 3 ans #267302
Bonjour,
Essayez-vous d'obtenir les valeurs P/L journalières ? Vous pouvez l'obtenir facilement en soustrayant AccountEquity() moins AccountEquity() du jour précédent ou si vous exécutez plusieurs EAs utilisant des nombres magiques différents, vous pouvez utiliser ce code.
double Total_profit= NULL;int cnt = NULL ;
for(cnt=0;cnt<=OrdersTotal();cnt++){
OrderSelect(cnt,SELECT_BY_POS) ;
if(OrderSymbol() == Symbol() && OrderMagicNumber()==magic)
{if( OrderType() == OP_BUY || OrderType() == OP_SELL )
{Total_profit= Total_profit+ OrderProfit() + OrderSwap() + OrderCommission();}
}
}
Faites-moi savoir si vous avez besoin d'aide à ce sujet.
Affichage d'1 réponse (sur un total de 1)