[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 49
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
People, help me out with the code: Why doesn't this EA put out a pendulum when the MA is crossed.
It will only open orders starting from the second. Not even from the second, but from the third.Is that what you have in mind?
DhP, Roman, thanks!!!!!!
Was the cleaning successful?
for(j=0; j<OrdersHistoryTotal(); j++)
if (OrderSelect(j,SELECT_BY_POS,MODE_HISTORY))
if (OrderSymbol()==Symbol())
{
datetime ctm=OrderCloseTime();
break;
}
I would like the next order on this security to be opened only after three bars, i.e. on the fourth bar, but not before. How can I make a check?
Hello, could you give me a hint? In the following code, I get the closing time of the last order for a particular security:
for(j=0; j<OrdersHistoryTotal(); j++)
if (OrderSelect(j,SELECT_BY_POS,MODE_HISTORY))
if (OrderSymbol()==Symbol())
{
datetime ctm=OrderCloseTime();
break;
}
I want to open the next order on this security after three bars, i.e. on the fourth bar, but not before. How can I make a check?
Are you sure it's the last one closed? What if it's the first one you meet? You're falling out of the loop.
Are you sure it's the last one closed? What if it's the first one you meet? You're falling out of the loop, aren't you?
I'm going through the history, aren't all the warrants there?
I'm going through the history, aren't all orders there?
you go through the history up to the first order on the symbol, after which break - you drop out of the loop.
If you had 100 orders you will only see one
.
I am going through the history, all orders are there?
Here. The function will return you the bar number of the last bar closed by this EA:
You call, for example, int BarClose=BarLastClosePose();
The BarClose variable will store the number of the bar of the last closed position, or -1 (if there is no bar). Magic - EA magic - write your variable there.
Or, delete this line if you want to check all orders (even those that have been placed by another EA or that have been manually opened by yourself)
And then you can check when the next order can be opened (after how many bars).
Generally, the goal is to open an order only after at least three bars, i.e. on the fourth bar, but not before, after the last closed order on the security. To do this, I go through the history and if I see an order for this security from the history, I consider it closed and last. Am I wrong in thinking that the orders will be selected in chronological order?