Questions from a "dummy" - page 187

 
G001:
I'm completely exhausted. It won't open properly.

Please help me. Where's the mistake?

Try this:
MqlTradeRequest request={0};
MqlTradeResult result={0};
MqlTradeCheckResult check={0};
 
fyords:
Try it like this:
Thank you.
It opens, just doesn't read the signals from the indicator correctly.
Does that help?
 
G001:
Thank you.
It opens, just doesn't read the signals from the indicator correctly.
Will this help?
ArraySetAsSeries(Bull,true);

It is done once in OnInit.

CopyBuffer(Indicator,1,0,3,Bull);
You didn't mess up the buffer numbers?
 
fyords:

This is done once at OnInit.

Are the buffer numbers correct?
I don't think so. The indicator is in the previous page.
 
G001:
It opens, only it doesn't read the signals from the indicator correctly.

What do you mean by wrong?

You can print the value of the indicator to check - "what do we get?"

 
fyords:

What do you mean by wrong?

You can print the value of the indicator to check - "what do we get?"

I checked the EA with other indicators and it works.
Maybe there is a problem with the indicator?
It opens on the first tick with this indicator.

Sorry, I do not know where to add print.

Example for BUY_STOP, goes from red to grey.

//+------------------------------------------------------------------+ 
//|                                                      MACDATR.mq5 | 
//|                                      Copyright © 2011, Svinozavr | 
//+------------------------------------------------------------------+ 
//---- Indicator settings
#property indicator_separate_window 
#property indicator_buffers 4 
#property indicator_plots   4
#property indicator_level1 +0.0005
#property indicator_level2 -0.0005
#property indicator_levelcolor DimGray
#define RESET 0
//-----
#property indicator_type1 DRAW_HISTOGRAM
#property indicator_color1 Gray
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
#property indicator_label1 "MACD"
//-----
#property indicator_type2 DRAW_HISTOGRAM
#property indicator_color2 Green
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
#property indicator_label2 "Bull"
//-----
#property indicator_type3 DRAW_HISTOGRAM
#property indicator_color3 Red
#property indicator_style3 STYLE_SOLID
#property indicator_width3 1
#property indicator_label3 "Bear"
//-----
#property indicator_type4 DRAW_LINE
#property indicator_color4 Olive
#property indicator_style4 STYLE_SOLID
#property indicator_width4 1
#property indicator_label4 "ATR"
//-----
//----- Indicator parameters
//+------------------------------------------------------------------+
input uint FastEMA      = 12;
input uint SlowEMA      = 26;
input uint SignalEMA = 9;
input int  ATRG         = 0;
input ENUM_APPLIED_PRICE AppliedPrice=PRICE_CLOSE;
//+------------------------------------------------------------------+
//-----
double ATRmin=0;
double kATR=1;
int min_rates_total;
int ATRHandle,MACDHandle;
double MACDBuffer[],ATRBuffer[],Bull[],Bear[];
//+------------------------------------------------------------------+    
//| MACD indicator initialization function                           | 
//+------------------------------------------------------------------+  
void OnInit()
{
//-----
  if(ATRG) min_rates_total=int(MathMax(FastEMA,SlowEMA)+ATRG);
  else min_rates_total=2*int(MathMax(FastEMA,SlowEMA));
//-----
  int ATR;
  if(!ATRG) ATR=int(SlowEMA); 
  else ATR=ATRG;
  ATRmin*=_Point;
//-----
  ATRHandle=iATR(NULL,0,ATR);
  if(ATRHandle==INVALID_HANDLE)Print(" Íå óäàëîñü ïîëó÷èòü õåíäë èíäèêàòîðà ATR");
//-----
  MACDHandle=iMACD(NULL,0,FastEMA,SlowEMA,SignalEMA,AppliedPrice);
  if(MACDHandle==INVALID_HANDLE)Print(" Íå óäàëîñü ïîëó÷èòü õåíäë èíäèêàòîðà MACD");
//-----
  SetIndexBuffer(0,MACDBuffer,INDICATOR_DATA);
  PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);
  ArraySetAsSeries(MACDBuffer,true);
//-----
  SetIndexBuffer(1,Bull,INDICATOR_DATA);
  PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total);
  ArraySetAsSeries(Bull,true);
//-----
  SetIndexBuffer(2,Bear,INDICATOR_DATA);
  PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,min_rates_total);
  ArraySetAsSeries(Bear,true);
//-----
  SetIndexBuffer(3,ATRBuffer,INDICATOR_DATA);
  PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,min_rates_total);
  ArraySetAsSeries(ATRBuffer,true);
//-----
  string shortname;
  StringConcatenate(shortname,"MACDATR (",FastEMA,", ",SlowEMA,", ",SignalEMA,", ",EnumToString(AppliedPrice),")");
//-----
  IndicatorSetString(INDICATOR_SHORTNAME,shortname);
//-----
  IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1);
//-----
}
//+------------------------------------------------------------------+  
//| MACD 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[]
                )
  {
//----- Check for data
  if(rates_total<min_rates_total) return(0);
//-----
  int to_copy,limit,i;
  double atr,Atr[];
  datetime Time[1];
//-----
  if(prev_calculated>rates_total || prev_calculated<=0)
  {
    limit=rates_total-min_rates_total;
  }
  else limit=rates_total-prev_calculated;
//----- 
  ArraySetAsSeries(Atr,true);
//-----
  to_copy=limit+1;
//-----
  if(CopyBuffer(ATRHandle,0,0,to_copy,Atr)<=0) return(RESET);
  if(CopyBuffer(MACDHandle,MAIN_LINE,0,to_copy,MACDBuffer)<=0) return(RESET);
//-----
  for(i=limit; i>=0 && !IsStopped(); i--)
  {
    atr=kATR*Atr[i]; // ATR
    atr=MathMax(atr,ATRmin);
//-----
    if(MACDBuffer[i]>0) {ATRBuffer[i]=MACDBuffer[i]-atr;}
    if(MACDBuffer[i]<0) {ATRBuffer[i]=MACDBuffer[i]+atr;}
  }
//-----
  for(i=limit; i>=0 && !IsStopped(); i--)
  {
//-----
    Bear[i]=0;
    Bull[i]=0;
//-----
    if(MACDBuffer[i]>0 && MACDBuffer[i+1]<MACDBuffer[i] && ATRBuffer[i]>=0) {Bull[i]=MACDBuffer[i];}
    if(MACDBuffer[i]<0 && MACDBuffer[i+1]>MACDBuffer[i] && ATRBuffer[i]<=0) {Bear[i]=MACDBuffer[i];}
  }
//+------------------------------------------------------------------+
//----- Done
  return(rates_total);
}
//+------------------------------------------------------------------+

 
G001:
Tested the EA with other indicators and it works.
Maybe the indicator is the problem?
With this indicator it opens on the first tick.

Sorry, I do not know where to add print.

Example for BUY_STOP, goes from red to grey.

I haven't found a problem, everything works. I took the codes from page 189.

 

Question about program property#property tester_file "" .

I need to connect a lot of files to my EA for testing, 3800 to be exact .

Daily option levels for several instruments only for this year .

What is the solution?

Документация по MQL5: Основы языка / Препроцессор / Свойства программ (#property)
Документация по MQL5: Основы языка / Препроцессор / Свойства программ (#property)
  • www.mql5.com
Основы языка / Препроцессор / Свойства программ (#property) - Документация по MQL5
 
Karlson: Question on program property#property tester_file "" .

Need to connect many files to the EA for testing, 3800 to be exact. Daily option levels for several instruments only for this year. what is the solution?

If for testing, it turns out that all information in these files must be unchangeable (archived). I'd try writing two functions: one resets all the data from hundreds of files into one file, the other reads that file according to well-defined rules. Have you tried it that way?
 
Yedelkin:
If for testing, it turns out that all information in these files must be unchangeable (archived). I'd try to write two functions: one resets all data from hundreds of files to one file, the other reads this file according to well-defined rules. Have you tried it that way?
I haven't tried it yet, but the idea to collect into one file is understandable. Maybe the developers will indicate an option - a way to connect unchangeable data from a folder.
Reason: