
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
Hello, I'm tryingto convert an indicator from mql4 to mql5. Basically I just need a sound notification in the MFI when a red bar appears. How do I attach this sound code now to the new mfi?
I attached an example of the old working version:
Tell me the correct way, this is a Heiken Ashi calculation
It's a clipping from the standard
{
haOpen=(ExtOpenBuffer0[i-1]+ExtCloseBuffer0[i-1])/2; // <<<
haClose=(Open[i]+High[i]+Low[i]+Close[i])/4;
haHigh=MathMax(High[i],MathMax(haOpen,haClose));
haLow=MathMin(Low[i],MathMin(haOpen,haClose));
The question arises: if Open should be searched by the previous bar, why is it searched by the next bar in the code?
Is it probably correct this way, or am I misunderstanding something:
Tell me the correct way, this is a Heiken Ashi calculation
It's a clipping from the standard
{
haOpen=(ExtOpenBuffer0[i-1]+ExtCloseBuffer0[i-1])/2; // <<<
haClose=(Open[i]+High[i]+Low[i]+Close[i])/4;
haHigh=MathMax(High[i],MathMax(haOpen,haClose));
haLow=MathMin(Low[i],MathMin(haOpen,haClose));
The question arises: if Open should be searched by the previous bar, why is it searched by the next bar in the code?
This must be correct, or am I misunderstanding something?
Tell me the correct way, this is a Heiken Ashi calculation
It's a clipping from the standard
{
haOpen=(ExtOpenBuffer0[i-1]+ExtCloseBuffer0[i-1])/2; // <<<
haClose=(Open[i]+High[i]+Low[i]+Close[i])/4;
haHigh=MathMax(High[i],MathMax(haOpen,haClose));
haLow=MathMin(Low[i],MathMin(haOpen,haClose));
The question arises: if Open should be searched by the previous bar, why is it searched by the next bar in the code?
Probably the right way, or am I misunderstanding something:
To see exactly, which index has the rightmost and the leftmost bar on the chart, use this simple method:
In any indicator, in MetaEditor, put a breakpoint on the first operation inside OnCakculate() (step 1):
Start debugging on historical data. As soon as you start debugging on your breakpoint, debugging will pause. Then add two expressions to the observation: "time[rates_total-1]" and "time[0]" (steps 2 and 3). Now we can easily see that in this situation (the time[] array has the default indexing direction, ArrayAsSeries has not been applied), the element time[rates_total-1] will be the rightmost bar in the chart (step 4).
I hope this simple and clear method will help you to quickly check the direction of indexing in indicators.
In mql5 the direction of bar indexing is done by default. Therefore [i-1] will be the first bar from the right.
I roughly understand, so I don't forget about using ArraySetAsSeries.
The question is that in both mql4 and mql5 code the same "i-1" calculation is applied, why the subtraction if the formula states the previous bar and not the future one?
To see exactly which index has the right and leftmost bar on the chart, use this simple trick:
In any indicator, in MetaEditor, put a breakpoint on the first operation inside OnCakculate() (step 1):
Start debugging on historical data. As soon as you start debugging on your breakpoint, debugging will pause. Then add two expressions to the observation: "time[rates_total-1]" and "time[0]" (steps 2 and 3). Now we can easily see that in this situation (the time[] array has the default indexing direction, ArrayAsSeries has not been applied), the element time[rates_total-1] will be the rightmost bar in the chart (step 4).
I hope this simple and clear method will help to quickly check the direction of indexing in indicators.
Thank you, I was not aware of that.
Do you have any suggestions on the correctness of calculation?
I need to make an alert for the CCI ARROWS indicator.
I need it to signal immediately after the arrow appears.
MT5
Hi all!!! I started to modify the indicator in MT5, but I can't figure out the iTime function, I can't get it to work, can someone dopilize the indicator to working condition?????
The indicator reads the file, which is located in the folder MQL5\Files\evolution-dvoid\.
After downloading it, rename it to .csv
Thanks in advance.
Good day all, I am not a programmer, but one of my friends says that in the code of indicator Bill Williams'Market Facilitation Index (BW MFI) the calculations are not made strictly according to the classical formula: BW MFI = (HIGH - LOW) / VOLUME And in addition some additional data correction is used. This is in fact an error, and consequently the indicator displays incorrect data!
Please advise how to fix this error in the indicator (remove the additional data correction) and receive
indicator that works strictly according to the formula: BW MFI = (HIGH - LOW) / VOLUME ?????
//+------------------------------------------------------------------+
//| MarketFacilitationIndex.mq5 |
//| Copyright 2009, MetaQuotes Software Corp.
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp.
#property link "http://www.mql5.com"
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots 1
#property indicator_type1 DRAW_COLOR_HISTOGRAM
#property indicator_color1 Lime,SaddleBrown,Blue,Pink
#property indicator_width1 2
//--- input parameter
input ENUM_APPLIED_VOLUME InpVolumeType=VOLUME_TICK; //volumes
//---- buffers
double ExtMFIBuffer[];
double ExtColorBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialisation function |
//+------------------------------------------------------------------+
void OnInit()
{
//---- indicators
SetIndexBuffer(0,ExtMFIBuffer,INDICATOR_DATA);
SetIndexBuffer(1,ExtColorBuffer,INDICATOR_COLOR_INDEX);
//--- name for DataWindow
IndicatorSetString(INDICATOR_SHORTNAME, "BWMFI");
//--- set accuracy
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//----
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CalculateMFI(const int start,const int rates_total,
const double &high[],
const double &low[],
const long &volume[])
{
int i=start;
bool mfi_up=true,vol_up=true;
//--- calculate first values of mfi_up and vol_up
if(i>0)
{
int n=i;
while(n>0)
{
if(ExtMFIBuffer[n]>ExtMFIBuffer[n-1]) { mfi_up=true; break; }
if(ExtMFIBuffer[n]<ExtMFIBuffer[n-1]) { mfi_up=false; break; }
//--- if mfi values are equal continue
n--;
}
n=i;
while(n>0)
{
if(volume[n]>volume[n-1]) { vol_up=true; break; }
if(volume[n]<volume[n-1]) { vol_up=false; break; }
//--- if real volumes are equal continue
n--;
}
}
//---
while(i<rates_total && !IsStopped())
{
if(volume[i]==0)
{
if(i>0) ExtMFIBuffer[i]=ExtMFIBuffer[i-1];
else ExtMFIBuffer[i]=0;
}
else ExtMFIBuffer[i]=(high[i]-low[i])/_Point/volume[i];
//--- calculate changes
if(i>0)
{
if(ExtMFIBuffer[i]>ExtMFIBuffer[i-1]) mfi_up=true;
if(ExtMFIBuffer[i]<ExtMFIBuffer[i-1]) mfi_up=false;
if(volume[i]>volume[i-1]) vol_up=true;
if(volume[i]<volume[i-1]) vol_up=false;
}
//--- set colors
if(mfi_up && vol_up) ExtColorBuffer[i]=0.0;
if(!mfi_up && !vol_up) ExtColorBuffer[i]=1.0;
if(mfi_up && !vol_up) ExtColorBuffer[i]=2.0;
if(!mfi_up && vol_up) ExtColorBuffer[i]=3.0;
i++;
}
}
//+------------------------------------------------------------------+
//| 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 start=0;
//---
if(start<prev_calculated) start=prev_calculated-1;
//--- calculate with tick or real volumes
if(InpVolumeType==VOLUME_TICK)
CalculateMFI(start,rates_total,high,low,tick_volume);
else
CalculateMFI(start,rates_total,high,low,volume);
//--- normalize last mfi value
if(rates_total>1)
{
datetime ctm=TimeTradeServer(),lasttm=time[rates_total-1],nexttm=lasttm+datetime(PeriodSeconds());
if(ctm<nexttm && ctm>=lasttm && nexttm!=lasttm)
{
double correction_koef=double(1+ctm-lasttm)/double(nexttm-lasttm);
ExtMFIBuffer[rates_total-1]*=correction_koef;
}
}
//---
return(rates_total);
}
//+------------------------------------------------------------------+
Please tell me what kind of code this is and how to make this into an MT5 indicator ?
//This is a volume based indicator. Make shure to use proper volume input.
Please tell me what kind of code this is and how to make this into an MT5 indicator ?
//This is a volume based indicator. Make shure to use proper volume input.
BW MFI Squat bar , 3 buffer ( if memory serves)