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

 

A couple of days ago I downloaded the EA "e-MoveSLTPbyMouse" (thanks Granit) and tried it out on Broco trading platform, works fine. Today I decided to use it with IBFX and saw that it did not work. Some kind of additional line has appeared, which "bounced" off the price, then the market successfully passed the stop loss line and I had to manually close the position with a small loss. Any thoughts on that? What can I do to make my Expert Advisor work with IBFX? Or maybe there is something similar in somebody's arsenal?

One more question. I have an EA that opens positions with horizontal lines but unfortunately it only opens 3-4 pips from the set price. For example, I put a line to SELL at 1.4018 with 1 pip to break it (EUR) and the position opened at 1.4015, i.e. it has slipped by 2 pips. On GBP, it overshot by 3 pips. Maybe someone has a similar EA, but it would work properly. I would be very grateful.

I am posting this EA, maybe someone will need it.

Files:
 

Gentlemen Experts, I would like to use in my Expert Advisor a sliding indicator on a chart.

If I attach the sliding indicator to the chart manually, the parameter Apply to can be written as previous indicator's data, but how should I do it in my EA?

I think it would be logical to apply the OnArray function, but I don't know where to take the array with the data of the first МА.

For example, I need the following: if the first МА (21) is higher than the second MA (21) (built on the first MA) then..................

And another question: if my Expert Advisor has the following function call: iMA(0,0,250, 0,1,0,0), then every tick it will take these 250 bars close, sum them and divide by 250? However, it is not so. And if I use one more sliding bar, the price will go down... Please clarify.



 
mukata писал(а) >>

Gentlemen Experts, I would like to use in my Expert Advisor a sliding indicator on a chart.

If I attach the sliding indicator to the chart manually, the parameter Apply to can be written as previous indicator's data, but how should I do it in my EA?

I think the iMAOnArray function makes sense, but I don't know where to take the array with the first MA's data, please, enlighten me or provide me with a link to such a construction, or the construction itself, if it exists.

For example, I need the following: if the first МА (21) is higher than the second MA (21) (built on the first MA) then..................

And another question: if my Expert Advisor has the following function call: iMA(0,0,250, 0,1,0,0), then every tick it will take these 250 bars close, add them and divide by 250? However, it is not so. And if I use one more sliding bar, the price will go down... Please, explain.

The easiest way to make an indicator.

 
Vinin >> :

The easiest thing to do is to make an indicator.

Let's make an indicator, where do we get the data array? Give me a hint about the construction, the textbook doesn't have it...

And the second question?

 
mukata писал(а) >>

Let's have an indicator, where do we get the data array? Please give me a hint about the construction, the textbook doesn't have it...

And the second question?

On the second question. It all depends on the implementation. You can calculate the wizard yourself by optimizing the code. You may calculate only the bar opening. There are a lot of variants.

But the best option is to use the indicator. In which all calculations are performed, and the Expert Advisor reads them (calculated values).

Here is an example of an indicator

I changed the indicator

Files:
 
Vinin >> :

On the second question. It all depends on the implementation. You can do your own calculation by optimising the code. You may calculate only by bar opening. There are a lot of variants.

But the best option is to use the indicator. In which all the calculations are performed, and the Expert Advisor reads them (the calculated values).

1) "You can calculate the tool yourself by optimizing the code" - I don't understand this line. I understand: on every tick start is called, and if there is call of function iMA(0,0,250,0,1,0,0), then every time it will add and divide these 250 bars. And if we create the indicator correctly, it will count only the last bar, and the last shift parameter will be read from the array. Right?

2) Where do you get the array to create the second MA?

 
mukata >> :

2) Where can I get an array for calculating the second MA?


Right! I forgot, the indicator creates an array of MA values...

Thank you very much.

 
mukata писал(а) >>

1) "You can calculate the machine yourself by optimizing the code" - I don't understand this line. I understand: on every tick start is called, and if there is call of function iMA(0,0,250,0,1,0,0), it will add and divide these 250 bars every time. And if we create the indicator correctly, it will count only the last bar, and the last shift parameter will be read from the array. Right?

2) Where can we get an array for creating the second MA?

1. It all depends on the implementation. There are optimal methods of calculation. iMa() uses its own calculation algorithm. CodeBase has them. So when you use it, the calculation mechanism works which is hidden from you. You only get the result. And the calculation will be performed every tick.

2. I have made this indicator specially to help you to understand arrays.

 
Vinin >> :

1. It all depends on the implementation. There are optimal methods of calculation. iMa() uses its own calculation algorithm. CodeBase has them. So when you use it, the calculation mechanism works which is hidden from you. You only get the result. And the calculation will be performed every tick.

2. I have made this indicator specifically to help you understand arrays.

Thank you very much for the indicator, I looked at the start function, everything became clear at once.

About the first question:

For example, in my Expert Advisor (not MA, but also a built-in function):

//пересекла ли главная линия стохастика сигнальную линию сверху вниз
if(iStochastic(Symbol(),0,KperiodF,DperiodF,SlowlingF,methodF,PriceFieldF,0,shiftF)>
iStochastic(Symbol(),0,KperiodF,DperiodF,SlowlingF,methodF,PriceFieldF,1,shiftF)&&
iStochastic(Symbol(),0,KperiodF,DperiodF,SlowlingF,methodF,PriceFieldF,0,0)<
iStochastic(Symbol(),0,KperiodF,DperiodF,SlowlingF,methodF,PriceFieldF,1,0)
){
//и обе линии ниже 90
if(iStochastic(Symbol(),0,KperiodF,DperiodF,SlowlingF,methodF,PriceFieldF,0,0)<90&&
iStochastic(Symbol(),0,KperiodF,DperiodF,SlowlingF,methodF,PriceFieldF,1,0)<90
){
//и выше 50
if(iStochastic(Symbol(),0,KperiodF,DperiodF,SlowlingF,methodF,PriceFieldF,0,0)>50&&
iStochastic(Symbol(),0,KperiodF,DperiodF,SlowlingF,methodF,PriceFieldF,1,0)>50
)
fl=1;return(fl);//продать
}
}

is it going to count it on every line?

Or one should write an indicator and take values from its arrays and compare them, or something else. To make it work faster.

 
mukata писал(а) >>

Thank you very much for the indicator, looked at the start function, everything became clear at once.

About the first question:

In my EA for example (not MA, but it's also a built-in function):

//пересекла ли главная линия стохастика сигнальную линию сверху вниз
if(iStochastic(Symbol(),0,KperiodF,DperiodF,SlowlingF,methodF,PriceFieldF,0,shiftF)>
iStochastic(Symbol(),0,KperiodF,DperiodF,SlowlingF,methodF,PriceFieldF,1,shiftF)&&
iStochastic(Symbol(),0,KperiodF,DperiodF,SlowlingF,methodF,PriceFieldF,0,0)<
iStochastic(Symbol(),0,KperiodF,DperiodF,SlowlingF,methodF,PriceFieldF,1,0)
)

Is it going to count it on every line?

Or should I write an indicator, and take values from its arrays and compare them, or something else. So that it would work faster.

First, it is better to calculate the values of the stochastic and the signal line. And then compare them. I simply do not like this style. It results in some kind of blindness. And it is easier to make a mistake.

If() in the metaquotes variant makes full calculation of the logical expression. It would be desirable to make it as simple as possible. It is just if() is one of the slowest operations.

There is also such a notion as "chattering" on the zero bar. There may be cases when the signal will be repeated on one bar more than once. And it may even fail to lock. It was a false signal. This is why we try to take values from the formed bars. But in this case we should use the opening prices. But there may be other variants.