Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 338

 

Can someone advise why my indicator is displayed in the tests and stays in the indicator window after the tests are finished, but if I call it through iCustom in an Expert Advisor, the indicator is not displayed?

//+------------------------------------------------------------------+
//|                                             Tiscks_Window_49.mq4 |
#property version   "1.00"
#property strict

#property indicator_separate_window
#property indicator_buffers 1
#property  indicator_color1 clrLawnGreen

double ExtMapBuffer1[];
int Draw_Bars;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   IndicatorShortName("Ask");
   IndicatorDigits(5);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,"Ask");
//---
   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[])
  {
//---
   ExtMapBuffer1[0]=MarketInfo(Symbol(),MODE_ASK);
   for(int i=Bars-2; i>=0; i --)
     {
      ExtMapBuffer1[i+1]=ExtMapBuffer1[i];
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+


Maybe I do not call it correctly in iCustom?

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double sep_window=iCustom(Symbol(),PERIOD_CURRENT,"Tiscks_Window_49",0,0);
   Print(" sep_window= ",sep_window);
  }
//+------------------------------------------------------------------+
 
Nauris Zukas:

Can someone advise why my indicator is displayed in the tests and stays in the indicator window after the tests are finished, but if I call it through iCustom in an Expert Advisor, the indicator is not displayed?
Maybe I do not call it correctly in iCustom?

You got it right. Try it with other indicators - it will be the same.

 
Nauris Zukas:

Can someone tell me why my indicator is shown in the tests and stays in the indicator window after the tests are over, but if I call it through iCustom in the Expert Advisor, the indicator is not shown?


Maybe I do not call it correctly in iCustom?

ExtMapBuffer1[0]=MarketInfo(Symbol(),MODE_ASK);

try to put it simply =Ask;
or, to check close[0]

and here, why do you need to move the entire history? the first 100-300 bars are enough

for(int i=Bars-2; i>=0; i --)
 
LRA:

It's all right. Try with other indicators - it will be the same...

Tried RSI, everything works. There's a nuance somewhere, I don't know where yet.


 
Taras Slobodyanik:

try just =Ask;
or to check close[0]

and here, why would you want to move the whole story? The first 100-300 bars are enough.

Changed it but it doesn't help either.

 
Nauris Zukas:

Can someone advise why my indicator is displayed in the tests and stays in the indicator window after the tests are finished, but if I call it through iCustom in an Expert Advisor, the indicator is not displayed?


Maybe I do not call it correctly in iCustom?

Perhaps, it is because the indicator is written that way. What is the probability that it simply does not have enough time to recalculate all the bars when being called from the Expert Advisor?

Try to recalculate all the bars only once, and then only a new call from the Expert Advisor.
 
Alexey Viktorov:

What is the probability that it just does not have time to recalculate all the bars when I call it from the Expert Advisor?

I print Print in Expert Advisor and it shows that the prices are there, which means that the bars have been recalculated.

Alexey Viktorov:
Try to recalculate all the bars only once and then only a new call from EA.

I haven't tested this variant yet, I am still thinking how to do it.

 

Good afternoon, taking my first steps, I've read the tutorial etc, I may have the question wrong, but still.....

If i want to get a ticks archive for the last couple of years, i may need it for a longer period of time to analyze it in a third-party application. If i'm not mistaken, but Bars contain only current chart data, thank you.

 
ijonhson:

Good afternoon, taking my first steps, I've read the tutorial etc, I may have the question wrong, but still.....

If i want to get a ticks archive for the last couple of years, i may need it for a longer period of time to analyze it in a third-party application. If i'm not mistaken, but Bars contain only current chart data, thank you.

If you do not know how to use these logs, do not try to overwrite them with other logs. Google will help you.

 

Hello Artiom, could you please tell me how to write an EA so that it does not open orders until the price has passed a certain level and then continues to open orders even after the price has moved back above the level? Regards Andrei.