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

 
FOTOGRAF14:
if(Close[1]<High[i] && Close[1]>Low[i])

i++;

how can i make a condition to be checked on the next bar, not on every tick?

I have this construction

static datetime TimeN=0;  


void OnTick()
  {

datetime TimeC=iTime(NULL,TF,0);
   if(TimeN==0)TimeN=TimeC;
   if(TimeN==TimeC) return;
   TimeN=TimeC;

 
-Aleks-:

This approach works if the indicator works on the chart - and I need this in a script - on a ready-made chart.
Э... this approach works everywhere. From EAs, scripts, other indicators you will be able to get what you need. If you prepare an indicator to suit your specific needs.
 
Alexey Kozitsyn:
Э... this approach works everywhere. You can get what you need from EAs, scripts, other indicators. If you prepare the indicator for your specific needs.

I don't understand.

"In OnCalculate(), when the rates_total > prev_calculated condition is met - calculate the indicator and write the value to this extra buffer;"

What do we record? The value of the indicator on the last bar, no?

 
-Aleks-:

I don't understand.

"In OnCalculate(), when the rates_total > prev_calculated condition is fulfilled - calculate the indicator and write the value to this additional buffer;".

What do we write? The indicator value on the previous bar, no?

We record what we calculate.
 
Alexey Kozitsyn:
Let's write down what we calculate.

Then it's a dumb move to change the MASK calculation - count the same MASK twice.
 
-Aleks-:

Then it is dumb to change the calculation of the MAK - to count the same MAK twice.

Have you written a single indicator from scratch to judge what is "dumb" and what is not?

Anyway, good luck in solving the problem. I am withdrawing from the discussion.

 
Alexey Kozitsyn:

Have you written a single indicator from scratch to judge what is "dumb" and what is not?

Anyway, good luck in solving the problem. I am withdrawing from the discussion.

Yes, I write indicators for personal use, but without OnCalculate().

"Dumb" refers to the method, not its author, I certainly didn't mean to offend anyone...

I'm talking about about such solution for simple MA[n]-Close[n]/period+Open[n]/period

I'm interested in similar solutions for other ways to calculate MAs.

 
Alexander Antoshkin:

I'm not a good speaker. If I start talking I will discredit the science.)

Find Albert Buraga with his theme "Beyond the market" he has been discussing this topic for a long time, and listen to ...... algorithms and calculations are all there, his group is in contact

there is no need to put up a link to his site - they will delete it. show your interest and you will find it...... I am not his student and do not want to advertise it, but I have taken for myself 1/3 of what he says is missing.

My work screen looks like this: Trading from Friday ...I've hardly been near my computer ... 80% of the time I was working with pending orders and profit on previously calculated levels...

...and that's the way it is every day

Thanks for the info - I'll look into it. I understand he's on smartlab too.

 
I looked through a lot of literature on the web, advise which textbook, author, or a course for free or video courses.
 

Hi, could you please advise how to solve this problem: at RSI>50 variable x is counted once and at RSI<50 variable y is counted once (I wrote this part in the code) and at RSI>70 variable x value is subtracted from current price (this part is the problem). The code is as follows:

1 part:

bool RSI_HIGHER_50=false;
bool RSI_LOWER_50=false;
void OnTick()
{
double RSI=iRSI(NULL,0,14,PRICE_CLOSE,1);
double x;
double y;
double z;
{
if (RSI>50&& !RSI_HIGHER_50)
{
x=MarketInfo(NULL,MODE_BID);
RSI_HIGHER_50=true;
RSI_LOWER_50=false;
}
}
{
if (RSI<50 && !RSI_LOWER_50)
{
y=MarketInfo(NULL,MODE_ASK);
RSI_LOWER_50=true;
RSI_HIGHER_50=false;
}
}
}

2 part:

if (RSI>70)
{
z=Close[1]-x;
}

If you just connect these parts, the z variable will not be calculated correctly. Is it possible to fix/save the value of variable x for further operations with it? How to achieve correct calculation of variable z under the above condition?

Thank you.

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
Reason: