
mql.opentraders.ru/25021.html
И даже на вашей фотке не то. Линии ведь не должны быть выше цены таким странным образом.
extern string IndName = "30pips"; //
double pips1=iCustom(NULL,0,IndName,N,0,1);
double pips2=iCustom(NULL,0,IndName,N,0,2);
Сделать надо будет простую вещь
//+------------------------------------------------------------------+
//| Pips.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 double MaxLot = 5; // аксимальный торговый объем
extern double KLot = 2; // увеличение лота
extern double KStep = 2; // увеличение шага
extern int StopLoss = 190; // стоп лосс ордера
extern int TakeProfit = 50; // тейк профит ордера
extern int Step = 10; // шаг между ордерами
extern int MaxTrades = 20; // максимальное количество ордеров
extern int Slip = 3; // проскальзывание
extern int N = 36; // период индикатора 30Pips
extern int Magic = 123; // магик
extern string IndName = "30pips"; //
int ticket;
double tp,sl,price;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutOrder(int type,double pr)
{
int r=0;
color clr=Green;
if(type==1 || type==3 || type==5)
{
clr=Red;
if(StopLoss>0) sl=NormalizeDouble(pr+StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(pr-TakeProfit*Point,Digits);
}
if(type==0 || type==2 || type==4)
{
clr=Blue;
if(StopLoss>0) sl=NormalizeDouble(pr-StopLoss*Point,Digits);
if(TakeProfit>0) tp=NormalizeDouble(pr+TakeProfit*Point,Digits);
}
r=OrderSend(NULL,type,Lot(),NormalizeDouble(pr,Digits),Slip,sl,tp,"",Magic,0,clr);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void ModifyOrders()
{
double all=0;
double 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()==OP_BUY || OrderType()==OP_SELL)
{
all+=OrderOpenPrice()*OrderLots();
count+=OrderLots();
}
}
}
}
if(count>0) all=NormalizeDouble(all/count,Digits);
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)
{
tp=NormalizeDouble(all+TakeProfit*Point,Digits);
sl=NormalizeDouble(all-StopLoss*Point,Digits);
if(OrderStopLoss()!=sl || OrderTakeProfit()!=tp)
bool mod=OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0,Yellow);
}
if(OrderType()==OP_SELL)
{
tp=NormalizeDouble(all-TakeProfit*Point,Digits);
sl=NormalizeDouble(all+StopLoss*Point,Digits);
if(OrderStopLoss()!=sl || OrderTakeProfit()!=tp)
bool mod=OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0,Yellow);
}
}
}
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int FindOrderType()
{
int oticket,ticketNumber=0,type=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
oticket=OrderTicket();
if(oticket>ticketNumber)
{
ticketNumber=oticket;
type=OrderType();
}
}
}
}
return(type);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double FindLastBuyPrice()
{
int oticket,ticketNumber=0;
double oprice=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_BUY)
{
oticket=OrderTicket();
if(oticket>ticketNumber)
{
ticketNumber=oticket;
oprice=OrderOpenPrice();
}
}
}
}
return(oprice);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double FindLastSellPrice()
{
int oticket,ticketNumber=0;
double oprice=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_SELL)
{
oticket=OrderTicket();
if(oticket>ticketNumber)
{
ticketNumber=oticket;
oprice=OrderOpenPrice();
}
}
}
}
return(oprice);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot()
{
double lot=Lots;
if(CountTrades()>0) lot=NormalizeDouble(Lots*MathPow(KLot,CountTrades()),2);
if(lot>MaxLot)lot=Lots;
return(lot);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Steps()
{
double step=0;
if(CountTrades()>0) step=NormalizeDouble(Step*MathPow(KStep,CountTrades()),0);
return(step);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
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);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double pips1=iCustom(NULL,0,IndName,N,0,1);
double pips2=iCustom(NULL,0,IndName,N,0,2);
ModifyOrders();
if(CountTrades()<1 && pips1<0)
{
PutOrder(0,Ask);
}
if(CountTrades()<1 && pips1>0)
{
PutOrder(1,Bid);
}
if(CountTrades()>0 && CountTrades()<=MaxTrades)
{
int otype=FindOrderType();
if(otype==OP_BUY)
{
price=FindLastBuyPrice();
if((price-Ask)/Point>=Steps())
{
PutOrder(0,Ask);
}
}
else if(otype==OP_SELL)
{
price=FindLastSellPrice();
if((Bid-price)/Point>=Steps())
{
PutOrder(1,Bid);
}
}
}
Comment("\n Lot: ",Lot(),
"\n Trades: ",CountTrades(),
"\n Step:",Steps());
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| BB.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
#property indicator_chart_window
input int BBPeriod1 = 20;
input int BBPeriod2 = 20;
input int BBPeriod3 = 20;
input int BBTF1 = 0;
input int BBTF2 = 30;
input int BBTF3 = 60;
input double BBDev = 2;
#property indicator_buffers 9
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_color5 Blue
#property indicator_color6 Lime
#property indicator_color7 Red
#property indicator_color8 Blue
#property indicator_color9 Lime
double up1[];
double up2[];
double up3[];
double dn1[];
double dn2[];
double dn3[];
double md1[];
double md2[];
double md3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//--- upper band
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,up1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,up2);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,up3);
/*--- lower ban*/
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,dn1);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,dn2);
SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(5,dn3);
//--- middle lined
SetIndexStyle(6,DRAW_LINE);
SetIndexBuffer(6,md1);
SetIndexStyle(7,DRAW_LINE);
SetIndexBuffer(7,md2);
SetIndexStyle(8,DRAW_LINE);
SetIndexBuffer(8,md3);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
for(int i=0; i<5555; i++)
{
up1[i]=iBands(NULL,BBTF1,BBPeriod1,BBDev,0,0,1,i);
dn1[i]=iBands(NULL,BBTF1,BBPeriod1,BBDev,0,0,2,i);
md1[i]=iBands(NULL,BBTF1,BBPeriod1,BBDev,0,0,0,i);
up2[i]=iBands(NULL,BBTF2,BBPeriod2,BBDev,0,0,1,i);
dn2[i]=iBands(NULL,BBTF2,BBPeriod2,BBDev,0,0,2,i);
md2[i]=iBands(NULL,BBTF2,BBPeriod2,BBDev,0,0,0,i);
up3[i]=iBands(NULL,BBTF3,BBPeriod3,BBDev,0,0,1,i);
dn3[i]=iBands(NULL,BBTF3,BBPeriod3,BBDev,0,0,2,i);
md3[i]=iBands(NULL,BBTF3,BBPeriod3,BBDev,0,0,0,i);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
// первая поза
if(Ask>ma+Points*Point && (BuySell==1 || BuySell==0))
{
if(CountTrades()<1) PutOrder(0,Ask);
}
if(Bid<ma-Points*Point && (BuySell==2 || BuySell==0))
{
if(CountTrades()<1) PutOrder(1,Bid);
}
AM2