Скачать MetaTrader 5
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий
Интересуют возможности MQL5? Загляни в документацию!
Dmitiry Ananiev
6330
Dmitiry Ananiev 2014.04.27 20:48 

накидайте кто нибудь какие примерно классы нужны для автооптимизации с одним параметром средствами MQL4++. т.е. интересует описание, а не сам код. Если код - то очень примерный, чтоб понять смысл.

И примерную схему как они должны между собой взаимодействовать.

Цель - изучить ООП и применять в дальнейшем эти наработки.

Как это будет выглядеть без ООП я примерно представляю, но опыта писать такие сложные задачи нет. Думаю с ООП будет полегче. Вот только перестроиться на ООП мозгами не получается.

Vladimir Pastushak
58678
Vladimir Pastushak 2014.04.28 06:01  
Dmitiry Ananiev
6330
Dmitiry Ananiev 2014.04.28 13:14  

Я с трудом представляю архитектуру такого оптимизатора.

кто-то поопытней пусть распишут примерный алгоритм и взаимодествие классов в таком оптимизаторе.

Dmitiry Ananiev
6330
Dmitiry Ananiev 2014.04.29 02:29  

вообщем набросал я что-то, но ка кто ни так работает.

extern          double typspread = 0.00005; //типичный спред, пример 0.00005
extern          double comission = 0.00006; // учет комиссии, пример 0.00006
#define Per  20 

class COptim
{       
        public:
                int ChannelPeriod;
                double profit;
                
                void SetChannelPeriod (int x)
                {
                        ChannelPeriod = x;
                }
                
                void Setprofit()
                {
                        profit = 0;
                }
        
        void Tick()
        
        {       
                for (int i=1; i<=20; i++)
                        {
                                O_Bid = Open[i];
                                if (Close[i]> Open[i])                          //свеча бычья
                                
                                        { while (O_Bid>=Low[i])
                                                {
                                                        Count(h,l,i);
                                                        if (O_Bid>=h) {O_CloseBuy();O_Sell();}
                                                        if (O_Bid<=l) {O_CloseSell(); O_Buy();}
                                                        O_Bid-=Point;
                                                }
                                                
                                                while (O_Bid<=High[i])
                                                {
                                                        Count(h,l,i);
                                                        if (O_Bid>=h) {O_CloseBuy();O_Sell();}
                                                        if (O_Bid<=l) {O_CloseSell(); O_Buy();}
                                                        O_Bid+=Point;
                                                }
                                                
                                                while (O_Bid>=Close[i])
                                                {
                                                        Count(h,l,i);
                                                        if (O_Bid>=h) {O_CloseBuy();O_Sell();}
                                                        if (O_Bid<=l) {O_CloseSell(); O_Buy();}
                                                        O_Bid-=Point;
                                                }
                                        }
                                        
                                if (Close[i]<=Open[i])                  //свеча медвежья
                                        {
                                                while (O_Bid<=High[i])
                                                {
                                                        Count(h,l,i);
                                                        if (O_Bid>=h) {O_CloseBuy();O_Sell();}
                                                        if (O_Bid<=l) {O_CloseSell(); O_Buy();}
                                                        O_Bid+=Point;
                                                }
                                                
                                                while (O_Bid>=Low[i])
                                                {
                                                        Count(h,l,i);
                                                        if (O_Bid>=h) {O_CloseBuy();O_Sell();}
                                                        if (O_Bid<=l) {O_CloseSell(); O_Buy();}
                                                        O_Bid-=Point;
                                                }
                                                
                                                while (O_Bid<=Close[i])
                                                {
                                                        Count(h,l,i);
                                                        if (O_Bid>=h) {O_CloseBuy();O_Sell();}
                                                        if (O_Bid<=l) {O_CloseSell(); O_Buy();}
                                                        O_Bid+=Point;
                                                }
                                        }
                                }
        }
        
        
        int position;
        double O_Bid;
        double openprice;
        double h,l;
                
        void O_Buy()
        {
                if (position > 0) return;
                position = 1;
                openprice = O_Bid+typspread+comission;
                return;
        }
        
        void O_Sell()
        {
                if (position <0) return;
                position = -1;
                openprice = O_Bid+comission;
                return;
        }
        
        void O_CloseSell ()
        {
                if (position >= 0) return;
                position = 0;
                profit += openprice - (O_Bid+typspread);
                return;
        }
        
        void O_CloseBuy ()
        {
                if (position <= 0) return;
                position = 0;
                profit += O_Bid - openprice;
                return;
        }


void Count (double &h, double &l, int i)
        {
                double CHh=High[iHighest(NULL,0,MODE_HIGH,ChannelPeriod+i,i)];
           double CHl=Low[iLowest(NULL,0,MODE_LOW,ChannelPeriod+i,i)];
           
           double d=(CHh-CHl)/2.0;
           double h1l1=(CHh+CHl)/2.0;
           
           h = h1l1 + d*0.9;
           l = h1l1 - d*0.9;
        }

};

double pr[Per];
int CH;

#include <mytrade.mqh>

void OnTick()
{       
        
        COptim op;
        
        
        for (int x=0; x<=200;x++)
        {       
                op.Setprofit();
                op.SetChannelPeriod(x);
                op.Tick();
                pr[x] = op.profit;
                
        }
         
        
        CH = ArrayMaximum(pr,Per,0);
        
        
        double CHh=High[iHighest(NULL,0,MODE_HIGH,CH,0)];
   double CHl=Low[iLowest(NULL,0,MODE_LOW,CH,0)];
        
        double d=(CHh-CHl)*0.9/2.0;
   double h1l1=(CHh+CHl)/2.0;
   
   double h= h1l1+d;
   double l= h1l1-d;
   if(Bid>=h)                                                CloseBuy(h);
   if(Bid>=h )                                               Sell(h);

   if(Bid<=l)                                                CloseSell(l);
   if(Bid<=l)                                                Buy(l);
   
   Graf(h,l);
        
}

просьба к профессионалам - помогите разобраться, что не так.

Идея такова - торговля по самооптимизируему каналу Дончиана.

/
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий