I want to draw color candles in MT4. but the bellow code doesn't do anything. The code doesn't return any error but not work as expected. Can someone tell me what the issue is? I tried with ChatGPT to find an answer, it doesn't give any correct answer for this.
it does not work for mt4
here is the code for mt5
#property indicator_chart_window #property indicator_buffers 5 #property indicator_plots 1 double buf_open[], buf_high[], buf_low[], buf_close[]; double buf_color_line[]; int OnInit() { // Assign buffers SetIndexBuffer(0, buf_open, INDICATOR_DATA); SetIndexBuffer(1, buf_high, INDICATOR_DATA); SetIndexBuffer(2, buf_low, INDICATOR_DATA); SetIndexBuffer(3, buf_close, INDICATOR_DATA); SetIndexBuffer(4, buf_color_line, INDICATOR_COLOR_INDEX); PlotIndexSetInteger(0, PLOT_DRAW_TYPE,DRAW_COLOR_CANDLES); PlotIndexSetInteger(0, PLOT_COLOR_INDEXES, 2); PlotIndexSetInteger(0, PLOT_LINE_COLOR, 0, clrBlue); PlotIndexSetInteger(0, PLOT_LINE_COLOR, 1, clrRed); return (INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| OnCalculate 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[]) { for(int i=prev_calculated;i<=rates_total-1;i++) { buf_open[i] = open[i]; buf_high[i] = high[i]; buf_low[i] = low[i]; buf_close[i] = close[i]; if(close[i]>=open[i]){ buf_color_line[i]=0; }else{ buf_color_line[i]=1; } } return (rates_total); }
There is no DRAW_COLORCANDLE in MT4.
ChatGPT (the worst), “Bots Builder”, “EA builder”, “EA Builder Pro”, EATree, “Etasoft forex generator”, “Forex Strategy Builder”, ForexEAdvisor (aka. ForexEAdvisor STRATEGY BUILDER, and Online Forex Expert Advisor Generator), ForexRobotAcademy.com, forexsb, “FX EA Builder”, fxDreema, Forex Generator, FxPro, “LP-MOBI”, Molanis, “Octa-FX Meta Editor”, Strategy Builder FX, “Strategy Quant”, “Visual Trader Studio”, “MQL5 Wizard”, etc., are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.
Since you haven't learned MQL4/5, therefor there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
We are willing to HELP you when you post your attempt (using Code button) and state the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.
| ChatGPT |
|
| bot builder | Creating two OnInit() functions. * |
| EA builder | |
| EATree | Uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.) |
| ForexEAdvisor |
|
| FX EA Builder |
|
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to draw color candles in MT4. but the bellow code doesn't do anything. The code doesn't return any error but not work as expected. Can someone tell me what the issue is? I tried with ChatGPT to find an answer, it doesn't give any correct answer for this.