int ActNumber=0;
datetime ExpDate=D'23.12.2025';
#property strict
#property version "3.05"
enum manager {
P=0, // Primary
B=1, // Secondary
};
extern manager TradeManager = 0;
extern string TradeComment = "iFX NET";
extern int MagicNumber = 33431;
extern int MaxTrades=1;//Max obchodu
extern int Slippage = 3;
extern int MaxSpread = 110;
extern double FixedLot = 0;
extern int RiskPercent = 2;
extern int MaxDrawdown = 90;
extern double MaxLoss=500;//Max ztrata za den
extern int SL=0;
extern int StartHour = 2;
extern int EndHour = 22;
extern int GMTOffset = 0;
extern int TradeDeviation = 2;
extern int TradeDelta = 12;
extern int Trailing = 3;
extern int StartTrailing = 4;
extern int VelocityTrigger = 70;
extern int VelocityTime = 7;
int DeleteRatio = 0;
int OrderExpiry = 0;
extern int TickSample = 100;
int r, gmt, brokerOffset, size, digits, stoplevel;
double marginRequirement, maxLot, minLot, lotSize, points, currentSpread, avgSpread, maxSpread, initialBalance, rateChange, rateTrigger, deleteRatio, commissionPoints;
double spreadSize[];
double tick[];
double avgtick[];
int tickTime[];
string testerStartDate, testerEndDate;
int lastBuyOrder, lastSellOrder;
bool calculateCommission = true;
bool closing;
double max = 0;
int init() {
// код доступен только после оплаты
}
void commission(){
if( !IsTesting() ){
double rate = 0;
for( int pos = OrdersHistoryTotal() - 1; pos >= 0; pos-- ) {
if( OrderSelect( pos, SELECT_BY_POS, MODE_HISTORY ) ) {
if( OrderProfit() != 0.0 ) {
if( OrderClosePrice() != OrderOpenPrice() ) {
if( OrderSymbol() == Symbol() ) {
calculateCommission = false;
rate = MathAbs( OrderProfit() / MathAbs( OrderClosePrice() - OrderOpenPrice() ) );
commissionPoints = ( -OrderCommission() ) / rate;
break;
}
}
}
}
}
}
}
int offlineGMT(){
int bkrH = Hour();
int gOffset = bkrH - GMTOffset;
if( gOffset < 0 ) gOffset += 24;
else if( gOffset > 23 ) gOffset -= 24;
return ( gOffset );
}
int start() {
// код доступен только после оплаты
}
int totalBuyStop = 0;
int totalSellStop = 0;
int ticket,pos;
int totalTrades = 0;
int totalUnprotected = 0;
double accountEquity,stop,cena,profdnes=0;
if( calculateCommission ) commission();
gmt = offlineGMT();
prepareSpread();
manageTicks();
if (MaxLoss!=0 && OrdersHistoryTotal()>0)
{
for( pos = 0; pos < OrdersHistoryTotal(); pos++ )
{
r = OrderSelect( pos, SELECT_BY_POS, MODE_HISTORY );
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && OrderCloseTime()>=iTime(Symbol(),PERIOD_D1,0)) profdnes+=OrderProfit() + OrderCommission() + OrderSwap();
}
}
if (!IsTesting() && !IsOptimization() && AccountNumber()!=ActNumber && ActNumber>0) {Comment("\n !! INVALID ACCOUNT NUMBER !!\n !! TRADING IS NOT ALLOWED !!");return(0);}
if(ExpDate>0 && TimeCurrent()>=ExpDate) {Comment("\n*** LICENSE EXPIRED ***");return(0);}
for(pos = OrdersTotal()-1; pos >=0; pos-- )
{
r = OrderSelect( pos, SELECT_BY_POS, MODE_TRADES );
if( OrderSymbol() != Symbol() ) continue;
if( OrderMagicNumber() == MagicNumber ){
totalTrades++;
profdnes+=OrderProfit() + OrderCommission() + OrderSwap();
switch ( OrderType() ) {
case OP_BUYSTOP:
if( (int) TimeCurrent() - lastBuyOrder > VelocityTime )
r = OrderDelete( OrderTicket() );
totalBuyStop++;
totalUnprotected++;
break;
case OP_SELLSTOP:
if( (int) TimeCurrent() - lastSellOrder > VelocityTime )
r = OrderDelete( OrderTicket() );
totalSellStop++;
totalUnprotected++;
break;
case OP_BUY:
accountEquity = AccountBalance() + OrderProfit() + OrderCommission() + OrderSwap();
if( OrderStopLoss() == 0 || ( OrderStopLoss() > 0 && OrderStopLoss() < OrderOpenPrice() ) ) totalUnprotected++;
if( Bid - OrderOpenPrice() > ( Trailing * Point ) + ( StartTrailing * Point ) + commissionPoints ){
if( OrderStopLoss() == 0.0 || Bid - OrderStopLoss() > Trailing * Point )
if( NormalizeDouble( Bid - ( Trailing * Point ), Digits ) != OrderStopLoss() )
r = OrderModify( OrderTicket(), OrderOpenPrice(), NormalizeDouble( Bid - ( Trailing * Point ), Digits ), OrderTakeProfit(), 0 );
} else {
if( accountEquity > max || accountEquity / AccountBalance() < ( double ) MaxDrawdown / 100 ){
if( Bid < OrderOpenPrice() - ( VelocityTrigger * Point ) )
if( OrderStopLoss() == 0.0 || Bid - OrderStopLoss() > ( Trailing * Point ) )
if( NormalizeDouble( Bid - ( Trailing * Point ), Digits ) != OrderStopLoss() )
r = OrderModify( OrderTicket(), OrderOpenPrice(), NormalizeDouble( Bid - ( Trailing * Point ), Digits ), OrderTakeProfit(), 0 );
}
}
break;
case OP_SELL:
accountEquity = AccountBalance() + OrderProfit() + OrderCommission() + OrderSwap();
if( OrderStopLoss() == 0 || ( OrderStopLoss() > 0 && OrderStopLoss() > OrderOpenPrice() ) ) totalUnprotected++;
if( OrderOpenPrice() - Ask > ( Trailing * Point ) + ( StartTrailing * Point ) + commissionPoints ){
if( OrderStopLoss() == 0.0 || OrderStopLoss() - Ask > Trailing * Point )
if( NormalizeDouble( Ask + ( TrailПоказано первые 50% кода (символов: 9781)
Введите ваш email и нажмите кнопку, чтобы перейти к оплате.