Erro gPointPow
1 resposta
anemosbr
3 anos atrás #266917
Quero interromper as ordens quando o ea atingir um determinado lucro e vi o código abaixo em outra mensagem no fórum:
duplo sqGetPLInPipsToday() {
string todayTime = TimeToStr( TimeCurrent(), TIME_DATE);
plToday duplo = 0;
for(int i=0;i<OrdersHistoryTotal();i++) {
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==verdadeiro && OrderSymbol() == Symbol()) {
if(OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLLLIMIT || OrderType() == OP_SELLSTOP) {
// pular ordens pendentes
continuar;
}
if(TimeToStr( OrderOpenTime(), TIME_DATE) == hojeTime) {
Log("Comparing ", TimeToStr( OrderOpenTime(), TIME_DATE), " = ", todayTime);
if(OrderType() == OP_BUY) {
plToday += OrderClosePrice() - OrderOpenPrice();
{} else {
plToday += OrderOpenPrice() - OrderClosePrice();
}
}
}
}
para (int cc = OrderTotal() - 1; cc >= 0; cc-) {
if (OrderSelect(cc, SELECT_BY_POS) && OrderSymbol() == Símbolo()) {
if(OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLLLIMIT || OrderType() == OP_SELLSTOP) {
// pular ordens pendentes
continuar;
}
if(TimeToStr( OrderOpenTime(), TIME_DATE) == hojeTime) {
if(OrderType() == OP_BUY) {
plToday += sqGetBid(OrderSymbol()) - OrderOpenPrice();
{} else {
plToday += OrderOpenPrice() - sqGetAsk(OrderSymbol());
}
}
}
}
return (plToday*gPointPow);
}
No entanto, quando tento inserir o código abaixo na linha de códigos gerada no AlgoWizard, recebo a seguinte mensagem de erro:
'gPointPow' - identificador não declarado
Como faço para corrigir esse erro? Preciso adicionar alguma coisa?
tomas262
3 anos atrás #267302
Olá,
Você tentou obter os valores de P/L diários? Ele pode ser obtido facilmente subtraindo AccountEquity() menos AccountEquity() do dia anterior ou, se você executar vários EAs usando números mágicos diferentes, poderá usar este código
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();}
}
}
Se precisar de ajuda com isso, entre em contato comigo
Visualizando 1 resposta (de um total de 1)