ChangeTimeframe

Author: Oleg Fedorov (aka certain)
0 Views
0 Downloads
0 Favorites
ChangeTimeframe
ÿþ//+------------------------------------------------------------------+

//|                                              ChangeTimeframe.mq4 |

//|                                       Oleg Fedorov (aka certain) |

//|                              voltIrEvvoyRipyafjamNeidy@gmail.com |

//|                                          Version from 15.12.2017 |

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

#property copyright "Oleg Fedorov (aka certain)"

#property link      "voltIrEvvoyRipyafjamNeidy@gmail.com"

#property version   "1.00"

#property strict

#property indicator_chart_window

//--- input parameters

input string   Up_Key="U";

input string   Down_Key="D";

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping



//---

   return(INIT_SUCCEEDED);

  }

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

//| Custom indicator iteration function                              |

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

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {

//---



//--- return value of prev_calculated for next call

   return(rates_total);

  }

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

//| ChartEvent function                                      |

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

void OnChartEvent(const int id,

                  const long &lparam,

                  const double &dparam,

                  const string &sparam)

  {

   string Up_Key_Value=Up_Key;

   string Down_Key_Value =Down_Key;

   int enum_timeframes[]={0,1,5,15,30,60,240,1440,10080,43200};

   int p = Period();

   int i = ArrayBsearch(enum_timeframes,p);

//      Comment(sparam); // >4K A;C651=KE :;028H

   StringToUpper(Up_Key_Value);

   StringToUpper(Down_Key_Value);

//---



   switch(id) 

     {

      case CHARTEVENT_KEYDOWN:

         if(StringGetChar(Up_Key_Value,0)==lparam)

           {

            if(i<9)

              {

               ChartSetSymbolPeriod(0,NULL,enum_timeframes[++i]);

              }

           };

         if(StringGetChar(Down_Key_Value,0)==lparam)

           {

            if(i>1)

              {

               ChartSetSymbolPeriod(0,NULL,enum_timeframes[--i]);

              }

           };

     }

  }

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

Comments