
extern double Lot=0.0;
extern int MaxRisk=2;
extern bool TakeProfit=FALSE;
extern int NoLoss= 0;
extern int Trall = 0;
extern bool DivLot=TRUE;
extern bool OneOrderDay=FALSE;
extern int ShiftTime=1;
extern int ExtFormula=0;
string Gs_pivot_116="Pivot";
bool Gi_124=TRUE;
int G_day_128=0;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
double icustom_0=iCustom(NULL,0,"DailyPivot_Ind2",ShiftTime,ExtFormula,0,0);
if(ObjectFind("R0.5_Line")<0 || ObjectFind("S0.5_Line")<0 || ObjectFind("R1.0_Line")<0 || ObjectFind("S1.0_Line")<0 || ObjectFind("R2.0_Line")<0 || ObjectFind("S2.0_Line")<0)
{
Alert("Не найден индикатор: DailyPivot_Ind2");
Gi_124=FALSE;
}
return (0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
return (0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double Ld_84;
double Ld_92;
double Ld_100;
if(!Gi_124)
{
Comment("Ошибка в параметрах! Советник остановлен.");
return (0);
}
if(DayOfWeek() == 0 || DayOfWeek() == 6) return (0);
if(!IsTradeAllowed()) return (0);
Comment("http://strategy4you.ru");
double icustom_0=iCustom(NULL,0,"DailyPivot_Ind2",ShiftTime,ExtFormula,0,0);
double Ld_8=NormalizeDouble(Ask,Digits);
double Ld_16 = NormalizeDouble(Bid, Digits);
double Ld_24 = ObjectGet("R0.5_Line", OBJPROP_PRICE1);
double Ld_32 = ObjectGet("S0.5_Line", OBJPROP_PRICE1);
double Ld_40 = ObjectGet("R1.0_Line", OBJPROP_PRICE1);
double Ld_48 = ObjectGet("S1.0_Line", OBJPROP_PRICE1);
double Ld_56 = ObjectGet("R2.0_Line", OBJPROP_PRICE1);
double Ld_64 = ObjectGet("S2.0_Line", OBJPROP_PRICE1);
int count_72 = 0;
int count_76 = 0;
for(int pos_80 = 0; pos_80 < OrdersTotal(); pos_80++)
{
if(OrderSelect(pos_80,SELECT_BY_POS, MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==20100321)
{
if(OrderType()==OP_BUY)
{
if(NoLoss<0)
{
if(Ld_16>Ld_40 && OrderStopLoss()<OrderOpenPrice())
{
EditOrder(OrderOpenPrice(),OrderTakeProfit(),OrderOpenPrice()+Point);
if(DivLot) CloseOrder(OrderLots()/2.0);
}
}
if(NoLoss>0)
{
if(Ld_16>OrderOpenPrice()+NoLoss*Point)
{
EditOrder(OrderOpenPrice(),OrderTakeProfit(),OrderOpenPrice()+Point);
if(DivLot) CloseOrder(OrderLots()/2.0);
}
}
if(Trall>0)
{
if(Ld_16-OrderOpenPrice()>Trall*Point)
if(OrderStopLoss()<Ld_16 -(Trall+2)*Point) EditOrder(OrderOpenPrice(),OrderTakeProfit(),Ld_16-Trall*Point);
}
G_day_128=TimeDay(OrderOpenTime());
count_72++;
}
if(OrderType()==OP_SELL)
{
if(NoLoss<0)
{
if(Ld_8<Ld_48 && OrderStopLoss()>OrderOpenPrice())
{
EditOrder(OrderOpenPrice(),OrderTakeProfit(),OrderOpenPrice()-Point);
if(DivLot) CloseOrder(OrderLots()/2.0);
}
}
if(NoLoss>0)
{
if(Ld_8<OrderOpenPrice()-NoLoss*Point)
{
EditOrder(OrderOpenPrice(),OrderTakeProfit(),OrderOpenPrice()-Point);
if(DivLot) CloseOrder(OrderLots()/2.0);
}
}
if(Trall>0)
{
if(OrderOpenPrice()-Ld_8>Trall*Point)
if(OrderStopLoss()>Ld_8+(Trall+2)*Point || OrderStopLoss()==0.0) EditOrder(OrderOpenPrice(),OrderTakeProfit(),Ld_8+Trall*Point);
}
G_day_128=TimeDay(OrderOpenTime());
count_76++;
}
}
}
}
if(OneOrderDay && G_day_128 == TimeDay(TimeCurrent())) return (0);
if(count_72+count_76==0 && Open[0]<Ld_24 && Open[0]>Ld_32)
{
Ld_84=GetOptimalLot(MaxRisk,Lot);
if(Ld_84==0.0)
{
Alert("Недостаточно средств для торговли!");
return (0);
}
Ld_92=Ld_40;
if(TakeProfit) Ld_92=Ld_56;
Ld_100=Ld_48;
if(TakeProfit) Ld_100=Ld_64;
if(Ld_8>Ld_24 && Ld_8<Ld_24+5.0*Point) NewOrder(OP_BUY,Ld_84,Ld_8,Ld_92,Ld_32);
if(Ld_16<Ld_32 && Ld_16>Ld_32-5.0*Point) NewOrder(OP_SELL,Ld_84,Ld_16,Ld_100,Ld_24);
}
return (0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double GetOptimalLot(int Ai_0,double Ad_4)
{
double Ld_12=Ad_4;
double free_magrin_20=AccountFreeMargin();
double marginrequired_28=MarketInfo(Symbol(),MODE_MARGINREQUIRED);
double lotstep_36=MarketInfo(Symbol(),MODE_LOTSTEP);
double Ld_44 = MarketInfo(Symbol(), MODE_MINLOT);
double Ld_52 = MarketInfo(Symbol(), MODE_MAXLOT);
if(Ad_4==0.0) Ld_12=free_magrin_20*Ai_0/100.0/marginrequired_28;
if(Ld_12 < Ld_44) Ld_12 = Ld_44;
if(Ld_12 > Ld_52) Ld_12 = Ld_52;
if(Ld_12 * marginrequired_28 > free_magrin_20) return (0.0);
return (MathFloor(Ld_12 / lotstep_36) * lotstep_36);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int NewOrder(int A_cmd_0,double A_lots_4,double A_price_12,double A_price_20=0.0,double A_price_28=0.0)
{
int ticket_36=0;
for(int count_40=0; count_40<3; count_40++)
{
while(!IsTradeAllowed()) Sleep(100);
ticket_36=OrderSend(Symbol(),A_cmd_0,A_lots_4,A_price_12,3,A_price_28,A_price_20,Gs_pivot_116,20100321,0,CLR_NONE);
if(ticket_36>0) break;
while(!IsTradeAllowed()) Sleep(100);
ticket_36=OrderSend(Symbol(),A_cmd_0,A_lots_4,A_price_12,3,0,0,Gs_pivot_116,20100321,0,CLR_NONE);
if(ticket_36>0)
{
if(OrderSelect(ticket_36,SELECT_BY_TICKET))
{
EditOrder(A_price_12,A_price_20,A_price_28);
break;
}
}
Print("#",ticket_36," Error: ",GetLastError()," Function: NewOrder(",A_cmd_0,",",A_lots_4,",",A_price_12,",",A_price_20,",",A_price_28,") №",count_40);
Sleep(1000);
}
return (ticket_36);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void EditOrder(double A_price_0,double A_price_8,double A_price_16)
{
for(int count_24=0; count_24<3; count_24++)
{
while(!IsTradeAllowed()) Sleep(100);
if(OrderModify(OrderTicket(),A_price_0,A_price_16,A_price_8,0,CLR_NONE)) break;
Print("#",OrderTicket()," Error: ",GetLastError()," Function: EditOrder(",A_price_0,",",A_price_8,",",A_price_16,") №",count_24);
Sleep(1000);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CloseOrder(double Ad_0=0.0)
{
double price_8= 0;
double ask_16 = 0;
double bid_24 = 0;
double lots_32= 0;
double lotstep_40=MarketInfo(Symbol(),MODE_LOTSTEP);
for(int count_48=0; count_48<3; count_48++)
{
while(!IsTradeAllowed()) Sleep(100);
ask_16 = MarketInfo(Symbol(), MODE_ASK);
bid_24 = MarketInfo(Symbol(), MODE_BID);
if(OrderType() == OP_BUY) price_8 = NormalizeDouble(bid_24, Digits);
if(OrderType() == OP_SELL) price_8 = NormalizeDouble(ask_16, Digits);
if(Ad_0==0.0) lots_32=OrderLots();
else lots_32=MathFloor(Ad_0/lotstep_40)*lotstep_40;
if(OrderClose(OrderTicket(),lots_32,price_8,3,CLR_NONE)) break;
Print("#",OrderTicket()," Error: ",GetLastError()," Function: CloseOrder(",Ad_0,") №",count_48);
Sleep(1000);
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Sigma.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // лот
extern double Profit = 0.1; // общий язь в валюте
extern double BuyProfit = 0; // язь по баям
extern double SellProfit = 0; // язь по селам
extern int StopLoss = 0; // лось
extern int TakeProfit = 0; // язь
extern int Slip = 30; // реквот
extern int Magic = 123; // магик
datetime t=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Comment("");
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=Green;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
if(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
}
r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades()
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()<2) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CloseType(int type)
{
bool cl;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY && type==0)
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slip,White);
}
if(OrderType()==OP_SELL && type==1)
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slip,White);
}
}
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double ProfitType(int type)
{
double pr=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==type)
{
pr+=OrderProfit()+OrderCommission()+OrderSwap();
}
}
}
}
return(pr);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(t!=Time[0])
{
if(Close[1]>Open[1])
{
PutOrder(0,Ask);
}
if(Close[1]<Open[1])
{
PutOrder(1,Bid);
}
t=Time[0];
}
//кроем все
if(Profit>0 && ProfitType(0)+ProfitType(1)>Profit)
{
CloseType(0);
CloseType(1);
}
//кроем баи
if(BuyProfit>0 && ProfitType(0)>BuyProfit) CloseType(0);
//кроем селы
if(SellProfit>0 && ProfitType(1)>SellProfit) CloseType(1);
Comment("\n All Profit: ",ProfitType(0)+ProfitType(1),
"\n Buy Profit: ",ProfitType(0),
"\n Sell Profit: ",ProfitType(1));
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| FapTurbo.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
//--- Inputs
extern double Lots = 0.1; // лот
extern int StopLoss = 1200; // лось
extern int TakeProfit = 50; // язь
extern int Slip = 30; // реквот
extern int MAPeriod = 5; // период МА
extern int BarsClose = 10; // время жизни позиции в барах
extern int Magic = 123; // магик
extern string Start = "21:00"; // старт
extern string End = "23:50"; // конец торговли
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Comment("");
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0;
color clr=Green;
double sl=0,tp=0;
if(type==1 || type==3 || type==5)
{
clr=Red;
if(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
}
r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int CountTrades()
{
int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()<2) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CloseAll()
{
bool cl;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY)
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slip,White);
}
if(OrderType()==OP_SELL)
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slip,White);
}
}
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
datetime OrderOpen()
{
datetime ot=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()<2) ot=OrderOpenTime();
}
}
}
return(ot);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double ma=iMA(NULL,0,MAPeriod,0,0,0,1);
if(TimeCurrent()>=StringToTime(Start) && TimeCurrent()<=StringToTime(End))
{
if(CountTrades()<1 && DayOfWeek()!=5)
{
if(Ask>ma)
{
PutOrder(0,Ask);
}
if(Bid<ma)
{
PutOrder(1,Bid);
}
}
}
if(CountTrades()>0 && TimeCurrent()-OrderOpen()>BarsClose*PeriodSeconds()) CloseAll();
Comment("\n Time: ",TimeCurrent());
}
//+------------------------------------------------------------------+
ERR_INVALID_PRICE 129 Неправильная цена
А вообше я пока не понял как он открывает, он открывает то по тренду то против.
AM2