//+------------------------------------------------------------------+ //| Donchian.mq4 | //| Andrei Andreev | //| http://www.andand.ru | //+------------------------------------------------------------------+ // BASED ON: //+------------------------------------------------------------------+ //| ^X_Sensors.mq4 | //| Version 2.0.1 | //|------------------------------------------------------------------| //| Copyright © 2007, Mr.WT, Senior Linux Hacker | //| http://w-tiger.narod.ru/wk2/ | //+------------------------------------------------------------------+ #property copyright "Andrei Andreev" #property link "http://www.andand.ru" #property indicator_chart_window extern int ForDays=10; int _N_Time,ObjectId; string OBJECT_PREFIX="LEVELS"; int _My_Period=PERIOD_D1; //------------------------------------------------------------------------------------------- int init() { _N_Time=0; return(0); } //------------------------------------------------------------------------------------------- int deinit() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //if ( _N_Time == Time[0] ) return(0); int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars; if(counted_bars==0) limit-=1+ForDays+1; double _rates[][6]; double open,close,high,low; double AverageRange; ArrayCopyRates(_rates,NULL,_My_Period); int err= GetLastError(); if(err == 4066) { Sleep(1000); if(iClose(NULL,_My_Period,0)!=Close[0]) { Sleep(1000); return(0); } } close= _rates[1][4]; high = _rates[0][3]; low=_rates[0][2]; open=_rates[0][1]; AverageRange=0; for(int i=1;i0) { ProfitableDeals=ProfitableDeals+1; } } return(ProfitableDeals); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double ProfitableDealsAmount() { int cnt,ticket,total; double Amount=0; total=OrdersTotal(); for(cnt=0;cnt0) { Amount=Amount+(OrderProfit()+OrderSwap()); } } return(Amount); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double LoosingDealsAmount() { int cnt,ticket,total; double Amount=0; total=OrdersTotal(); for(cnt=0;cnt