FT_TIME_BIGDOG

Author: FORTRADER.RU, ����, ftyuriy@gmail.com
Price Data Components
Series array that contains open time of each bar
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites
FT_TIME_BIGDOG
//+------------------------------------------------------------------+
//|                                               FT_TIME_BIGDOG.mq4 |
//|                            FORTRADER.RU, Þðèé, ftyuriy@gmail.com |
//|               http://www.fortrader.ru, Âðåìÿ + êàíàëû + òðåéëèíã |
//+------------------------------------------------------------------+
#property copyright "FORTRADER.RU, Þðèé, ftyuriy@gmail.com"
#property link      "http://FORTRADER.RU, TIME"
/*Ðàçðàáîòàíî äëÿ 52 âûïóñêà æóðíàëà FORTRADER.Ru. Ñèñòåìà ïî ñòðàòåãèè áîëüøàÿ ñîáàêà. 
Îáñóæäåíèå: http://forexsystems.ru/torgovaia-strategiia-big-dog-t8929.html?t=8929
Àðõèâ æóðíàëà: http://www.fortrader.ru/arhiv.php
52 âûïóñê: http://www.fortrader.ru/
*/

extern int starttime = 14; 
extern int stoptime  = 16; 
extern int maxpoint  = 50; 

extern int TP=50;

extern int mn=1;

extern double Lots=0.1;

extern int orderlimit=20;

int start()
  {
   OpenPattern();
   return(0);
  }

int day,buy,sell,stop;  
int OpenPattern()
{double op,sl,tp;int err;


   //Åñëè íîâûé äåíü òî óäàëÿåì îðäåðà.
   if(day!=DayOfWeek()){_DeleteOrder(1);_DeleteOrder(0);}
   
   double high= GetHighLow_Time(starttime,stoptime,0);
   double low = GetHighLow_Time(starttime,stoptime,1);
   
   if(OrdersTotal()<1){buy=0;sell=0;stop=0;}
   
   if(MathAbs(high-low)<maxpoint*Point*mn && StrToInteger(TimeToStr(Time[1],TIME_MINUTES))>=stoptime && stop==0)
   {stop=1;
      if(sell==0 && (high-Ask)>orderlimit*Point*mn)
      {day=DayOfWeek();sell=1;
      op=high;  sl=low;tp=high+TP*Point*mn;
      err=OrderSend(Symbol(),OP_BUYSTOP,Lots,NormalizeDouble(op,Digits),3,sl,tp,"FORTRADER.RU",0,0,Red);
      if(err<0){Print("FT_TIME_BIGDOG()-  Îøèáêà óñòàíîâêè îòëîæåííûõ îðäåðîâ OP_SELLLIMIT.  op "+op+" sl "+sl+" tp "+tp+" "+GetLastError());return(-1);}
      }
      
      if(buy==0 && (Bid-low)>orderlimit*Point*mn)
      {day=DayOfWeek();buy=1;
      op=low;  sl=high;  tp=low-TP*Point*mn;
      err=OrderSend(Symbol(),OP_SELLSTOP,Lots,NormalizeDouble(op,Digits),3,sl,tp,"FORTRADER.RU",0,0,Red);
      if(err<0){Print("FT_TIME_BIGDOG()-  Îøèáêà óñòàíîâêè îòëîæåííûõ îðäåðîâ OP_BUYLIMIT.  op "+op+" sl "+sl+" tp "+tp+" "+GetLastError());return(-1);}
      }
   }
return(0);
}

//óäàëÿåò îòëîæåííûå ñòîï îðäåðà
int _DeleteOrder(int type)
{
   for( int i=1; i<=OrdersTotal(); i++)          
   {
    if(OrderSelect(i-1,SELECT_BY_POS)==true) 
    {                                       
     if(OrderType()==OP_SELLSTOP && OrderSymbol()==Symbol() && type==0)
     {
      OrderDelete(OrderTicket()); 
     }//if
  
    if(OrderType()==OP_BUYSTOP && OrderSymbol()==Symbol() && type==1)
     {
      OrderDelete(OrderTicket()); 
     }//if
    }//if
   }
   return(0);
}  

double GetHighLow_Time(int starttime,int stoptime, int type)
{double ret;int i;

if(type==0)
{
   if(StrToInteger(TimeToStr(Time[1],TIME_MINUTES))>=stoptime)
   {
      for( i=0;i<200;i++)
      {
         if(StrToInteger(TimeToStr(iTime(Symbol(),Period(),i),TIME_MINUTES))<=stoptime)
         {
            if(High[i]>ret)
            {ret=High[i];}
            if(StrToInteger(TimeToStr(iTime(Symbol(),Period(),i),TIME_MINUTES))<=starttime)
            {return(ret);}
         }
      }    
   }
}

if(type==1)
{
   if(StrToInteger(TimeToStr(Time[1],TIME_MINUTES))>=stoptime)
   {
      for( i=0;i<200;i++)
      {
         if(StrToInteger(TimeToStr(iTime(Symbol(),Period(),i),TIME_MINUTES))<=stoptime)
         {
            if(Low[i]<ret || ret==0){ret=Low[i];}
            if(StrToInteger(TimeToStr(iTime(Symbol(),Period(),i),TIME_MINUTES))<=starttime){return(ret);}
         }
      }    
   }
}

return(ret);
}

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---