mql5

ChartHeightInPixelsSet in MQL5 does not work


I have written the following codes in my Metaeditor, but it does not work.

void OnInit()
{
ChartHeightInPixelsSet(500, 0, 1);
}


bool ChartHeightInPixelsSet(const int value,const long chart_ID=0,const int sub_window=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetInteger(chart_ID,CHART_HEIGHT_IN_PIXELS,sub_window,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }


I have created a new Expert in metaeditor and the function ChartHeightInPixelsGet works but the function ChartHeightInPixelsSet does not work. Many times I tried but I did not succeed. I also tried it by "void OnStart()" and also updated my metatrader to 2025 but it did not work.

Is this the answer : "Some functions in Metatrader does not work" If this is the answer, How can we know which functions works correctly? (Can someone help me?)


Solution

  • int size=0,step=1;

    int OnInit()

    {

    size=0; step=10;

    EventSetMillisecondTimer(44);

    return(INIT_SUCCEEDED);

    }

    void OnDeinit(const int reason) { }

    void OnTick() {

    }

    void OnTimer()

    {

    if(ChartGetInteger(0,CHART_WINDOWS_TOTAL,0)>1)

    {

    size+=step;

    if(size>100){step=-10;}

    if(size<0){step=10;}

    ChartSetInteger(0,CHART_HEIGHT_IN_PIXELS,1,size);

    ChartRedraw(0);

    }

    }