指定
if(bearishCross && sells<MaxTradesPerSym)
{
sl = NormalizeDouble(ask + stoploss,(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS));
tp = NormalizeDouble(ask - stoploss*TakeProfitRR,(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS));
trade.SetExpertMagicNumber(MagicNumber);
trade.Sell(volume,symbol,bid,sl,tp,"EA_SELL");
lastActionTime=TimeCurrent();
}
ManageTrailing(symbol);
}
//+------------------------------------------------------------------+
void CountOpen(string sym,int &buy,int &sell)
{
buy=0; sell=0;
for(int i=PositionsTotal()-1;i>=0;i--)
{
if(PositionSelectByTicket(PositionGetTicket(i)))
{
if(PositionGetString(POSITION_SYMBOL)==sym && PositionGetInteger(POSITION_MAGIC)==MagicNumber)
{
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) buy++;
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL) sell++;
}
}
}
}
//+------------------------------------------------------------------+
double CalcLotByRisk(string sym,double slPts,double riskP)
{
double bal=AccountInfoDouble(ACCOUNT_BALANCE);
double riskMoney=bal*riskP/100.0;
if(riskMoney<=0) return 0.0;
double tickVal=SymbolInfoDouble(sym,SYMBOL_TRADE_TICK_VALUE);
double tickSize=SymbolInfoDouble(sym,SYMBOL_TRADE_TICK_SIZE);
if(tickVal<=0||tickSize<=0) return 0.0;
double lossPerLot=slPts*(tickVal/tickSize);
if(lossPerLot<=0) return 0.0;
double lots=riskMoney/lossPerLot;
return NormalizeVolume(sym,lots);
}
//+------------------------------------------------------------------+
double NormalizeVolume(string sym,double vol)
{
double step=SymbolInfoDouble(sym,SYMBOL_VOLUME_STEP);
double minv=SymbolInfoDouble(sym,SYMBOL_VOLUME_MIN);
double maxv=SymbolInfoDouble(sym,SYMBOL_VOLUME_MAX);
if(step<=0) step=0.01;
double n=MathFloor(vol/step)*step;
if(n<minv) n=minv;
if(n>maxv) n=maxv;
int digits=(step<1)?(int)MathRound(MathAbs(MathLog10(step))):0;
return NormalizeDouble(n,digits);
}
//+------------------------------------------------------------------+
void ManageTrailing(string sym)
{
for(int i=PositionsTotal()-1;i>=0;i--)
{
if(!PositionSelectByTicket(PositionGetTicket(i))) continue;
if(PositionGetString(POSITION_SYMBOL)!=sym) continue;
if(PositionGetInteger(POSITION_MAGIC)!=MagicNumber) continue;
int type=PositionGetInteger(POSITION_TYPE);
double openPrice=PositionGetDouble(POSITION_PRICE_OPEN);
double sl=PositionGetDouble(POSITION_SL);
double curr=(type==POSITION_TYPE_BUY)?SymbolInfoDouble(sym,SYMBOL_BID):SymbolInfoDouble(sym,SYMBOL_ASK);
double point=SymbolInfoDouble(sym,SYMBOL_POINT);
double digits=(int)SymbolInfoInteger(sym,SYMBOL_DIGITS);
double profitPts=(type==POSITION_TYPE_BUY)?(curr-openPrice)/point:(openPrice-curr)/point;
if(profitPts>TrailingStartPts)
{
double newSL=(type==POSITION_TYPE_BUY)?curr - TrailingStepPts*point:curr + TrailingStepPts*point;
if((type==POSITION_TYPE_BUY && newSL>sl)||(type==POSITION_TYPE_SELL && newSL<sl))
{
trade.PositionModify(PositionGetInteger(POSITION_TICKET),NormalizeDouble(newSL,(int)digits),PositionGetDouble(POSITION_TP));
}
}
}
}
//+------------------------------------------------------------------+
{
sl = NormalizeDouble(ask + stoploss,(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS));
tp = NormalizeDouble(ask - stoploss*TakeProfitRR,(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS));
trade.SetExpertMagicNumber(MagicNumber);
trade.Sell(volume,symbol,bid,sl,tp,"EA_SELL");
lastActionTime=TimeCurrent();
}
ManageTrailing(symbol);
}
//+------------------------------------------------------------------+
void CountOpen(string sym,int &buy,int &sell)
{
buy=0; sell=0;
for(int i=PositionsTotal()-1;i>=0;i--)
{
if(PositionSelectByTicket(PositionGetTicket(i)))
{
if(PositionGetString(POSITION_SYMBOL)==sym && PositionGetInteger(POSITION_MAGIC)==MagicNumber)
{
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) buy++;
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL) sell++;
}
}
}
}
//+------------------------------------------------------------------+
double CalcLotByRisk(string sym,double slPts,double riskP)
{
double bal=AccountInfoDouble(ACCOUNT_BALANCE);
double riskMoney=bal*riskP/100.0;
if(riskMoney<=0) return 0.0;
double tickVal=SymbolInfoDouble(sym,SYMBOL_TRADE_TICK_VALUE);
double tickSize=SymbolInfoDouble(sym,SYMBOL_TRADE_TICK_SIZE);
if(tickVal<=0||tickSize<=0) return 0.0;
double lossPerLot=slPts*(tickVal/tickSize);
if(lossPerLot<=0) return 0.0;
double lots=riskMoney/lossPerLot;
return NormalizeVolume(sym,lots);
}
//+------------------------------------------------------------------+
double NormalizeVolume(string sym,double vol)
{
double step=SymbolInfoDouble(sym,SYMBOL_VOLUME_STEP);
double minv=SymbolInfoDouble(sym,SYMBOL_VOLUME_MIN);
double maxv=SymbolInfoDouble(sym,SYMBOL_VOLUME_MAX);
if(step<=0) step=0.01;
double n=MathFloor(vol/step)*step;
if(n<minv) n=minv;
if(n>maxv) n=maxv;
int digits=(step<1)?(int)MathRound(MathAbs(MathLog10(step))):0;
return NormalizeDouble(n,digits);
}
//+------------------------------------------------------------------+
void ManageTrailing(string sym)
{
for(int i=PositionsTotal()-1;i>=0;i--)
{
if(!PositionSelectByTicket(PositionGetTicket(i))) continue;
if(PositionGetString(POSITION_SYMBOL)!=sym) continue;
if(PositionGetInteger(POSITION_MAGIC)!=MagicNumber) continue;
int type=PositionGetInteger(POSITION_TYPE);
double openPrice=PositionGetDouble(POSITION_PRICE_OPEN);
double sl=PositionGetDouble(POSITION_SL);
double curr=(type==POSITION_TYPE_BUY)?SymbolInfoDouble(sym,SYMBOL_BID):SymbolInfoDouble(sym,SYMBOL_ASK);
double point=SymbolInfoDouble(sym,SYMBOL_POINT);
double digits=(int)SymbolInfoInteger(sym,SYMBOL_DIGITS);
double profitPts=(type==POSITION_TYPE_BUY)?(curr-openPrice)/point:(openPrice-curr)/point;
if(profitPts>TrailingStartPts)
{
double newSL=(type==POSITION_TYPE_BUY)?curr - TrailingStepPts*point:curr + TrailingStepPts*point;
if((type==POSITION_TYPE_BUY && newSL>sl)||(type==POSITION_TYPE_SELL && newSL<sl))
{
trade.PositionModify(PositionGetInteger(POSITION_TICKET),NormalizeDouble(newSL,(int)digits),PositionGetDouble(POSITION_TP));
}
}
}
}
//+------------------------------------------------------------------+
反馈
1
等级
项目
2
0%
仲裁
1
0%
/
0%
逾期
0
空闲
相似订单
Salut je besoin de quelqu'un qui peut me faire l’indicateur arrow donc l’image je joint en annexe. Exactement pareille mais sa plus grande spécificités est que l’indicateur ne doit pas disparaître apres qu’il est apparu meme si ce un faut signals il doit resté actife. Note l’indicateur doit ne doit pas apparaitre n’importe quand ni comment mais doit examiné avec exactitude la zone de block order et celui de support
BONSOIR/BONJOUR J'ai à ma disposition un système de plusieurs indicateurs que j'utilise. J'observe l'ensemble de ces indicateurs pour déclencher un achat/vente dans une condition particulière des indicateurs. je veux formaliser tout ça dans un robot de trading automatique qui déclenchera les positions dans ces conditions particulières
项目信息
预算
30 - 500 USD
截止日期
到 15 天
客户
所下订单1
仲裁计数0