Bonjour,
Pourriez vous m’aider à convertir le code mq4 ci dessous en indicateur ProRealtime. Il s’agit de l’indicateur OBO Trend Bars.
Je vous remercie d’avance.
extern string rem1=”//—- Definition Trend et Breakout”;
extern int BreakoutPeriode=1;
extern int TrendPeriode=3;
extern string rem2=”//—- Order”;
extern int MaxTradesPerBar=1;
extern int StopLoss=7;
extern int BreakEven=7;
extern int PartialTP1=55;
extern int PartialRatio1=30;
extern int PartialTP2=110;
extern int PartialRatio2=70;
extern int TakeProfit=150;
extern int Slippage=3;
extern string rem3=”//—- MM: 1.Fixed 2.Geometrical 3.Proportional 4.Smart 5.TSSF”;
extern int MMType=3;
extern double FixedLots=0.1;
extern int GeometricalFactor=3;
extern int ProportionalRisk=90;
extern int LastXTrades=10;
extern double DecreaseFactor=2;
extern double TSSFTrigger1=1;
extern int TSSFRatio1=50;
extern double TSSFTrigger2=2;
extern int TSSFRatio2=75;
extern double TSSFTrigger3=3;
extern int TSSFRatio3=100;
extern string rem4=”//—- Debug”;
extern bool DebugMode=false;
int Magic=12387;
double Lots;
bool SignalBuy=false;
bool SignalSell=false;
double highrange, lowrange;
double trend, trend1, signaltrend;
datetime LastTradeTime=0;
int MaxTrades=false;
int FlagPartial=0;
int OrdersThisBar;
int orders;
int losses;
int tradegagnant,tradeperdant;
double profit, perte, avgwin, avgloss, prcwin, tssf;
bool TradingRange;
//+——————————————————————+
//| expert initialization function |
//+——————————————————————+
int init()
{
//—-
//—-
return(0);
}
//+——————————————————————+
//| expert deinitialization function |
//+——————————————————————+
int deinit()
{
//—-
//—-
return(0);
}
//+——————————————————————+
//| expert start function |
//+——————————————————————+
int start()
{
//—-
if (OrdersTotal()0) OrdersList();
if (OrdersTotal()=MaxTradesPerBar)
{MaxTrades=true;}
else
{MaxTrades=false;}
if (Time[0]!=LastTradeTime)
{OrdersThisBar=0;}
if (Close[0]==High[0]&&Close[0]highrange&&signaltrend0&&OrdersTotal()=orders-LastXTrades;i–)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==False)
{
Print(“Erreur dans l historique!”);
break;
}
if(OrderSymbol()!=Symbol() || OrderType()OP_SELL)
continue;
//—-
if(OrderProfit()0)
break;
if(OrderProfit()1)
Lots=NormalizeDouble(Lots-Lots*losses/DecreaseFactor,1);
}
if (MMType==5&&OrdersTotal()=orders-LastXTrades;j–)
{
if(OrderSelect(j,SELECT_BY_POS,MODE_HISTORY)==False)
{
Print(“Erreur dans l historique!”);
break;
}
if(OrderProfit()=0)
{
tradegagnant++;
profit=profit+OrderProfit();
}
else
{
tradeperdant++;
perte=perte+OrderProfit();
}
}
if (ordersLastXTrades)avgwin=profit/tradegagnant;
if (ordersLastXTrades)avgloss=perte/tradeperdant;
if (ordersLastXTrades)prcwin=tradegagnant/(tradegagnant+tradeperdant);
if (ordersLastXTrades)tssf=avgwin/avgloss*((1.1-prcwin)/(prcwin-0.1)+1);
if(tssfTSSFTrigger1&&tssfTSSFTrigger2&&tssfTSSFTrigger3)Lots=NormalizeDouble(AccountFreeMargin()*ProportionalRisk/TSSFRatio3*100/100000,1);
}
if(LotsPoint*BreakEven&&OrderStopLoss()!=OrderOpenPrice())
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,LightGreen);
return(0);
}
//—- PartialTP1
if (Bid-OrderOpenPrice()Point*PartialTP1&&FlagPartial==0&&PartialTP10&&OrderLots()*PartialRatio1*PartialRatio2/10000=0.1)
{
OrderClose(OrderTicket(),OrderLots()*PartialRatio1/100,Bid,Slippage,Red);
FlagPartial=1;
return(0);
}
//—- PartialTP2
if (Bid-OrderOpenPrice()Point*PartialTP2&&FlagPartial==1&&PartialTP20)
{
OrderClose(OrderTicket(),OrderLots()*PartialRatio2/100,Bid,Slippage,Red);
FlagPartial=2;
return(0);
}
}
if (OrderType()==OP_SELL)
{
//—- BreakEven
if (OrderOpenPrice()-AskPoint*BreakEven&&OrderStopLoss()!=OrderOpenPrice())
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Yellow);
return(0);
}
//—- PartialTP1
if (OrderOpenPrice()-AskPoint*PartialTP1&&FlagPartial==0&&PartialTP10&&OrderLots()*PartialRatio1*PartialRatio2/10000=0.1)
{
OrderClose(OrderTicket(),OrderLots()*PartialRatio1/100,Ask,Slippage,Red);
FlagPartial=1;
return(0);
}
//—- PartialTP2
if (OrderOpenPrice()-AskPoint*PartialTP2&&FlagPartial==1&&PartialTP20)
{
OrderClose(OrderTicket(),OrderLots()*PartialRatio2/100,Ask,Slippage,Red);
FlagPartial=2;
return(0);
}
}
}
}
}