don't know if this will help. goto tools-options-charts and change max number of bars in chart to 500.
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
The RefreshRates function only refreshes incomming rates, not the entire charts on the software. Or does it?
Please take a look at my code:
//+------------------------------------------------------------------+
//| My Custom Indicator.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_color1 Blue
#property indicator_minimum 0
double buffer[];
extern int Length = 3;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,buffer);
SetIndexDrawBegin(0,0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
for (int i = 0; i < Bars-1; i++) buffer[i] = EMPTY_VALUE;
for (i = 0; i < Bars - 1; i++)
{
int price_idx = i + 1;
int prev_price_idx = 0;
for (int j = 0; j < Length; j++)
{
if (j == 0)
{
// Find the first of highest highs
while (High[price_idx] > High[i] && price_idx < Bars - 1)
{
price_idx++;
}
}
else
{
// Find the lowest lows
while (Low[price_idx] > Low[prev_price_idx] && price_idx < Bars - 1)
{
price_idx++;
}
}
prev_price_idx = price_idx;
price_idx++;
}
buffer[i] = price_idx - i;
}
// At this point, when the indicator is displayed on the chart, there may be a segment that could have a
// range of 2000 - thereby hiding all the other values that could exist below (say) 100. We need a mechanism
// to shrink the results to scale so that we could view all values within the window.
double high = 0;
for (i = 0; i < Bars - 1; i++)
{
if (buffer[i] > high) high = buffer[i];
}
for (i = 0; i < Bars - 1; i++)
{
while (buffer[i] > 100) buffer[i] /= 2;
}
//----
return(0);
}
//+------------------------------------------------------------------+