Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 238

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
Hello again I would like to raise a question about placing a stop on the last order.
I want to clarify that in the tester sometimes a stop is not placed on the last order.
This has not happened so far on the forward tests. But as they say, why wait?)
Code
Can you suggest the following thing, there are N EAs on the account, which under certain conditions can all open an order at the same time, each of them checks no more than 1 order on the account, but sometimes I end up with N orders, what can I do?
read articles
Pause between trades
Error 146 ("Trade flow busy") and how to deal with itread articles
Pause between trades
Error 146 ("Trade flow busy") and how to deal with itThank you!!!
Are you sure that this part of the code is the source of the problem? From what you have shown it is difficult to draw conclusions - there are a lot of unknown variables and you can't see the opening itself.
To find the reason yourself, print or display the values of the variables with comments. Then you will be able to see their values at any time.
This is based on eOpenByTime Expert Advisor from Mr. Kim. I also added a trailing stop, closed at the end of the week and opened at a certain day of the week. In this form the Expert Advisor works as it should be.
The deal opening is performed in the following way, I have added only the day of a week of deal opening but there is nothing to screw up here
To be honest, I do not quite understand why TimeCurrent is compared to TimeCurrent + TimeTradeOpen where TimeTradeOpen is an external parameter of the TimeTradeOpen = "19:51" type. (This is actually the position opening time we need.) I also do not understand why this comparison works. Duration is the time during which the Expert Advisor will try to open a position.
By analogy, I have added a closing of a position on Friday.
So far, everything was working.
Then I wanted to add a condition that looks at a candlestick at a given time and a given day of the week, if the candlestick is bullish, then sell, if it is bearish, then buy.
In the same way, I have copied these 3 lines, which have worked before, but now for some reason they do not want to.
After that the code for position opening follows. TimeTradeIf has a similar format TimeTradeIf = "19:51" and is also set via external parameters.
The whole code is quite long, do you need to insert?
Hello again I would like to raise a question about placing a stop on the last order.
I want to clarify that in the tester sometimes a stop is not placed on the last order.
This has not happened so far on the forward tests. But as they say, why wait?)
Code
Found the problem. The code is OK. it's the writer who demands the impossible ))
It is based on eOpenByTime Expert Advisor from esteemed Mr. Kim. I also added a trailing stop, closed at the end of the week and opened at a certain day of the week. In this form the EA works as it should.
The deal opening is performed in the following way, only the day of the week of deal opening is added by me but there is nothing to screw up here
To be honest, I do not quite understand why TimeCurrent is compared with TimeCurrent + TimeTradeOpen, where TimeTradeOpen is an external parameter of the TimeTradeOpen = "19:51" type. (This is actually the position opening time we need.) I also do not understand why this comparison works. Duration is the time during which the Expert Advisor will try to open a position.
By analogy, I have added a closing of a position on Friday.
So far, everything was working.
Then I wanted to add a condition that looks at a candlestick at a given time and a given day of the week, if the candlestick is bullish, then sell, if it is bearish, then buy.
In the same way, I have copied these 3 lines, which have worked before, but now for some reason they do not want to.
After that the code for position opening follows. TimeTradeIf has a similar format TimeTradeIf = "19:51" and is also set via external parameters.
The entire code is quite long, should I paste it?
To be honest, I have already forgotten what the problem is. In this code section I see that only short positions are checked and the opening of short positions is also specified:
To be honest, I've forgotten what the problem is. In this code section I see that only short positions are checked and only short positions are opened:
The Sell variable is external and contains true or false, 1 or 0, respectively,
Kim's is eOpenByTime.
The logic, the algorithm of actions, is flawed.
If he would drop the start() function and variables, what they carry, then we can suggest something.
Artem, this is correct, the Sell variable is external and carries the value true or false, 1 or 0 respectively,
I looked at Kim's, eOpenByTime.
The logic, the algorithm of actions, is flawed.
If he would show the start() function and variables, what they bear, then we can suggest something.
The idea is this: if a candle is bullish on a certain DayOfWeekIf at a certain time TimeTradeIf, then Sell = true (sell), if it is bearish, then Sell = false (buy).
It should be, but in the test I only get trades for sale.
eOpenByTime allows to open deal at given time, I added more at given day of week if (DayOfWeek()==DayOfWeekOpen, where DayOfWeekOpen = 1,2,3,4,5
I'm attaching the code in two parts, there's no other way around, I've highlighted the problem condition. Everything works as it should without it, i.e. we set Sell and open a deal at the right time at the right day of the week.
Only trawl has been cut out.
What's the problem, it works.