The main conditions for position opening on the example of opening to buy (for sales - mirror):
the fast stochastic line crosses the slow stochastic line upwards
we need to add a condition - if there is an open position to buy, at a new signal (see point above) a trade is opened only when the opening price of the new trade is higher than the opening price of the last open position by a given number of points, for example 30.
The conditions for closing a position (to buy), both conditions must be met
the slow stochastics line crosses the 80 stochastics level from above downwards
a condition needs to be added - this is the second crossing (see point above) for each previously opened position.
Sorry if I didn't explain the closing, on the chart the closing looks like this: two signals to close the trade are marked with red crosses, because the slow (red) stochastic line crosses the 80 level downwards. But the trade is closed only at the second signal/crossing
basic conditions for opening a position using the example of a buy opening (for selling mirrored):
the fast stochastic line crosses the slow stochastic line from below to above
We need to add a condition - if there is an open position to buy, at a new signal (see above) a position is opened only when the opening price of a new position is higher than the price of the last open position by a given number of points, for example 30.
***
It seems we missed a condition to open a position: in what range should the indicator be (or a level above or below which the indicator should be) ...
We seem to have missed the condition for opening a position: in which range the indicator should be (or the level above or below which the indicator should be) ...
If we can lower the level for the sake of simplicity), i.e. the stochastic level is not important for opening
I think you can make it much simpler - in the Expert Advisor, the threshold for CLOSE set to 100, and give the signal a weight of 0.5 - thus the signal with a weight of 0.5 will NEVER overcome the threshold of 100
Please explain what the problem is. The function is supposed to look through all open positions and count the number of open positions with a given magic number. But in fact it chooses only one from the entire list opened by another EA with the same ticket and magic number, so count is always =0.
int OpenPositions()//проверка открытых позиций
{
int count=0;
for(int z=PositionsTotal()-1; z>=0; z --)
{
if(!PositionSelect(_Symbol))
{
Print(__FUNCSIG__" позиция не выбрана ",GetLastError()); continue;
}
long ticket = PositionGetInteger(POSITION_TICKET);
Print(__FUNCSIG__" ТИКЕТ ", IntegerToString(ticket));
ulong myMN=PositionGetInteger(POSITION_MAGIC);
Print(__FUNCSIG__" МАГИК ", IntegerToString(myMN));
if(myMN==Magic)
count++;
}
return(count);
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
First, formulate clearly:
The main conditions for position opening on the example of opening to buy (for sales - mirror):
The conditions for closing a position (to buy), both conditions must be met
- the slow stochastics line crosses the 80 stochastics level from above downwards
- a condition needs to be added - this is the second crossing (see point above) for each previously opened position.
Sorry if I didn't explain the closing, on the chart the closing looks like this: two signals to close the trade are marked with red crosses, because the slow (red) stochastic line crosses the 80 level downwards. But the trade is closed only at the second signal/crossingbasic conditions for opening a position using the example of a buy opening (for selling mirrored):
***
It seems we missed a condition to open a position: in what range should the indicator be (or a level above or below which the indicator should be) ...
We seem to have missed the condition for opening a position: in which range the indicator should be (or the level above or below which the indicator should be) ...
If we can lower the level for the sake of simplicity), i.e. the stochastic level is not important for opening
If we can lower the level for the sake of simplicity), i.e. the stochastic level is not important for opening
Can we move it to a separate topic, something like "Stochastic Expert Advisor, indented positions"?
Let's reschedule.
Shall I make a new topic or will you?
let's move it
Should I make a new topic or you do?
Please create a thread in the section:Automated Trading Systems
I think you can make it much simpler - in the Expert Advisor, the threshold for CLOSE set to 100, and give the signal a weight of 0.5 - thus the signal with a weight of 0.5 will NEVER overcome the threshold of 100
Thank you! Seems to be working!