I would like to know if there is a code for not opening another long position on a price that already has a long one open. And if it is possible for tick chart also.
*edit: For ex: Moment 1: Price 1.3200 // I will go long
M2: Price 1.3190 // I am waiting
M3: Price 1.3200 // here I would like not to open a long because I already have one open
M4: Price 1.3210 // Open another one long
If it's just a line or two then code it yourself, how long will it take you to research 2 lines of code ? the reality is you do not know if it is 2 lines or 200 lines, and of course you want the code to be tested before it's given you . . .
Check your currently open orders . . .
1. For loop
3. check magic number and symbol
4. check Ordertype()
5. check OrderOpenPrice()
5 lines already not including braces or variable declarations, etc.
If you thought it "was just a line or max two," then why didn't you post your attempt? You didn't bother to try, didn't bother to learn. You just wanted someone (a slave) to do it for you.
You could have read the book or docs, many examples there. You could have searched for it. You could have looked at todays postings. You could have tried. Instead you cry "bla bla bla." Grow up, read the book, put some effort on your side.
total = OrdersTotal();
for (i = 0; i <= total; i++)
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
if ( OrderType() == OP_BUY)
if ( OrderOpenPrice() == tick0 )
Could you help me further because it is still opening position at the same price. My tick0 would like to be the price where not to open another position at. My buy condition will be something like:
if((FastMA < SlowMA) && Bid!=tick0)
I tried to search on forums but still with no results.
Thank you in advance,
for (i = 0; i < total; i++)