Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 691

 
borilunad:

Little mistake: 0=Close, 1=Open, the rest is correct.

Open is not needed. The main task was how to put variables in the tester to make EA runs based on the indicator, which can be built on different types of prices.

Here we should not forget to set price from 1 to 6, in increments of one, when optimizing.

 
rambo:
Can you please tell me if an EA written for MT5 can be run on the latest MT4 and vice versa?
If it compiles, you can run it, but will it work as intended, that's the question.
 
Forexman77:

Open is not needed. The main task was how to put variables in the tester to make EA runs based on the indicator, which can be built on different types of prices.

Here we should not forget to set price from 1 to 6, in increments of one, when optimisation is carried out.


But the Open price is 1, the Close price is 0. See Doc!
 
Forexman77:

If anyone needs it, I've worked out how to do a price-type indicator rendering without complicated constructions:

input ENUM_APPLIED_PRICE price=0;

price=iMA(NULL, 0, 1, 0, MODE_SMA, price, i);

This may be easier, but if you need to add more price types, it's certainly better to do it your way, or rather a combined way
 
evillive:
If it compiles, you can run it, but whether it will work as intended is the question.

thanks
 
Vinin:

Maybe it's easier, but if you need to add more types of prices, then of course it's better to do it your way, or rather a combined method

That's genius! I hadn't thought of this method.

 
borilunad:

But the Open price is 1 and the Close price is 0. See Doc!

If you use "ENUM_APPLIED_PRICE" enumerations.

But I don't use them, I just use a conditional operator to check all six options for truth and only one condition always works.

For example, the condition worked and we calculated the price:

if(price==5)ExtMapBuffer1[i]=((High[i]+Low[i]+Close[i])/3);//рассчитали весь буффер индикатора 
I receive the close price to be calculated. That is, I prepare the prices myself and do not take them from enumeration "ENUM_APPLIED_PRICE".
 
Forexman77:

That's genius! I hadn't thought of that way.


This method will work only when calling technical indicators, if you have to change price type in other calculations through settings (say, you want to compare some value with Close[i] and pass it through optimizer to (High[i]+Low[i])/2, i.e. with PRICE_MEDIAN), it will not work.
 
evillive:

This way will work only when calling technical indicators, if you have to change price type in other calculations through settings (for example, you compare some value with Close[i] and want to pass through optimizer to compare it with (High[i]+Low[i])/2, i.e. with PRICE_MEDIAN), it will not work.

Prices are only needed to calculate the indicator.

I did it like this:

extern ENUM_APPLIED_PRICE price=PRICE_CLOSE;

for(i=limit1;i>=0;i--) ExtMapBuffer1[i]=iMA(NULL,0,1,0,MODE_SMA,price,i);

Compared this variant and its all the same when changing.

 
Forexman77:

If you use "ENUM_APPLIED_PRICE" enumerations.

But I don't use them, I just use a conditional operator to check all six options for truth and only one condition always works.

For example, the condition worked and the price was calculated:

I get the closing price for the calculation. That is, I prepare the prices myself and do not take their enumeration "ENUM_APPLIED_PRICE".


It is possible to redo everything, but it will only work in this particular case! It is better to proceed from documented constants to avoid confusion in the future!