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
megamixx,
If you are still out there, I can suggest a few code changes that will do what you're looking for. Let me know if you are still interested.
Then recompile to make sure it is without error. Let me know when you have this and I'll paste the next change.Got it and compiled successfully thanks sn.
Got it and compiled successfully thanks sn.
okay, good.
Next, there is a block of code like this
copy the entire block, paste it right after and rename it to OpenTradesOnThisCandle
Then, recompile to make sure it is without error.
I'm off to work now, so you won't hear from me until later. Post the changes if you get stuck.
Copied this block and renamed it, now it looks like this:
int OpenTradesOnThisCandle( )
{ int op =0;
for(int i=OrdersTotal()-1;i>=0;i--) // scan all orders and positions...
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() != MagicNumber) continue;
if ( OrderSymbol()==Symbol() )
{
if ( OrderType() == OP_BUY ) op++;
if ( OrderType() == OP_SELL ) op++;
}
}
return(op);
}
Hope I did it right sn. I compiled and got no errors but warning:
Function "OpenTradesOnThisCandle" is not referenced and will be removed from exp-file
0 error(s), 1 warning(s)
Good. The message is just a warning, and will go away soon.
Now change the line where you see MODE_TRADES to be MODE_HISTORY in the new subroutine you created.
Now replace both of the two if statements with OrderType() to this
When you have that (and you will get the same warning) compile it to make sure it is error free.
This is how the block looks now:
int OpenTradesOnThisCandle( )
{ int op =0;
for(int i=OrdersTotal()-1;i>=0;i--) // scan all orders and positions...
{
OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
if (OrderMagicNumber() != MagicNumber) continue;
if ( OrderSymbol()==Symbol() )
{
if (OrderOpenTime() > Time[0]) op++;
if (OrderOpenTime() > Time[0]) op++;
}
}
return(op);
}
Compiled, 0 errors, 1 warning
Hi megamix,
I don't read the thread from beginning, however ...
1. Use SRC button when posting code
2. The return of OrderSelect() is either true or false, so this is the correct way of writing OrderSelect(),
:D
Hi megamix,
I don't read the thread from beginning, however ...
1. Use SRC button when posting code
2. The return of OrderSelect() is either true or false, so this is the correct way of writing OrderSelect(),
:D
Thanks for the tip on posting code. Makes sense. As for point #2, I'll defer to sn as he's walking me through the steps and don't want to mess up his process. Much appreciated !
Thanks for the tip on posting code. Makes sense. As for point #2, I'll defer to sn as he's walking me through the steps and don't want to mess up his process. Much appreciated !
we will keep it simple for now. onewithzacky is correct, that checking return codes is a good habit.
if (OrderOpenTime() > Time[0]) op++; <<== this only needs to be there once. So take one out.
The next thing to do is to find this code and duplicate it right below.
Then change
(TradesInThisSymbol > 0)
to
(OpenTradesOnThisCandle() > MaxTradesPerCandle)
Then compile - the error should go away.
we will keep it simple for now. onewithzacky is correct, that checking return codes is a good habit.
if (OrderOpenTime() > Time[0]) op++; <<== this only needs to be there once. So take one out.
The next thing to do is to find this code and duplicate it right below.
Then change
(TradesInThisSymbol > 0)
to
(OpenTradesOnThisCandle() > MaxTradesPerCandle)
Then compile - the error should go away.
Done.
Deleted duplicate if (OrderOpenTime() > Time[0]) op++;
and found and changed
(TradesInThisSymbol > 0)
to
(OpenTradesOnThisCandle() > MaxTradesPerCandle)
Many thanks for your helpful assistance on this.