Results 1 to 2 of 2

Thread: Help! - How to not place new order too closed to already opened price?

  1. #1
    How do I check through opened price?
    I tried the following, but doesn't work.



    If (illness)....



    For(bcnt=btotal-1; bcnt gt;= 0; bcnt--)
    {
    OrderSelect(bcnt, SELECT_BY_POS, MODE_TRADES);
    if(OrderType()lt;=OP_SELL OrderSymbol()==Symbol())
    {
    if(OrderType()==OP_BUY)
    {
    if((Ask gt; OrderOpenPrice() (Point*OrderDist)) || (Ask lt; OrderOpenPrice() - (Point*OrderDist)))
    {
    Buy();


    ....



    //------------------------------

  2. #2
    Quote Originally Posted by ;
    How do I check through all already opened price?
    I tried the following, but does not work.



    If (condition)....



    For(bcnt=btotal-1; bcnt gt;= 0; bcnt--)
    {
    OrderSelect(bcnt, SELECT_BY_POS, MODE_TRADES);
    if(OrderType()lt;=OP_SELL OrderSymbol()==Symbol())
    {
    if(OrderType()==OP_BUY)
    {
    if((Ask gt; OrderOpenPrice() (Stage*OrderDist)) || (Ask lt; OrderOpenPrice() - (Stage*OrderDist)))
    {
    Buy();


    ....



    //------------------------------
    You have got the buy function in the loop?

    You probably wish to iterate through the loop and assess all orders to see if ANY are too close. Then test whether its all great outside the loop buy (outside the loop)

    bool tooclose=false;
    for(bcnt=btotal-1; bcnt gt;= 0; bcnt--)

    OrderSelect(bcnt, SELECT_BY_POS, MODE_TRADES);
    if(OrderType()lt;=OP_SELL OrderSymbol()==Symbol())

    if(OrderType()==OP_BUY)

    if((Ask lt; OrderOpenPrice() (Stage*OrderDist)) (Ask gt; OrderOpenPrice() - (Stage*OrderDist))) tooclose = true;




    //outside of loop
    if (! tooclose) Buy(); else Alert (oops too close for buy);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners more information