Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 98

 
Roger:

I do not believe it, this EA cannot work either on real or in tester.


Why? Is there a mistake? Explain.

This is just a part of the code that is responsible for converting horizontal lines into orders.

 
Please help. How to make an EA optimise at a distance of 20-30 bars to zero. At the very end of the chart......
 

Help to understand the indicator, I can not understand why during the signals are not displayed in real time, but only if you switch the timeframe, in the visualization tester everything is rendered as it should be.

before update http://charts.mql5.com/2/379/eurusd-m-m1-roboforex.png

after http://charts.mql5.com/2/379/eurusd-m-m1-roboforex-2.png

//+------------------------------------------------------------------+
//|                                                           t27_zz |
//|                                                          tommy27 |
//|                                        SKYPE:       t.o.m.m.y.27 |
//|                                        MAIL: tommy27fx@gmail.com |
//+------------------------------------------------------------------+
#property copyright "tommy27"
#property link      "tommy27fx@gmail.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 FireBrick

extern int DeepBars = 5000;
double buf_1[];
double buf_2[];
//+------------------------------------------------------------------+
//| Функция инициализации, запускается один раз                      |
//+------------------------------------------------------------------+
int init() 
  {
   SetIndexBuffer(0,buf_1);
   SetIndexBuffer(1,buf_2);

   SetIndexStyle (0,DRAW_ARROW, STYLE_SOLID, 2);
   SetIndexStyle (1,DRAW_ARROW, STYLE_SOLID, 2);
   SetIndexArrow (0,108);
   SetIndexArrow (1,108);

   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   IndicatorShortName("t27_zz");
   return(0);
  }
//+------------------------------------------------------------------+
//| Основная Функция, запускается на каждом тике                     |
//+------------------------------------------------------------------+
int start() 
  {
   if (Bars <= 100) return(0);
   int ExtCountedBars = IndicatorCounted();
   if (ExtCountedBars < 0) return(-1);
   if (ExtCountedBars > 0) ExtCountedBars--;
   for (int i=DeepBars-ExtCountedBars-1; i>=0; i--)
     { 
      if (Bar1(i)==1)   buf_1[i+1] = Low[i+1]-5*Point;//UP
      if (Bar1(i)==2)   buf_2[i+1] = High[i+1]+5*Point;//DOWN
     }
   return(0);
  }
//---- end
//------------------------------------------------------------------------
int Bar1(int i)
{
 if(Low[i+1] <= Low[i+2] && Low[i+1] <= Low[i])//UP
  return(1);
 if(High[i+1] >= High[i+2] && High[i+1] >= High[i])//DOWN
  return(2);
 return(0);
} 
 
tommy27:

Help to understand the indicator, I can not understand why during the signals are not displayed in real time, but only if you switch the timeframe, in the visualization tester, all rendered as it should.



I have to deal with DeepBars variable.

 
splxgf:


Deal with the variable DeerBars.


Thank you very much! Removed DeerBars and everything worked, can you also tell me how to set the displayed depth correctly then, what to replace DeerBars with now ?
 

Why replace it?

if (ExtCountedBars > 0) ExtCountedBars--;
int recalc=Bars-ExtCountedBars;//добавить
for (int i=recalc; i>=0; i--)//поправить
 
splxgf:

Why replace it?


Yes, I corrected it like this:

if (ExtCountedBars > 0) ExtCountedBars--;
   for (int i=Bars-ExtCountedBars-1; i>=0; i--)

and with DeepBars I wanted to set the number of bars to not show the whole story, but to display on the last DeepBars - this for some reason I can't do.

 
<br / translate="no">

And with DeepBars I wanted to set the number of bars, so it wouldn't show the whole history, but would display on the last DeepBars - for some reason it can't do that.


if (ExtCountedBars > 0) ExtCountedBars--;
int recalc=Bars-ExtCountedBars;
if (recalc>DeepBars) recalc=DeepBars;
 
Thank you very much for your help, you have helped me a lot.
 
Dozol:


Why? Is there a mistake? Explain.

This is just the part of the code responsible for converting horizontal lines into orders.

According to your code, the line will be deleted after the first tick, i.e. there is no price tracking function and it works like a script - you manually draw a horizontal line, an order is opened or not, but the line is immediately deleted. Sellstop orders by this code will never open.