Hi! Please my code doesnt show any data, Im new in Mql4 and I want to learn here is my code, what is wrong with it?
//+------------------------------------------------------------------+
//| Mom Vol2.mq4 |
//| Copyright 2021, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1
//--- plot Label1
#property indicator_label1 "Label1"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrRed
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- indicator buffers
double Label1Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,Label1Buffer);
//---
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[])
{
int i;
double bv;
double sv;
//---
if(close[i] > open[i])
{
bv = (close[i] - open[i])*volume[i];
}
else
bv = (close[i] - low[i])*volume[i];
if(close[i] < open[i])
{
sv = (open[i] - close[i])*volume[i];
}
else
sv = (high[i] - close[i])*volume[i];
//--- return value of prev_calculated for next call
return(bv-sv);
}
//+------------------------------------------------------------------+
Discover new MetaTrader 5 opportunities with MQL5 community and services
- www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
- Whats wrong with this simple code?
- SuperTrend
- Need some help with my simple alert indicator
-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor -
No question asked. No response needed. Title does not count.
-
Why do you expect to see anything, when you don't fill your buffer?
-
Learn what to return from OnCalculate
How to do your lookbacks correctly #9 — #14 & #19
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register