[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 134

 
klyuchnikk:

Hello all.

I have an Expert Advisor that works on history (for analysis). I manually set a parameter in it - the time (hours, minutes) of placing orders. I run the EA within the set date range, change the order times and run it again. I do it 96 times (after 15 min) a day. How can I loop it so that it does this by itself?

Can I help you?
 
artmedia70:
Once again I ask: When exactly do you want to place the order? Do not answer with your code (I don't want to understand it - we have enough of our own codes for analysis), but just in words,

e.g.: I want to put a pause above/below the MA at that distance, provided that ... ...yada yada yada yada ...

For the second time I'm asking you to explain. We would have solved your problem long ago.


At the moment the problem is this: fastMa crossed slowMa up... ...so we're looking for where to buy. Then we wait until the price i.e. Ask (since we consider buying) will reach fastMa ( well, I guess there will be no exact value, we need +- some deviation, it is renamed i_thresholdFromMa) and as soon as the price reaches fastMa +- i_thresholdFromMa , Expert Advisor should place BUYSTOP at (fastMa + buyHear * pt).

What I have come up with does not work in one terminal and does not always work in another one. Something is wrong in general.

The last variant of buyHear function here:

//+-------------------------------------------------------------------------------------+
//| Открытие длинной позиции                                                            |
//+-------------------------------------------------------------------------------------+
bool OpenBuy()
{
   int ticket = -1;
   double OOP = fastMa + buyHear * pt;
   
   if ((ND(OOP) - Ask) >= g_stopLevel)           
   {
       if (ND(OOP) > Ask)           // Проверка что цена открытия выше Ask, т.к. у нас вход отложенником
       {
           ticket = OrderSend(Symbol(), OP_BUYSTOP, 0.1, ND(OOP), 3, 0, 0, NULL, i_magic, 0);
       }
   }
   if (ticket > 0)
   {
       return (true);
   }
   else
    
   Alert (GetLastError());
}
Here are the input parameters:
extern double i_thresholdFromMa = 5;                           // Отступ от МА
extern double buyHear = 10,                                    // Расстояние от МА до отложки на бай

int init()
{
   if (Digits == 1 || Digits == 3 || Digits == 5)
       pt = Point * 10;
}

Errors can be seen on the screenshot (in OrderSend() the price is fed above the red bead, while the order as seen on the screenshot is below....):

opening price joint

artmedia70:
And another thing: if you have fastMA and slowMA defined as global, why do you pass them into functions? All functions can see them anyway, without passing their parameters to the called function.

And before they were not global, they were declared in specific functions, not in start. But since they were used in none of the functions, getting them every time was somehow, let's say, a sign of "bad manners as a programmer" and it's not comfortable to have identical lines of code in different functions.

Artyom, do you think I get the right wrist at the start? I mean, that on each tick the value will be received. Isn't it too expensive? Because I'm not a programmer by education, these questions sometimes occur to me...

 
Tincup:

The answer is not quite clear to me, so let me ask again. Did I understand you correctly that when setting trading conditions

You should use the MA value for the corresponding number of bars backwards, but not the value marked with a yellow arrow in the picture.

I drew the figure as I understood your answer.



Actually the question is a bit off. The matter is not the shift of the curve but the value at which bar the Expert Advisor needs to get from the buffer. This is what needs to be understood. And there is NO correspondence between the bias and getting the value from the buffer.
 

hello

first question


A=true

if the Imacd value(Main Line) 15 minutes ago is less than 30 minutes ago

 
Claus084:

hello

first question

A=true

if the Imacd value (Main Line) 15 minutes ago is less than 30 minutes ago

No, better forward!
 
double iMACD( string symbol, int timeframe, int fast_ema_period, int slow_ema_period, int signal_period, int applied_price, int mode, int shift)
Calculation of the Moving Averages Convergence/Divergence indicator. In the systems where OMA is called MACD histogram, this indicator is drawn as two lines. In the client terminal, the convergence/divergence of moving averages is drawn as a histogram.
Parameters:
symbol - Symbol name of the symbol, on data of which the indicator will be calculated. NULL means current symbol.
timeframe - Period. Can be one of the periods of the chart. 0 means period of current chart.
fast_ema_period - Averaging period for calculating the fast moving average.
slow_ema_period - Averaging period for calculating a slow moving average.
signal_period - Averaging period for signal line calculation.
applied_price - Price used. Can be any of the price constants.
mode - Indicator line index. Can be any of the indicator line identifier values.



The question here is


if I understand it correctly
- Index of the value received from the indicator buffer (shift relative to the current bar by the specified number of periods back).


number of what periods?
or how do I get the value of the macd from the previous bar instead of the current one?

int start ()
{
bool A=trueif
(iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_MAIN,1)<iMACD(NULL,15,12,26,9,PRICE_CLOSE,MODE_SIGNAL,2)) { A==true; } return; }


 

Click on thechart periods and see which periods! And find the previous bar(shift = 1) to the current bar(shift = 0) in the last place:

double MA0 = iMACD(symbol,timeframe,fast_ema_period,slow_ema_period,signal_period,applied_price,mode,0);//текущий бар
double MA1 = iMACD(symbol,timeframe,fast_ema_period,slow_ema_period,signal_period,applied_price,mode,1);//предыдущий бар


Or better yet, start studying S. Kovalev's textbook!
 
Please advise, in the "open prices" testing mode, does the tester only use the open, or the open, close, high and low prices?
 
xant:

Hello again.

Please advise how to solve the following problem.

There is an indicator in compiled form. The code is not available. The indicator reflects price levels in the main chart window. I want to use these levels for my EA but it's impossible to call the indicator using the iCustom() function - the displayed levels are graphical objects. Is it possible to read the data otherwise, for example, through the object names and time? The names of all the levels are known (available in the indicator settings), the objects are updated once a week.

I want to say right away that I am not very experienced in programming, I would be very grateful for a useful reply.

This is a good idea. Graphical objects are recognized by name. Levels can be specified by two (basic) types of graphical objects: OBJ_TREND (trend line) and OBJ_HLINE (horizontal line). As I understand it, you need two properties of these objects (price and possibly time):

    //---- Уровень для горизонтальной линии
    double ld_Level = ObjectGet (Name, OBJPROP_PRICE1);
    //---- Уровень для трендовой линии на текущем баре
    ld_Level = ObjectGetValueByShift (Name, Bar);
    datetime ldt_Time = ObjectGet (Name, OBJPROP_TIME1);
Something like this.
 
Sancho77:
Please advise: in the test mode by "open prices", does the tester use only the open, close, high and low prices?

Yes, only open prices, that's why it's important to consider it when analyzing the EA. For example, if the tail of the candle breaks your channel, then the EA may not notice it, but you can write this in the program logic and solve the problem.

Reason: