//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#property link "http://forexbig.ru"
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//+------------------------------------------------------------------+
//| On Balance Volume.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int ExtOBVAppliedPrice=0;
extern int UP=13400000;
extern int DN=9100000;
//---- buffers
double ExtOBVBuffer[];
double up=0,dn=0;
bool b=true,s=true;
datetime t=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string sShortName;
//---- indicator buffer mapping
SetIndexBuffer(0,ExtOBVBuffer);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
//---- sets default precision format for indicators visualization
IndicatorDigits(0);
//---- name for DataWindow and indicator subwindow label
sShortName="777";
IndicatorShortName(sShortName);
SetIndexLabel(0,sShortName);
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutArrow(string name,double price,int arrow_code,color clr)
{
ObjectDelete(name);
//--- создадим стрелку
ObjectCreate(0,name,OBJ_ARROW,0,Time[0],price);
//--- установим код стрелки
ObjectSetInteger(0,name,OBJPROP_ARROWCODE,arrow_code);
//--- установим цвет стрелки
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим размер стрелки
ObjectSetInteger(0,name,OBJPROP_WIDTH,2);
}
//+------------------------------------------------------------------+
//| On Balance Volume |
//+------------------------------------------------------------------+
int start()
{
int i,nLimit,nCountedBars;
//---- bars count that does not changed after last indicator launch.
nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted
if(nCountedBars>0) nCountedBars--;
nLimit=Bars-nCountedBars-1;
//----
for(i=nLimit; i>=0; i--)
{
if(i==Bars-1)
ExtOBVBuffer[i]=Volume[i];
else
{
double dCurrentPrice=GetAppliedPrice(ExtOBVAppliedPrice,i);
double dPreviousPrice=GetAppliedPrice(ExtOBVAppliedPrice,i+1);
if(dCurrentPrice==dPreviousPrice)
ExtOBVBuffer[i]=ExtOBVBuffer[i+1];
else
{
if(dCurrentPrice<dPreviousPrice)
ExtOBVBuffer[i]=ExtOBVBuffer[i+1]-Bars;
else
ExtOBVBuffer[i]=ExtOBVBuffer[i+1]+Bars;
}
}
}
if(t!=Time[0])
{
if(ExtOBVBuffer[1]<UP && ExtOBVBuffer[2]>UP)
{
up++;
if(up>2 && s)
{
Alert(Symbol()+" Sell!!!");
PutArrow("SELL"+(string)Time[0],High[0],234,Red);
s=false;
b=true;
dn=0;
}
}
if(ExtOBVBuffer[1]>DN && ExtOBVBuffer[2]<DN)
{
dn++;
if(dn>2 && b)
{
Alert(Symbol()+" Buy!!!");
PutArrow("Buy"+(string)Time[0],Low[0],233,Blue);
b=false;
s=true;
up=0;
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double GetAppliedPrice(int nAppliedPrice,int nIndex)
{
double dPrice;
//----
switch(nAppliedPrice)
{
case 0: dPrice=Close[nIndex]; break;
case 1: dPrice=Open[nIndex]; break;
case 2: dPrice=High[nIndex]; break;
case 3: dPrice=Low[nIndex]; break;
case 4: dPrice=(High[nIndex]+Low[nIndex])/2.0; break;
case 5: dPrice=(High[nIndex]+Low[nIndex]+Close[nIndex])/3.0; break;
case 6: dPrice=(High[nIndex]+Low[nIndex]+Close[nIndex])/4.0; break;
default: dPrice=0.0;
}
//----
return(dPrice);
}
//+----------------------------------------------------------
//+------------------------------------------------------------------+
//| MarketStopSell.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
extern double Lots = 0.1; // торговый объем
extern int StopLoss = 350; // стоп лосс ордера
extern int TakeProfit = 90; // тейк профит ордера
extern int Step = 100; // шаг между ордерами
extern int Slip = 30; // проскальзывание
extern int Magic = 123; // магик
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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;
}
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
PutOrder(1,Bid);
PutOrder(4,Bid+Step*Point);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Igrun.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 Risk = 10; // риск
extern double Loss = 3000; // лось в рублях
extern double Profit = 20; // язь в рублях
extern int StopLoss = 0; // лось
extern int TakeProfit = 0; // язь
extern int Delta = 90; // размер свечи
extern int Slip = 30; // реквот
extern int Magic = 123; // магик
datetime t=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
}
//+------------------------------------------------------------------+
//| Установка ордера |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
{
int r=0,err=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,Lot(),NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| Лот для усреднителя |
//+------------------------------------------------------------------+
double Lot()
{
double lot=Lots;
double MinimumLot = MarketInfo(NULL,MODE_MINLOT);
double MaximumLot = MarketInfo(NULL,MODE_MAXLOT);
if(Risk>0) lot=AccountEquity()*Risk/100000;// 10000*10/100000=1
if(lot<MinimumLot) lot=MinimumLot;
if(lot>MaximumLot) lot=MaximumLot;
return(lot);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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);
}
//+------------------------------------------------------------------+
//| Профит всех ордеров по типу ордера |
//+------------------------------------------------------------------+
double AllProfit(int ot=-1)
{
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()==0 && (ot==0 || ot==-1))
{
pr+=OrderProfit()+OrderCommission()+OrderSwap();
}
if(OrderType()==1 && (ot==1 || ot==-1))
{
pr+=OrderProfit()+OrderCommission()+OrderSwap();
}
}
}
}
return(pr);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OpenOrd()
{
double delta=Close[1]-Open[1];
if(delta<0 && delta<-Delta*Point)
{
PutOrder(1,Bid);
}
if(delta>0 && delta>Delta*Point)
{
PutOrder(0,Ask);
}
}
//+------------------------------------------------------------------+
//| Закрытие позиции по типу ордера |
//+------------------------------------------------------------------+
void CloseAll(int ot=-1)
{
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()==0 && (ot==0 || ot==-1))
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slip,White);
}
if(OrderType()==1 && (ot==1 || ot==-1))
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slip,White);
}
}
}
}
}
//+------------------------------------------------------------------+
//| Подсчет ордеров по типу |
//+------------------------------------------------------------------+
int CountOrders(int type)
{
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()==type) count++;
}
}
}
return(count);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(t!=Time[0])
{
OpenOrd();
//if(AllProfit(0)>Profit) CloseAll(0);
//if(AllProfit(1)>Profit) CloseAll(1);
if(AllProfit()>Profit || AllProfit()<-Loss) CloseAll();
t=Time[0];
}
Comment("\n Открыто Buy ",CountOrders(0),
"\n Открыто Sell ",CountOrders(1),
"\n Общий профит: ",AllProfit(),
"\n Профит по Buy: ",AllProfit(0),
"\n Профит по Sell: ",AllProfit(1));
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool OneDayTrade()
{
if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderType()<2)
{
if(TimeDay(OrderOpenTime())==Day()) return(true);
}
}
return(false);
}
//+------------------------------------------------------------------+
//| TimeOrder.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 KLot = 2; // умножение лота
extern double MaxLot = 5; // максимальный лот
extern int StopLoss = 5000; // лось
extern int TakeProfit = 5000; // язь
extern int TrailingStop = 0; // трал
extern string StartTime = "3:00"; // время начала торговли
extern int Slip = 30; // слипаж
extern int BuySell = 0; // 0-buy 1-sell
extern int Magic = 20; // магик
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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,Lot(),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);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot()
{
double lot=Lots;
if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderProfit()<0)
{
lot=OrderLots()*KLot;
}
}
if(lot>MaxLot)lot=Lots;
return(lot);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool OneDayTrade()
{
if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderType()<2)
{
if(TimeDay(OrderCloseTime())==Day()) return(true);
}
}
return(false);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void Trailing()
{
bool mod;
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)
{
if(Bid-OrderOpenPrice()>TrailingStop*Point)
{
if(OrderStopLoss()<Bid-TrailingStop*Point)
{
mod=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Yellow);
return;
}
}
}
if(OrderType()==OP_SELL)
{
if((OrderOpenPrice()-Ask)>TrailingStop*Point)
{
if((OrderStopLoss()>(Ask+TrailingStop*Point)) || (OrderStopLoss()==0))
{
mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,Yellow);
return;
}
}
}
}
}
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(TrailingStop>0) Trailing();
if(CountTrades()<1 && TimeCurrent()>StringToTime(StartTime) && !OneDayTrade())
{
if(BuySell==0) PutOrder(0,Ask);
if(BuySell==1) PutOrder(1,Bid);
}
}
//+------------------------------------------------------------------+
Но мартин это все равно слив, я думаю отрицать никто не будет.
AM2