Trading_Time_v1

Author: Copyright 2020, MrBrooklin
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
Trading_Time_v1
ÿþ//+------------------------------------------------------------------+

//|                                                 Trading_Time.mq5 |

//|                                       Copyright 2020, MrBrooklin |

//|                         https://www.mql5.com/ru/users/mrbrooklin |

//+------------------------------------------------------------------+

#property copyright   "Copyright 2020, MrBrooklin"

#property link        "https://www.mql5.com/ru/users/mrbrooklin"

#property description "$C=:F8O Trading Time (2@5<O B>@3>2;8) @50;87>20=0 2 2845"

#property description "<8:@>A>25B=8:0. > 2E>4=KE ?0@0<5B@0E =C6=> 7040BL 2@5<O"

#property description "=0G0;0 8 >:>=G0=8O @01>BK A>25B=8:0. =D>@<0F8O > 70?@5B5"

#property description "8;8 @07@5H5=88 B>@3>2;8 2K2>48BAO 2 2845 A>>1I5=8O 2 >:=5 ;5@B0."

#property version     "1.01"

/* $C=:F8O Trading Time (2@5<O B>@3>2;8) @50;87>20=0 2 2845 <8:@>A>25B=8:0.

   > 2E>4=KE ?0@0<5B@0E =C6=> 7040BL 2@5<O =0G0;0 8 >:>=G0=8O @01>BK A>25B=8:0.

   =D>@<0F8O > 70?@5B5 8;8 @07@5H5=88 B>@3>2;8 2K2>48BAO 2 2845 A>>1I5=8O 2 >:=5 ;5@B0.*/

//--- %+  " +

input ushort   Trading_Start=7; //0G0;> B>@3>2;8

input ushort   End_Of_Trade=19; //>=5F B>@3>2;8

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

   Can_Trade(); // @07@5H8< B>@3>20BL 2 C:070==>< 2> 2E>4=KE ?0@0<5B@0E 2@5<5==>< 480?07>=5

   Sleep(60000); // 45;05< <8=CB=CN ?0C7C, GB>1K =5 >1@0I0BLAO : B>@3>2><C A5@25@C =0 :064>< B8:5

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

bool Can_Trade() // A>74048< ;>38G5A:CN DC=:F8N 4;O @07@5H5=8O B>@3>2;8 2 C:070==>< 480?07>=5 2@5<5=8

  {

   MqlDateTime time_current; // >1JO28< AB@C:BC@C, 2 :>B>@>9 1C45< E@0=8BL B5:CI55 2@5<O

   TimeCurrent(time_current); // >1=>28< 40==K5 > B5:CI5< 2@5<5=8

// 5A;8 2> 2E>4=KE ?0@0<5B@0E 7040=> 2@5<O =0G0;0 B>@3>2;8 1>;LH5, G5< 2@5<O >:>=G0=8O B>@3>2;8

   if(Trading_Start-End_Of_Trade>0 &&

      (time_current.hour>=Trading_Start || // 5A;8 B5:CI55 2@5<O 1>;LH5 8;8 @02=> 2@5<5=8 =0G0;0 B>@3>2;8

       time_current.hour<End_Of_Trade)) // 8;8 5A;8 B5:CI55 2@5<O <5=LH5 2@5<5=8 >:>=G0=8O B>@3>2;8

     {

      Alert("">@3C5< A ?5@5E>4>< G5@57 00 G. 00 <8=. 87 >4=>9 A5AA88 2 4@C3CN!"); // 2K2>48< 8=D>@<0F8N

      return true; // 2>72@0I05< 7=0G5=85 "8AB8=0"

     }

   else // 2 ?@>B82=>< A;CG05

      // 5A;8 2> 2E>4=KE ?0@0<5B@0E 7040=> 2@5<O >:>=G0=8O B>@3>2;8 1>;LH5, G5< 2@5<O =0G0;0 B>@3>2;8

      if(End_Of_Trade-Trading_Start>0 &&

         (time_current.hour>=Trading_Start && // 5A;8 B5:CI55 2@5<O 1>;LH5 8;8 @02=> 2@5<5=8 =0G0;0 B>@3>2;8

          time_current.hour<End_Of_Trade)) // 8 5A;8 B5:CI55 2@5<O <5=LH5 2@5<5=8 >:>=G0=8O B>@3>2;8

        {

         Alert("">@3C5< B>;L:> 2 B5G5=88 >4=>9 A5AA88!"); // 2K2>48< 8=D>@<0F8N

         return true; // 2>72@0I05< 7=0G5=85 "8AB8=0"

        }

   return false; // 2>72@0I05< 7=0G5=85 ";>6L"

  }

//+------------------------------------------------------------------+

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 ---