[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 651

 
xtonic:

Evening riddles from metha:

I imported quotes from the quote archive, it says in 1 minute: Database: 0 / 3665972, window is empty - what can it mean ?

When I open standalone EURUSD,M1 chart - it shows big letters: "Pending Update" - what can it mean ?

I am running a test - TestGenerator: no history data 'EURUSD1'.

Reload the terminal. If everything was done correctly, it should appear.

 

where to read how an indicator with the following parameters is drawn

SetIndexStyle(0,DRAW_HISTOGRAM, 0, 1, color1)

SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1, color2)

I do not understand why sometimes it draws sometimes not - I understand it very well if you draw a normal line DRAW_LINE - the indicator buffer value will set the y-axis, but the element number corresponds to the number of bars on the chart

why the horizontal segment on the bar appears when two indicator buffers are on the same bar, but when one of the indicator buffers is EMPTY_VALUE - nothing, and I don't understand the coloring logic

 
ToLik_SRGV:

Reload the terminal. If everything has been done correctly, it should appear.


I've already done all this, even rebooted the system, that's the point.

 
xtonic:


I've already done all that, even rebooted the system, that's the point.


Have you imported quotes from where?

If you could explain exactly what you were doing, step by step, then you would be more likely to get help here.

 

Good people, have mercy - I can't get: buy/sell after another peak of smoothed CCI.

I tried to declare the second buffer (it makes more sense to me), no errors, the log is silent, the printer, apparently, I'm putting it like a goat - I don't understand anything.

 // Торговые критерии
   double c1b[];
   ArrayResize(c1b,PeriodB);
   double c1b_1[];
   ArrayResize(c1b_1,AvgB);
   for(i=1;i<=PeriodB;i++)
   {
   c1b[i]=iCCI(NULL,0,PeriodB,PRICE_TYPICAL,i);
   {
   c1b_1[i]=iMAOnArray(c1b,0,AvgB,0,MODE_SMA,i);
   }
   }
   
   double c1s[];
   ArrayResize(c1s,PeriodS);
   double c1s_1[];
   ArrayResize(c1s_1,AvgS);
   for(i=1;i<=PeriodS;i++)
   {
   c1s[i]=iCCI(NULL,0,PeriodS,PRICE_TYPICAL,i);
   {
   c1s_1[i]=iMAOnArray(c1s,0,AvgS,0,MODE_SMA,i);
   }
   }

if (NormalizeDouble(c1b_1[i],4)<NormalizeDouble(c1b_1[i+2],4)&&NormalizeDouble(c1b_1[i+2],4)>NormalizeDouble(c1b_1[i+3],4))
     {                                          // 
      Opn_B=true;                               // Критерий откр. Buy
      Cls_S=true;                               // Критерий закр. Sell
     }
if (NormalizeDouble(c1s_1[i],4)>NormalizeDouble(c1s_1[i+2],4)&&NormalizeDouble(c1s_1[i+2],4)<NormalizeDouble(c1s_1[i+3],4))
     {                                          // 
      Opn_S=true;                               // Критерий откр. Sell
      Cls_B=true;                               // Критерий закр. Buy
     }

Attachment contains the entire Expert Advisor. After testing in visualization, CCI is drawn both in this and old version (it is plotted in the attached file), but smoothed one is not and therefore trades are not opened.

Old variant:

// Торговые критерии
   double c1b[];
   for(i=1;i<=PeriodB;i++)
   {
   c1b[i]=iCCI(NULL,0,PeriodB,PRICE_TYPICAL,i);
   }
   double c1b_1=iMAOnArray(c1b,0,AvgB,0,MODE_SMA,1);
   double c1b_2=iMAOnArray(c1b,0,AvgB,0,MODE_SMA,2);
   double c1b_3=iMAOnArray(c1b,0,AvgB,0,MODE_SMA,3);
   
   double c1s[];
   for(i=1;i<=PeriodS;i++)
   {
   c1s[i]=iCCI(NULL,0,PeriodS,PRICE_TYPICAL,i);
   }
   double c1s_1=iMAOnArray(c1s,0,AvgS,0,MODE_SMA,1);
   double c1s_2=iMAOnArray(c1s,0,AvgS,0,MODE_SMA,2);
   double c1s_3=iMAOnArray(c1s,0,AvgS,0,MODE_SMA,3);

if (NormalizeDouble(c1b_1,4)<NormalizeDouble(c1b_2,4)&&NormalizeDouble(c1b_2,4)>NormalizeDouble(c1b_3,4))
     {                                          // 
      Opn_B=true;                               // Критерий откр. Buy
      Cls_S=true;                               // Критерий закр. Sell
     }
if (NormalizeDouble(c1s_1,4)>NormalizeDouble(c1s_2,4)&&NormalizeDouble(c1s_2,4)<NormalizeDouble(c1s_3,4))
     {                                          // 
      Opn_S=true;                               // Критерий откр. Sell
      Cls_B=true;                               // Критерий закр. Buy
     }

I understand no one has time to clean up the others, advise me at least where exactly to insert the Print and where to look for feedback in the journal or logs and what you need to pay attention to.

Files:
21.mq4  15 kb
 

Good afternoon!

I have a question about partial closing, because each brokerage company has its own rules. I do not understand how to do the order accounting correctly:

The problem: We need to find a tick of a newly placed order in this particular TS without using a magician.

1) I have noticed that a partly closed order has a comment, you should be able to read the comment // I am not sure that all brokerage companies write comments

2) search by date of order opening // not sure if it will work for all brokerage companies

3) look for a new tick right after a partial closing and check the volume, etc. to see if it is the right order

4) something else

 
wenay:

how to do the order counting better:

read the help there:
comment - Order comment text. The last part of the comment can be changed by the trade server.

magic - The magic number of the order. Can be used as a user-defined identifier.

Magic is a good way to help you

To search for an order, do the following

if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {

.......

 
Craft:

Please advise where exactly Print should be inserted and where to look for feedback in the logbook or log files and what you need to pay attention to.

Print where you want to check the situation (for example, if you place an order - print the fact of placing or an error of placing the order in the journal).

If you are not sure that your function can be called, i.e. the function call condition will never be met, add the Print to the input of the function.

Print read in the terminal in the "Experts" tab

 
IgorM:

where to read how an indicator with the following parameters is drawn

SetIndexStyle(0,DRAW_HISTOGRAM, 0, 1, color1)

SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1, color2)

I don't understand why sometimes it draws sometimes not - I understand if you draw a normal line DRAW_LINE - the indicator buffer value will set the y-axis, but the number of the element corresponds to the number of bars on the chart

what are the parameters in the indicator buffer when its type is DRAW_HISTOGRAM?? why when two indicator buffers end up on one bar, a horizontal segment on the bar appears, but when one of the indicator buffers is equal to EMPTY_VALUE - nothing, and I do not understand the coloring logic

Thestyle of DRAW_HISTOGRAM is not fundamentally different from other styles of drawing lines, the X-axis is represented by bar numbers, the Y-axis - by the values of the indicator array, but as they say, there is a nuance.
Let's take a simple indicator as an example:

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_width1 2
double SIMPLE[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init(){
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0, SIMPLE);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start(){
   for(int shift = Bars-IndicatorCounted()-1; shift >= 0; shift--){
      SIMPLE[shift] = 1;
   }
}
//+------------------------------------------------------------------+

One indicator array, separate window, all elements are assigned value 1. Throw it on the chart, and what do we see (Figure 1 on the left):

The "Data Window" shows the indicator readings, but there is nothing in its window. This is the nuance, MT4 just doesn't know 1 is how high? How high should the bar be drawn? It has nothing to draw from, i.e. simply put, there is no division price for the bars. As you have noticed, there is no separate parameter that sets the height of the bars, their height is set automatically, relative to other elements. Let us help MT4 and set the division price, we can do it programmatically:

#property indicator_minimum 0
#property indicator_maximum 2

You can simply fix minima (say 0) and maxima (say 2) in the indicator settings.
And everything instantly falls into place (Fig. 2, right), now the terminal knows how high the bar should be drawn, 1 is in the middle between 0 and 2 :))) In this example, the indicator array has one value (especially for showing "nuance") and we should indicate to the terminal how much or little it is. If we replace the array data with 1, for example Close[shift], the terminal will not set any hard constraint and will draw a picture "ala MAKD".

A little different picture, if we draw the bar chart in general, not in a separate window. Let's leave the value of Close[shift] for the first indicator array, just change the parameter:

#property indicator_chart_window

We get the same picture again (Fig. 3, left). The values are present but not displayed.

The terminal needs some basis for automatic calculation of the bar height, and since minimums and maximums cannot be fixed in the general window, the second indicator array will appear. We add the second line and set it to 0.

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_width1 2
#property indicator_color2 Red
#property indicator_width2 2
double SIMPLE[];
double SIMPLE2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init(){
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0, SIMPLE);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1, SIMPLE2);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start(){
   for(int shift = Bars-IndicatorCounted()-1; shift >= 0; shift--){
      SIMPLE[shift] = Close[shift];
      SIMPLE2[shift] = 0;
   }
}
//+------------------------------------------------------------------+

Indicator arrays start to display relative to each other. And everything will be as it should be (Fig 4, right). The columns are drawn from SIMPLE[shift] to SIMPLE2[shift].

And finally, there is the code of indicator which fills in the candles, blue if it is up and pink if it is down. Again two arrays for each colour (the drawing is from home to end (from Open to Close)).

//+------------------------------------------------------------------+
//|                                                       SIMPLE.mq4 |
//|                        Copyright © 2010,Анатолий Сергеев  |
//|                                            mql.sergeev@yandex.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Анатолий Сергеев"
#property link      "mql.sergeev@yandex.ru"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_width1 2
#property indicator_color2 Blue
#property indicator_width2 2
#property indicator_color3 Pink
#property indicator_width3 2
#property indicator_color4 Pink
#property indicator_width4 2
double Blue_home[];
double Blue_end[];
double Pink_home[];
double Pink_end[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init(){
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0, Blue_home);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1, Blue_end);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2, Pink_home);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexBuffer(3, Pink_end);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start(){
   for(int shift = Bars-IndicatorCounted()-1; shift >= 0; shift--){
      if(Close[shift] > Open[shift]){
         Blue_home[shift] = Open[shift];
         Blue_end[shift] = Close[shift];
      }else{
         Pink_home[shift] = Open[shift];
         Pink_end[shift] = Close[shift];
      }
   }
}
//+------------------------------------------------------------------+

 
IgorM:
read the help there:
comment - Order comment text. The last part of the comment can be changed by the trade server.

magic - The magic number of the order. Can be used as a user-defined identifier.

Use magic to help you

To check for an order, do the following:

if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {

.......



Task: You need to find the tick of a newly appeared order for this particular TS without using a magik .
Reason: