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

 

i.e. it is assumed that the array is full and the average spread is found then

if ( CountedSpred == true)

{

if (Bid <= Low && Ask< High -CountedSpred/2*delta )

return(10);

if ( Bid>= High )

return(20);

}

 

First, make a small EA that simply collects the spread history. Save it to a file at certain intervals.

 
Vinin:

First, make a small EA that simply collects the spread history. Save it to a file at certain intervals.

I thought about it, but it is necessary to count the spread in the EA, because let's say the average spread over 100 ticks is 6 points and then the condition to buy coincides, but in the same moment the spread is 12, then according to the condition we will open, and we should have skipped this signal, so I think that a separate script will not work, and if it does it should be bound to the EA, but unfortunately I don't know how.
 
ex_kalibur:

// Calculation of trading criteria

if (Bid <= Low && Ask< High -CountedSpred/2*delta)

return(10);

if ( Bid>= High )

return(20);

Here I got stuck. According to the task we should first obtain the history of average spread, how should I do that?

we need an array of 100 cells to be filled completely

When the EA starts, this array will mostly be filled with the current spread. Do you understand what 100 ticks is? Calculate the arrival period of a new tick and multiply by 100 - that's how long it will take to fill the array, but... it's unlikely that the spread will change during this time. So, for the first start, you need to fill the array with the current spread and start the EA with this data. Then, with strong market volatility, your brokerage company may increase the spread and expand the Stop Leverage - then the spread will get into an array and begin to fill it with new data. But I can't get it into my head - why do we need an average spread? If it is less than the actual spread, and it is possible, then you still have to work with the current spread. If the average spread is higher than the current one, it is likely that more favourable conditions will be missed.

Can we simply let the Expert Advisor work with the necessary limitations and not plant too many trees?

Let's arrange an array of spreads according to the expected values of these spreads and see... Let's take 50 ticks with a spread of 2 and 50 ticks with a spread of 10.

(50*2 + 50*10)/100 = (100 + 500)/100 = 6 And the spread is 10 ... And how will your Expert Advisor work in case of non-compliance with the trading conditions? Of course, the Expert Advisor will take the data on the current state of brokerage company conditions and will work with a spread of 10.

The question - why all the fuss with an array of spreads and calculation of the average, preceding the opening in any case according to the current conditions?

 
ex_kalibur:
I thought about it, but the need to consider the spread in the EA, because, say, the average spread over 100 ticks is 6 points, and then the condition to buy coincides, but in that very moment the spread was 12, we will open, and we have to skip this signal, so I think that a separate script will not work, and if it does, it should be tied to the EA, but, unfortunately, I don't know how yet

Weird. I have highlighted the oddities. With a spread of 6 pips, when the buy condition is matched, the EA has spread data = 6 pips. Accordingly, it works trying to meet those conditions. Now the spread has doubled - it has become 12 and you write: ". then by condition we will open ..."

I can assure you no. You will get an error from the trade server. The Expert Advisor will process this error and either not bother the server with more requests or it will correct the variable storing the spread value and enter the market with new conditions, respecting all the restrictions on the minimum distance...

 
artmedia70:

When the EA starts, this array will basically be filled with the current spread. Do you understand what 100 ticks is? Calculate the arrival period of a new tick and multiply by 100 - that is how long it will take to fill the array, but... it's unlikely that the spread will change during this time. So, for the first start, you need to fill the array with the current spread and start the EA with this data. Then, with strong market volatility, your brokerage company may increase the spread and expand the Stop Leverage - then the spread will get into an array and begin to fill it with new data. But I can't get it into my head - why do we need an average spread? If it is less than the actual spread, and it is possible, then you still have to work with the current spread. If the average spread is higher than the current one, it is likely that more favourable conditions will be missed.

Can we simply let the Expert Advisor work with the necessary limitations and not plant too many trees?

Let's arrange an array of spreads according to the expected values of these spreads and see... Let's take 50 ticks with a spread of 2 and 50 ticks with a spread of 10.

(50*2 + 50*10)/100 = (100 + 500)/100 = 6 And the spread is 10 ... And how will your Expert Advisor work in case of non-compliance with the trading conditions? Of course, the Expert Advisor will take the data on the current state of brokerage company conditions and will work with a spread of 10.

The question - why all the fuss with an array of spreads and calculation of the average, preceding the opening in any case according to the current conditions?

I see your point, I did not make it clear enough, the average spread still takes part in the formation of the corridor
 
Let's say the market is quiet (overnight), the average corridor is 8 pips (difference between nai and cat) but the spread is 10, do you think it makes sense to trade in the channel at this time
 

No, because we will be closing in the red all the time.

now we increase the volumes, the average spread rises to 12, but the channel draws 14, now we can take 2 points, and that is the average spread fits in the channel, respectively, at the entry signal if the spread is widening we skip it and wait for one more, because we know that the average spread is still 12, and it is possible that we enter not at 12 but at 7 or 8, but we can not enter at 16!!!! If we don't have this value, or if we have it as a fixed one, we can lose a lot of entries with a big spread

it is very important to buy because we open with Ask, i.e. the Bid touches the bottom line, but the spread is 16 and he opens a Buy outside the channel, then the Bid reaches the top line and closes in minus 2 points.

 
ex_kalibur:
Now let's assume the market is quiet (it's night), the average corridor is 8 pips (difference between nai and cat) but the spread is 10.
It depends on the width of your channel. If it is larger, and sufficiently larger, than the spread and StopLevel, then trade if your strategy is designed for that, and if the channel is already these values - how will you open in it? Imagine you are at the bottom of the channel and need to open to Buy. And the allowed opening price (including the Stop Level) - is above the upper boundary of the channel, where you want to open to Sell... Is it worth trading this way?
 
so when opening orders in the market, we are not interested in the stop loss at all
Reason: