[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 24

 

It was already running. It didn't predict the opening signal for a long time, and the air was supplied by the same timer.

In short, Paul died.

 
Can anyone advise: It's a trivial question , but I can't seem to solve it all day long. How to make the EA open an order at the opening of a candle, and if it closes on the same candle, not to open until the appearance of a new candle. The problem here is that when the signal opens, let's say the order is closed on the same candlestick, so the signal is in force, but it is no longer relevant because the robot was written for the opening price. I remember there was a way, but I can't remember it.
 

The flag is called.

As the order opens, assign OrderIsOpened=true. When a new candle opens - ...=false, and so on.

 
tara:

The flag is called.

As the order opens, assign OrderIsOpened=true. When a new candle opens - ...=false, and so on.

Thank you. And how to code the opening of a new cand le?
 
kwadrad:
Thank you. And how to code the opening of a new candle?


Whatever you like - it's all in your hands. For example:

- when time changes by TF size (easiest)

- when the "new" open price differs from the "old" one

by the same "flag" technology.

You're welcome.

 
kwadrad:
Thank you. And how do you code the opening of a new candle?
Explore with a search engine.
 
Fartarantula:

Hello dear mql people. Here comes my first code problem.

It is a trend indicator. The task is a trend indicator with coordinates 1-th line = max of last day and the day before and 2-th line = min of last day and the day before.

It would be OK, but when you switch to a lower timeframe, the coordinate is clinging to the beginning of the day, although at the corresponding price level.... and the sense of the line is completely lost.

When creating a trendline object, the datetime parameter is to blame. I cannot think how to get to it. It is necessary to calculate the time of formation of price extrema. It appears that this information

It appears that this information is embedded in the 1-minute timeframe. How to determine the datetime when the timeframe changes so that a trend is re-drawn and coordinates are attached to bars corresponding to extrema.

Unfortunately, the search has yielded nothing on the subject. I would be grateful for advice.

I understand that the procedure of code writing itself causes difficulties.

I offer you the following way of solving this task:

// Ваша трендовая по High на дневном таймфрейме
datetime Time1 = iTime(Symbol(), PERIOD_D1, 1);
double   High1 = iHigh(Symbol(), PERIOD_D1, 1);
datetime Time2 = iTime(Symbol(), PERIOD_D1, 2);
double   High2 = iHigh(Symbol(), PERIOD_D1, 2);
ObjectCreate("High_Trend", OBJ_TREND, 0, Time2, High2, Time1, High1, 0, 0);

// Ищем точное время High'ев на таймфрейме PERIOD
int PERIOD = PERIOD_M5;

int BarTime1 = iBarShift(Symbol(), PERIOD, Time1);
int BarTime2 = iBarShift(Symbol(), PERIOD, Time2);
Time1 = iTime(Symbol(), PERIOD, 
      Highest(Symbol(), PERIOD, MODE_HIGH, BarTime1, 1));
Time2 = iTime(Symbol(), PERIOD, 
      Highest(Symbol(), PERIOD, MODE_HIGH, BarTime2, BarTime1+1));

ObjectSet("High_Trend", OBJPROP_TIME2, Time1);
ObjectSet("High_Trend", OBJPROP_TIME1, Time2);

The only problem is that if you launch the Expert Advisor with this code in the Strategy Tester and set PERIOD variable to PERIOD_M1, both iBarShift functions return -1, i.e. the function cannot find a bar on TF M1 with the same time in the history... I don't know why it happens.

I found out why! There was no history for M1 bars on the tested period.

 
alex12:

I need to view the price behaviour over the entire history of the instrument by MA, but the indicator is not drawn when inserted in the chart.

What is the problem?

When compiled = 0 and 0.

By the way - MT4 terminal hangs!

Set the History and Aver_Bars input parameters to a smaller value and the terminal will stop "hanging".

What makes you think that the indicator is not drawn when attached to a chart? This is what your indicator drew when I placed it on today's chart for EUR/USD TF M1:


:D :D :D

 
artmedia70:
When this error occurs (division by zero), the EA stops working. Look for a place in the code where division by zero occurs - most likely, zero is obtained as a result of calculation of some parameters.
Thank you, I have figured it out. I will check it at the weekend.
 

Hello, dear forum members.

Of course, I have some questions from a newcomer. I am trying to learn mql4, since I have never developed any program before, so the questions may be very primitive. But I've never been able to do them myself.

I've decided to "mess up" with displaying volumes by drawing a line instead of a bar chart with some processing. The code should make the following sense. Starting from the second bar which is in the same direction as the previous bar (both of them are up), the volume is drawn from the second bar. As a result, I get a broken line in the indicator window, which is indeed drawn from the second bar upwards, but not in all cases for some reason. The line is interrupted because other conditions of its drawing are not defined at all, it is a thing of the future. But here myself to understand why the line is not drawn on every second bar upwards, I can not. Please help me.

Here is the code. If you have any other comments on other bugs in the code, I will be glad to help you.

double dVolume=Volume[i];
double vback1=Volume[i+1];

         {
         double vteor12=(dVolume+vback1)/2;
            if (Close[i+1]>Open[i+1] && Close[i]>Open[i]) double UP12=(Close[i]-Open[i+1])*1000; else UP12=0;
            if (UP12!=0) double vrealUP12=(dVolume+vback1)/UP12; else vrealUP12=0;
            if (Close[i+1]>Open[i+1])
            if (Close[i]>Open[i])
            ExtVolumesBuffer[i]=dVolume+vteor12-vrealUP12;
            if (ExtVolumesBuffer[i]<0) ExtVolumesBuffer[i]=0;
              }
Reason: