SCT_BestTimeToTrade

Author: Copyright 2020, Forex Jarvis. forexjarvis@gmail.com
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Miscellaneous
Uses files from the file systemIt writes information to file
0 Views
0 Downloads
0 Favorites
SCT_BestTimeToTrade
//+------------------------------------------------------------------+
//|                                          SCT_BestTimeToTrade.mq4 |
//|                                    Copyright 2020, Forex Jarvis. |
//|                                            forexjarvis@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, Forex Jarvis. forexjarvis@gmail.com"
#property version   "1.00"
#property strict
#property script_show_inputs

input int iRange = 60;   // Period: Specify the number of days

double pipPos(string sSymbol) {
      if (MarketInfo(sSymbol,MODE_DIGITS)==1 || MarketInfo(sSymbol,MODE_DIGITS)==3 || MarketInfo(sSymbol,MODE_DIGITS)==5)
         return MarketInfo(sSymbol,MODE_POINT)*10;
      else 
         return MarketInfo(sSymbol,MODE_POINT)*1;
   
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class cCandlestick {

   public:

      datetime dtTime;
      double dRangeCandle;
      double dHighPrice;
      double dLowPrice;
      
      int iDayOfWeek;
      string sDayOfWeek;
      
      void mvGetCandleStickCharateristics (string s, int i) {
         
         dtTime = iTime(s, PERIOD_H1, i);
         dHighPrice = iHigh(s, PERIOD_H1,i);
         dLowPrice = iLow(s, PERIOD_H1,i);
         
         dRangeCandle = NormalizeDouble(MathAbs(dHighPrice-dLowPrice)/pipPos(Symbol()),4);

      }
};

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart()
{
   int i;

   int handle = FileOpen(Symbol()+"_H1_history"+".csv",FILE_CSV|FILE_READ|FILE_WRITE,',');
   
   if(handle>0) {

      FileSeek(handle,0,SEEK_SET);
      FileWrite(handle, "Date", "Time", "Range in Pips");
         
      cCandlestick cCS;

      int iHourlyRange = iRange*24; //Sum of all hours
                  
      for (i=1;i<=iHourlyRange;i++) {
         
         cCS.mvGetCandleStickCharateristics(_Symbol,i);
         FileWrite(handle, TimeToString(cCS.dtTime, TIME_DATE), TimeToString(cCS.dtTime, TIME_MINUTES), DoubleToString(cCS.dRangeCandle,5));

      }
   }
   FileClose(handle);

}

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