Что-то, не так вышло:
В советнике несколько модификаций стопов. Они конфликтуют друг с другом. Нужно оставлять что то одно.
Что-то, не так вышло:
close[0]-iMA(NULL,0,MAPeriod,0,MODE_SMA,PRICE_CLOSE,0)
//+------------------------------------------------------------------+
//| TickIndicator.mq4 |
//| Copyright 2015, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Lime
input int MAPeriod = 12;
double IndBuf[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(0,IndBuf);
//---
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[])
{
//---
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars>0) counted_bars--;
limit=counted_bars;
for(int i=limit; i>=0; i--)
{
IndBuf[i+1]=IndBuf[i];
}
IndBuf[0]=close[0]-iMA(NULL,0,MAPeriod,0,MODE_SMA,PRICE_CLOSE,0);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| TimeClose.mq4 |
//| Copyright 2015, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
extern int Minutes = 10;
datetime StartTime;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
StartTime=TimeCurrent();
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
void CloseAll()
{
bool cl,sel;
for(int i=OrdersTotal()-1;i>=0;i--)
{
sel=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY) cl=OrderClose(OrderTicket(),OrderLots(),Bid,30,Blue);
if(OrderType()==OP_SELL) cl=OrderClose(OrderTicket(),OrderLots(),Ask,30,Red);
}
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
Comment("\n Current Time: ",TimeCurrent(),
"\n Start Time: ",StartTime,
"\n Seconds Timer: ",TimeToString(TimeCurrent()-StartTime,TIME_SECONDS),
"\n Minutes Timer: ",TimeToString(TimeCurrent()-StartTime,TIME_MINUTES),
"\n Int Timer: ",(int)(TimeCurrent()-StartTime));
if(TimeCurrent()-StartTime>=Minutes*60) CloseAll();
}
//+------------------------------------------------------------------+
AM2