Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 66
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
What you called Trailing is in fact not, it is calculated in a different way and its behaviour can be illogical.
Even though our concepts of the terms do not coincide, but you do understand me, don't you?
Solved the problem, it was here:
This function did not take into account all open trades, so I had to change the loop conditions. Now it looks like this:
This function calculates the sum of profits of all open trades at the price level specified to it. However, there is a quoted opinion that it does not take into account the spread, and I agree with it. The author of this opinion suggested this solution:
But I confess to be honest, I don't understand him as he writes:
But, to be honest, I don't understand him as he writes:
I do not seem to understand his algorithm; how the spread is considered there? Can someone explain?OrderProfit() counts for short positions at the current Ask, this is where the value of the current spread is taken into account. If the spread does not change, when the price changes from the current Bid to newSL the one-lot profit of the position (either Buy or Sell, with an appropriate sign) will change by the value of delta, which is written in the operator:
delta = ( newSL - Bid ) * TickValue;
In brief, OrderProfit() counts everything including spreads. We fix the result for a certain moment ( the current price) using OrderProfit(). From here on, all we have to do is to monitor price changes.
OrderProfit() is counted for short positions at the current Ask, this is where the current spread values are taken into account. If the spread does not change, when the price changes from the current Bid to newSL the one-lot profit of the position (either Buy or Sell, with the corresponding sign) will change by the value of delta, which is written in the statement:
delta = ( newSL - Bid ) * TickValue;
In brief, OrderProfit() counts everything including spreads. We fix the result for a certain moment ( the current price) using OrderProfit(). From here on, all we have to do is to monitor the price change.
I think I am beginning to understand, but perhaps it is more correct:
OrderProfit for short positions is calculated from Ask price, isn't it?
By the way, MarketInfo( SymbolName, MODE_TICKVALUE) returns 329.02 for EURUSD currency pair, that's why this function does not work properly for me.
So far I've decided to go for a trick, i.e. MarketInfo(SymbolName, MODE_TICKVALUE) to count differently:
So far I've decided to go for a trick, i.e. MarketInfo(SymbolName, MODE_TICKVALUE) to count differently:
The way it was written is correct. How much the Bid is shifted, the Ask is shifted by the same amount, if the spread is unchanged.
From personal experience, the spread is usually unchanged, and it is quite strong.) During sharp moves I have seen the spread increase from 8 to 80 points on a five-digit spread.
Can a double top be coded(reliably)?
When testing an Expert Advisor in the journal an error pops up
2013.08.07 12:35:41 2012.06.06 05:29 Puria - 1.452 - SQ EURUSD,M30: Error 4002 (array index - out of range)
2013.08.07 12:35:41 2012.06.06 05:29 Puria - 1.452 - SQ EURUSD,M30: Attempting to open a Buy order. Waiting for an answer.
Accordingly, the orders are not opened. How to eliminate the error? What are the reasons?
I would be glad to help.
When testing an EA, an error pops up in the log
2013.08.07 12:35:41 2012.06.06 05:29 Puria - 1.452 - SQ EURUSD,M30: Error 4002 (array index - out of range)
2013.08.07 12:35:41 2012.06.06 05:29 Puria - 1.452 - SQ EURUSD,M30: Attempting to open a Buy order. Waiting for an answer.
Accordingly, the orders are not opened. How to eliminate the error? What are the reasons?
I would be glad to help.