#include <OrderReliable_v0_2_5.mqh>
extern int INCREMENT=70;
extern double LOTS=0.1;
extern int LEVELS=1;
extern double MAX_LOTS=99;
extern int MAGIC=1803;
extern bool CONTINUE=true;
extern bool MONEY_MANAGEMENT=false;
extern int RISK_RATIO=2;
bool UseProfitTarget=false;
bool UsePartialProfitTarget=false;
int Target_Increment = 50;
int First_Target = 20;
bool UseEntryTime=false;
int EntryTime=0;
bool Enter=true;
int nextTP;
int init()
{
// код доступен только после оплаты
}
int deinit()
{
return(0);
}
int start()
{
// код доступен только после оплаты
}
int ticket, cpt, profit, total=0, BuyGoalProfit, SellGoalProfit, PipsLot;
double ProfitTarget=INCREMENT*2, BuyGoal=0, SellGoal=0, spread=(Ask-Bid)/Point, InitialPrice=0;
if(INCREMENT<MarketInfo(Symbol(),MODE_STOPLEVEL)+spread) INCREMENT=1+MarketInfo(Symbol(),MODE_STOPLEVEL)+spread;
if(MONEY_MANAGEMENT) LOTS=NormalizeDouble(AccountBalance()*AccountLeverage()/1000000*RISK_RATIO,0)*MarketInfo(Symbol(),MODE_MINLOT);
if(LOTS<MarketInfo(Symbol(),MODE_MINLOT))
{
Comment("Not Enough Free Margin to begin");
return(0);
}
for(cpt=1;cpt<LEVELS;cpt++) PipsLot+=cpt*INCREMENT;
for(cpt=0;cpt<OrdersTotal();cpt++)
{
OrderSelect(cpt,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==MAGIC && OrderSymbol()==Symbol())
{
total++;
if(!InitialPrice) InitialPrice=StrToDouble(OrderComment());
if(UsePartialProfitTarget && UseProfitTarget && OrderType()<2)
{
double val=getPipValue(OrderOpenPrice(),OrderType());
takeProfit(val,OrderTicket());
}
}
}
if(total<1 && Enter && (!UseEntryTime || (UseEntryTime && Hour()==EntryTime)))
{
if(AccountFreeMargin()<(100*LOTS))
{
Print("Not enough free margin to begin");
return(0);
}
InitialPrice=Ask;
SellGoal=InitialPrice-(LEVELS+1)*INCREMENT*Point;
BuyGoal=InitialPrice+(LEVELS+1)*INCREMENT*Point;
for(cpt=1;cpt<=LEVELS;cpt++)
{
OrderSendReliable(Symbol(),OP_BUYSTOP,LOTS,InitialPrice+cpt*INCREMENT*Point,2,SellGoal,BuyGoal,DoubleToStr(InitialPrice,MarketInfo(Symbol(),MODE_DIGITS)),MAGIC,0);
OrderSendReliable(Symbol(),OP_SELLSTOP,LOTS,InitialPrice-cpt*INCREMENT*Point,2,BuyGoal+spread*Point,SellGoal+spread*Point,DoubleToStr(InitialPrice,MarketInfo(Symbol(),MODE_DIGITS)),MAGIC,0);
}
} // initial setup done - all channels are set up
else // We have open Orders
{
BuyGoal=InitialPrice+INCREMENT*(LEVELS+1)*Point;
SellGoal=InitialPrice-INCREMENT*(LEVELS+1)*Point;
total=OrdersHistoryTotal();
for(cpt=0;cpt<total;cpt++)
{
OrderSelect(cpt,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC && StrToDouble(OrderComment())==InitialPrice){EndSession();return(0);}
}
if(UseProfitTarget && CheckProfits(LOTS,OP_SELL,true,InitialPrice)>ProfitTarget) {EndSession();return(0);}
BuyGoalProfit=CheckProfits(LOTS,OP_BUY,false,InitialPrice);
SellGoalProfit=CheckProfits(LOTS,OP_SELL,false,InitialPrice);
if(BuyGoalProfit<ProfitTarget)
{
for(cpt=LEVELS;cpt>=1 && BuyGoalProfit<ProfitTarget;cpt--)
{
if(Ask<=(InitialPrice+(cpt*INCREMENT-MarketInfo(Symbol(),MODE_STOPLEVEL))*Point))
{
ticket=OrderSendReliable(Symbol(),OP_BUYSTOP,cpt*LOTS,InitialPrice+cpt*INCREMENT*Point,2,SellGoal,BuyGoal,DoubleToStr(InitialPrice,MarketInfo(Symbol(),MODE_DIGITS)),MAGIC,0);
}
if(ticket>0) BuyGoalProfit+=LOTS*(BuyGoal-InitialPrice-cpt*INCREMENT*Point)/Point;
}
}
if(SellGoalProfit<ProfitTarget)
{
for(cpt=LEVELS;cpt>=1 && SellGoalProfit<ProfitTarget;cpt--)
{
if(Bid>=(InitialPrice-(cpt*INCREMENT-MarketInfo(Symbol(),MODE_STOPLEVEL))*Point))
{
ticket=OrderSendReliable(Symbol(),OP_SELLSTOP,cpt*LOTS,InitialPrice-cpt*INCREMENT*Point,2,BuyGoal+spread*Point,SellGoal+spread*Point,DouПоказано первые 50% кода (символов: 6398)
Введите ваш email и нажмите кнопку, чтобы перейти к оплате.