[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 875

 
reag:

Yes, the first option doesn't work, though I'm working on a non-standard timeframe, the second one does. Thank you all!


The first option works - at least 20 days on a demo account (no more time to check) and in the tester on the history for 10 years

ZS: Well, if it doesn't work, it doesn't work :)

 
IgorM:


the first option works - at least 20 days on a demo account (no more time to check) and in the tester on the history for 10 years

ZS: well, not working means not working :)

The first one works in a real account. For me it works probably because the chart window is very large. Probably works because the chart window is very large and does not reach the maximum... but maybe the EA is like that - he'll do just fine... :)
 
Andrei01:
it's not scary on the demo. :) but on the real site, it's probably better not to take chances and do it normally ... Probably works because the chart window is very large and does not reach the maximum ... but maybe the EA is like that - it will do fine... :)


not quite so - by counting the number of bars I can "not miss" the moment of history loading - and at these moments, it's better to wait a little, the history is not only loaded at the end of TF, but sometimes the beginning of TF is also loaded - ok, this is a big secret shhhhhhhhhh

:)

 
IgorM:


not really - by counting the number of bars I can "not miss" the moment of history loading - and at these moments, it's better to wait a little, the history is not only loaded at the end of TF, but sometimes it loads the beginning of TF too - ok, it's a big secret shhhhhhhhhh

:)


It turned out that the second variant does not work either ... The bar numbers in the indicator array don't change anyway! I understand it's because of the non-standard timeframe. It is formed by the standard Period_Converter_Opt, I get it from M1 to M2, when I open M2 Bars are equal to a half of the Max bar in the window, and when I get to the value of Max bar in the window, the fomation of the SetIndexBuffer array stops...((
 
reag:

It turned out that the second option doesn't work either ... the bar numbers in the indicator array do not change anyway! I guess it's because of the non-standard timeframe. It is formed by the standard Period_Converter_Opt, I get it from M1 to M2, when I open M2 Bars are equal to a half of Max bar in the window, and when I get to the value of Max bar in the window, the fomation of the SetIndexBuffer index array stops...((


but at least some parameters of the new bar can be compared with the memorised bar?

If you have a non-standard TF - is it possible that the bar you think is zero - has an index not 0, 1 ?

 
IgorM:


but at least some parameters of the new bar can be compared with the memorised bar?

If you have a non-standard TF - is it possible that the bar you think is zero has an index other than 0, 1 ?


The algorithm for recognizing a new bar works, but the chart stops after reaching a maximum bar in the window; I assume that fomenting the SetIndexBuffer index array stops. Here's the problem, i.e. after enabling everything works fine and then the chart freezes and the bars move... and consequently the indicator does not work!
 
reag:

The algorithm itself recognises a new bar, but the chart stops after reaching a max bar in the window, I assume that the fomation of the SetIndexBuffer index array stops. Here's the problem, i.e. after switching on everything works fine, and then the chart freezes and the bars move... and consequently the indicator does not work!

Where is the code? If it works at startup, maybe the problem is that the number of bars to be re-drawn is defined incorrectly
 
IgorM:

Where is the code? If it does this on startup, the problem might be that the number of bars to be redrawn is not defined correctly

#property indicator_chart_window
#property show_inputs
#property indicator_buffers 3 // number of buffers
#property indicator_color1 DarkSeaGreen // colour of the first line
#property indicator_color2 SaddleBrown // colour of the second line
#property indicator_color3 SaddleBrown // colour of the second line

extern intHistory=300; // Number of bars in calculated history
extern int Arrows=1;
extern int Line=0; // Number of bars for calculations
//extern int Left_Right= 5; // Horizontal offset (bars)
extern int Up_Right=8; // vertical offset (points)
static int up = 1, intPost=600;
static datetime VPPosLStr,time0new,time0old;
double Line_0[],Line_1[],Line_2[]; //declaration of data arrays

//--------------------------------------------------------------------
int init() //Special function init()
{

if (Arrows==1 && Line==1)int Style=1;
if (Arrows==1 && Lines!=1)style=3;
if (Arrows!=1 && Lines==1)style=2;
switch(Style) // Header switch
{ // Body start switch
case 1 :
//--------------------------------------------------------------------
SetIndexBuffer(0,Line_0); // Assign array to buffer 0
SetIndexStyle(0,DRAW_SECTION,STYLE_DOT,1);// Line style
SetIndexEmptyValue(0,0.0);
//--------------------------------------------------------------------
SetIndexBuffer(1,Line_1); // Assign array to buffer 1
SetIndexStyle(1,DRAW_ARROW,EMPTY,1); // Line style
SetIndexArrow (1,217);
//--------------------------------------------------------------------
SetIndexBuffer(2,Line_2); // Assign array to buffer 2
SetIndexStyle (2,DRAW_ARROW,EMPTY,1); // Line style
SetIndexArrow (2,218);
//--------------------------------------------------------------------
break; // Options.
case 2 :
//--------------------------------------------------------------------
SetIndexBuffer(0,Line_0); // Assign an array to buffer 0
SetIndexStyle(0,DRAW_SECTION,STYLE_DOT,1);// Line style
SetIndexEmptyValue(0,0.0);
break;
case 3 :
//--------------------------------------------------------------------
SetIndexBuffer(1,Line_1); // Assign array to buffer 1
SetIndexStyle(1,DRAW_ARROW,EMPTY,1); // Line style
SetIndexArrow (1,217);
//--------------------------------------------------------------------
SetIndexBuffer(2,Line_2); // Assign array to buffer 2
SetIndexStyle (2,DRAW_ARROW,EMPTY,1); // Line style
SetIndexArrow (2,218);
//--------------------------------------------------------------------
break;
default: break; // case didn't match
}
int k=Bars; // end of body switch

return(0); // Exit special function init()
}
//--------------------------------------------------------------------
int start() // Special function start()
{
//----+ check the number of bars for correct
//calculate the indicator
if(History-1 < 15)
return(0);

//+--- +==========================================+
int i, // Bar index
n, // formal parameter (index)
k, // index of the index element of the index array
Counted_bars; // Number of calculated bars
double Line;
iBarShift(NULL, 0, VrPostStr);
//Comment (indpostr," ",up);
//--------------------------------------------------------------------
/* Counted_bars=IndicatorCounted(); // Number of counted bars
//---- check for possible errors
if(Counted_bars < 0)
return(-1);
i=Bars-Counted_bars-1+indicatorCounted; // Index of the first one not counted
if (i>History-1) // If there are a lot of bars, then .
i=History-1; // ...calculate the given number
time0new=Time[0];
if(time0old!=time0new)
{
i=History-1;
time0old=time0new;
Comment ("Bars ",Bars,",History ",History,",i ",i);
}

for(i=i-1; i >= 3; i--) // Loop over uncounted bars
{
if(up==0)
{
Line=Low[i];

if (Line<Low[i-1] && Line<Low[i-2] && Bpostr<Time[i])
{
Line_0 [i] = Line[i];
Line_0 [i] = Line;
Line_2[i] = Line-up_down*Point;
up=1;
continue;
}
}
if(up==1) //build fibo grid by criterion of two candlesticks rollback
{
Line=High[i];

if (Line>High[i-1] && Line>High[i-2]&& Bpostr<Time[i])
{
Line_0[i] = Line[i];
Line_0[i] = Line;
Line_1[i] = Line+Up_down*Point;
up=0;
}
}
//Index calculation for the next bar
}
// WindowRedraw();
//--------------------------------------------------------------------
return(0);
}
//--------------------------------------------------------------------
int deinit()
{

return(0);
}
 
reag:


   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(int i=0; i<limit; i++){
I write indicators this way, this is my standard indicator start - it's a bit stretched, but when I was dealing with mql, I wrote it this way and that's how it stays
it's hard to understand your code - the names of variables in Cyrillic letters scare me - I get confused with comments
 
IgorM:
I write indicators this way, this is my standard indicator start
it's difficult to understand your code - the variable names in Cyrillic letters scare me - I get confused with comments

Yes it's just me trying... Cyrillic )), the combination of Bars and IndicatorCounted() on a non-standard timeframe does not work exactly, when the Max bar in Bars window is exceeded it goes no further.
Reason: