Standard Chart Library Doesn't Work

 

Folks ..

I have been trying to use the standard Library for chart.. Using this code

#include <Charts\Chart.mqh>
CChart         m_chart;

int OnInit()
 {
//---
   m_chart.AutoScroll(true);
   m_chart.ColorBackground(clrBlack);
   m_chart.ShowGrid(false);
   m_chart.Mode(CHART_CANDLES);
   m_chart.Shift(true);
   m_chart.ShowPeriodSep(true);
   m_chart.ShowLineAsk(true);
   m_chart.ShowLineBid(true);
   m_chart.Scale(2);
   m_chart.ColorBarUp(clrCrimson);
   m_chart.ColorBarDown(clrBlue);
   m_chart.ColorCandleBear(clrBlue);
   m_chart.ColorCandleBull(clrCrimson);
//---

return(INIT_SUCCEEDED);
 }

It Doesn't work what's wrong here

 

Two methods need to be applied:

//+------------------------------------------------------------------+
//|                                    CChart Current Properties.mq5 |
//|                              Copyright © 2020, Vladimir Karputov |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2020, Vladimir Karputov"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property script_show_inputs
//---
#include <Charts\Chart.mqh>
//---
CChart         m_chart;                      // object of CTrade class
//--- input parameters
input int      Input1=9;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   m_chart.Attach();
   m_chart.AutoScroll(true);
   m_chart.ColorBackground(clrBlack);
   m_chart.ShowGrid(false);
   m_chart.Mode(CHART_CANDLES);
   m_chart.Shift(true);
   m_chart.ShowPeriodSep(true);
   m_chart.ShowLineAsk(true);
   m_chart.ShowLineBid(true);
   m_chart.Scale(2);
   m_chart.ColorBarUp(clrCrimson);
   m_chart.ColorBarDown(clrBlue);
   m_chart.ColorCandleBear(clrBlue);
   m_chart.ColorCandleBull(clrCrimson);
   m_chart.Detach();
  }
//+------------------------------------------------------------------+


Properties

 

Attach

Assigns the current chart to the class instance

Detach

Detaches chart from the class instance

Documentation on MQL5: Standard Library / Price Charts / Attach
Documentation on MQL5: Standard Library / Price Charts / Attach
  • www.mql5.com
Attach - Price Charts - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Vladimir Karputov:

Two methods need to be applied:


Properties

 

Attach

Assigns the current chart to the class instance

Detach

Detaches chart from the class instance

isn't there any way rather than attach and detach methods before and after my chart properties ....i don't like the way it closes a chart when i made a change on the chart  timeframe .... Basically when Init and deinit event occurs

 
Omega J Msigwa:

isn't there any way rather than attach and detach methods before and after my chart properties ....i don't like the way it closes a chart when i made a change on the chart  timeframe .... Basically when Init and deinit event occurs

i found out what was wrong it works well thank you ..your method works as well

 
Omega J Msigwa :

isn't there any way rather than attach and detach methods before and after my chart properties ....i don't like the way it closes a chart when i made a change on the chart  timeframe .... Basically when Init and deinit event occurs

Pay attention to which program you are working in: in an Expert Advisor or in a script.

Reason: