EA question

 

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

 
darchii:

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.

Check your currently open orders,  if you have a long trade open don't open another.
 
Yes, but what is the code to check this, in a EA? If anyone can help me with.
 
Since there are no slaves here, you have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt and the nature of your problem.
 
I was supposed it was just a line max two... so this would not kill any time of you, since you do not want to help you please do not "off topic" with "we are not slaves bla bla bla".
 
darchii:
I was supposed it was just a line max two... so this would not kill any time of you, since you do not want to help you please do not "off topic" with "we are not slaves bla bla bla".

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

2. OrderSelect()

3. check magic number and symbol 

4. check Ordertype() 

5. check OrderOpenPrice()

 

5 lines already not including braces or variable declarations, etc. 

 
Ok, thank you for the update, I think I can manage from here, best wishes.
 
darchii: I was supposed it was just a line max two... so this would not kill any time of you, since you do not want to help you please do not "off topic" with "we are not slaves bla bla bla".

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.

 
RaptorUK:

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

2. OrderSelect()

3. check magic number and symbol 

4. check Ordertype() 

5. check OrderOpenPrice()

 

5 lines already not including braces or variable declarations, etc. 

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 )       
               return (0);
            }
         }
      }

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++)
 
darchii:

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:

I tried to search on forums but still with no results.

It is possible that   Bid != tick0  even if Bid is equal to tick0 . . .  read this thread:  Can price != price ?
Reason: