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
Maji could you look at this?
it's giving me an error code i don't know how to fix.
https://www.mql5.com/en/forum/174700/page69
What are you trying to do there?
I looked at the code but no errors jumped at me.
Perhaps you are trying to set your stoploss too close. Also, why not allow for a slippage of 1 pip.
Multiple position opend at the same price and at same time
Hi Maji,
Do not know why for USA/CAN, it always open twice at the same time and same price:
3931887 2006.10.26 08:32 sell 0.10 usdcad 1.1232 0.0000 1.1247 2006.10.26 15:30 1.1265 0.00 0.00 0.00 -29.29
3931891 2006.10.26 08:32 sell 0.10 usdcad 1.1232 0.0000 1.1217 2006.10.26 15:15 1.1273 0.00 0.00 0.00 -36.37
3954705 2006.10.26 15:15 sell 0.30 usdcad 1.1267 0.0000 1.1247 2006.10.26 15:30 1.1265 0.00 0.00 0.00 5.33
3954709 2006.10.26 15:15 sell 0.30 usdcad 1.1267 0.0000 1.1247 2006.10.26 15:30 1.1265 0.00 0.00 0.00 5.33
I have added the trace to the code. Examples are (but have more like this):
01:32:24 Cost_Avg___RSI_w_Trend_1 USDCAD,M15: PlaceFirstTrade for Sell
01:32:24 Cost_Avg___RSI_w_Trend_1 USDCAD,M15: PlaceFirstTrade for Sell
01:32:47 Cost_Avg___RSI_w_Trend_1 USDCAD,M15: open #3931887 sell 0.10 USDCAD at 1.1232 ok
01:32:47 Cost_Avg___RSI_w_Trend_1 USDCAD,M15: modify #3931887 sell 0.10 USDCAD at 1.1232 sl: 0.0000 tp: 1.1217 ok
01:32:48 Cost_Avg___RSI_w_Trend_1 USDCAD,M15: open #3931891 sell 0.10 USDCAD at 1.1232 ok
01:32:48 Cost_Avg___RSI_w_Trend_1 USDCAD,M15: modify #3931891 sell 0.10 USDCAD at 1.1232 sl: 0.0000 tp: 1.1217 ok
Another strange thing, when CloseShorts is triggered this morning, only one short position is closed and another three are still opened for a quite time.
For the first question, it seems
When first position is opened, CountTrades() does not immediately returns the number of position, and
In the code, the part
=================
if(timeprev==Time[0])
return(0);
timeprev=Time[0];
=================
seems also does not prevent the second position opening. The similar problem were also seen from other EAs. For this EA, the problem was only observed for USA/CAN, other pair seems ok up to know.
Please help.
Thanks!
Scott
Scott,
The timeprev code prevents the code being repeated again on the same bar. Here is my results for the RSI trend. I am running them on 15 and 30m bars. I don't have that problem, so can't figure out why you are having that issue. Are you running it on a server? If you are, I used to have problems with my EA when I ran them on a friend's VPN. Apparently, there is an image was being created which ran concurrently leading to duplicate trades.
Anyone else having that issue?
As for closing, that is a tradecontext busy issue. I think I will have to figure out a work around for that. I am using a similar workaround for the ordersend function.
Scott,
The timeprev code prevents the code being repeated again on the same bar. Here is my results for the RSI trend. I am running them on 15 and 30m bars. I don't have that problem, so can't figure out why you are having that issue. Are you running it on a server? If you are, I used to have problems with my EA when I ran them on a friend's VPN. Apparently, there is an image was being created which ran concurrently leading to duplicate trades.
Anyone else having that issue?
As for closing, that is a tradecontext busy issue. I think I will have to figure out a work around for that. I am using a similar workaround for the ordersend function.I am running it on my own PC with XP. Can not understand why. This only happened for USD/CAD (more than three time like this). Other Pairs sounds ok up to now.
I am running it on my own PC with XP. Can not understand why. This only happened for USD/CAD (more than three time like this). Other Pairs sounds ok up to now.
Did you check your journals to see what was going on at the time when the two trades were triggered?
Each Bar has an unique time stamp that is carried in the Time[0] array. Once that is established, that little piece of code will not allow the EA to execute. However, if the next tick comes, within the same bar but changes the timestamp (which should not happen within the current bar), the EA will execute again. I think something like that happened... a bad tick data or something similar.
Maji
Did you check your journals to see what was going on at the time when the two trades were triggered?
Each Bar has an unique time stamp that is carried in the Time[0] array. Once that is established, that little piece of code will not allow the EA to execute. However, if the next tick comes, within the same bar but changes the timestamp (which should not happen within the current bar), the EA will execute again. I think something like that happened... a bad tick data or something similar.
MajiHi Maji,
Is the Time[0] the starting time for the Bar 0? I do not understand well how the next tick comes, the time stamp will be changed for the same BAR. My knowledge is not enough for this.
The problem happened for USD/CAD again. Following is the jounal, can you see some reason?
=========================================================
2006.10.26 22:02:18 '459195': order #3985938 sell 0.10 USDCAD at 1.1231 was modified -> sl: 0.0000 tp: 1.1216
2006.10.26 22:02:18 '459195': request in process
2006.10.26 22:02:18 '459195': request was accepted by server
2006.10.26 22:02:18 '459195': modify order #3985938 sell 0.10 USDCAD at 1.1231 sl: 0.0000 tp: 0.0000 -> sl: 0.0000 tp: 1.1216
2006.10.26 22:02:18 '459195': order was opened : #3985938 sell 0.10 USDCAD at 1.1231 sl: 0.0000 tp: 0.0000
2006.10.26 22:02:18 '459195': request in process
2006.10.26 22:02:18 '459195': request was accepted by server
2006.10.26 22:02:18 '459195': instant order sell 0.10 USDCAD at 1.1231 sl: 0.0000 tp: 0.0000
2006.10.26 22:02:13 '459195': order #3985933 sell 0.10 USDCAD at 1.1231 was modified -> sl: 0.0000 tp: 1.1216
2006.10.26 22:02:13 '459195': request in process
2006.10.26 22:02:13 '459195': request was accepted by server
2006.10.26 22:02:12 '459195': modify order #3985933 sell 0.10 USDCAD at 1.1231 sl: 0.0000 tp: 0.0000 -> sl: 0.0000 tp: 1.1216
2006.10.26 22:02:12 '459195': order was opened : #3985933 sell 0.10 USDCAD at 1.1231 sl: 0.0000 tp: 0.0000
2006.10.26 22:02:12 '459195': request in process
2006.10.26 22:02:12 '459195': request was accepted by server
2006.10.26 22:02:12 '459195': instant order sell 0.10 USDCAD at 1.1231 sl: 0.0000 tp: 0.0000
2006.10.26 22:02:11 TradeDispatcher: trade context is busy
=========================================================
BTW, today, we have Sell opening for EUR/USD 0.1, 0.3, and 0.5 lots, all open in the opposit direction of current trend (Up trend). If we can buy dip on up trend, sell top on the down trend, it would be much safe. Seems to me, the current use of MA in your code can not make the trade following the trend. would you like to re-consider for my suggestion for the use of MA slope? I think, simply using the difference of two MA would work well. Normal MA is bit lag, but seems can indicate the big trend.
I don't know why the double trades were placed. The new bar should have unique time stamp. Sorry, cannot help you there.
I am working on the v2 of the trend-RSI that will consider the slope of the MA.
Was the H4 closing price above the H4 MA during today's open trades?
I don't know why the double trades were placed. The new bar should have unique time stamp. Sorry, cannot help you there.
I am working on the v2 of the trend-RSI that will consider the slope of the MA.
Was the H4 closing price above the H4 MA during today's open trades?Yes, the H4 closing prices are above H4 MA during today's open trades.
The EUR/USD has opening positions 0.1, 0.2, 0.3, 0.5,0.8 lots. The 0.8 lots position is in positive at this moment.
Perhaps, change this (without even considering MS slope)
if(UseTrend)
{
buy = MAValue > Cl;
sell = MAValue < Cl;
}
to
if(UseTrend)
{
buy = MAValue < Cl;
sell = MAValue > Cl;
}
might give more safe trades.
Thanks!
Scott
Yes, the H4 closing prices are above H4 MA during today's open trades.
The EUR/USD has opening positions 0.1, 0.2, 0.3, 0.5,0.8 lots. The 0.8 lots position is in positive at this moment.
Perhaps, change this (without even considering MS slope)
if(UseTrend)
{
buy = MAValue > Cl;
sell = MAValue < Cl;
}
to
if(UseTrend)
{
buy = MAValue < Cl;
sell = MAValue > Cl;
}
might give more safe trades.
Thanks!
ScottAbsolutely Scott... that was my intention all along. I wanted to type Buy = cl > Ma.. .but I typed it wrong and never noticed it... DOOOOOOHHHHHHH
Thanks for pointing it out. I am requesting everyone to make that change.
Thanks again.