Need help!! Close order on this bar close
Results 1 to 6 of 6

Thread: Need help!! Close order on this bar close

  1. #1
    Hi!!

    Need help please!!

    I am new to programming. . .and I am trying to earn an EA...
    It works fine if I place a cross country condition to close an order...

    . . .but...

    I would like to tell the EA to close an open order in the close of the current bar....

    How can I do it??

    If I utilize shut[0] or iClose function. . .it seems backtesting it shuts my order in the tick close and not in the bar close....

    I would like to tell the EA this kind of thing. . .for example:
    in case my market condition is fulfilled. . .close the order in the close of the current bar

    anyone can tell me how I can do it??

    Thanks a lot!!

  2. #2
    The Simplest way is to do it on the first tick of a new Pub, Vol[0] = 1

  3. #3
    Quote Originally Posted by ;
    The easiest way is to do it on the first tick of a new bar, Vol[0] = 1
    Thanks, I tried to utilize

    Volume[0]gt;1

    but it shuts the order 1 bar later...

    Example: My EA opens an order on bar 0 , I want that if my condition is fulfilled, it shuts the order at the open another bar (the next bar in the trade), but the code Volume[0]gt;1 closes the order at the open of the third bar....is it possible?

  4. #4
    I think TIME may be relevant.

    Time[0] stores the beginning time of this current live pub so...

    At the minute your EA believes it may want to close down the transaction at the end of the bar then save[0] in to some factor.
    Then keep checking it from Time[0].
    As soon as a new bar appears Time[0] will be greater than your stored value.

    EG.

    Datetime thisbartime;

    if (CloseTradeOnNextOpenCondition ==true)

    thisbartime = Time[0];
    else thisbartime =0;


    if ((thisbartime !) =0) (Time[0] ! =thisbartime))

    //shut trade

  5. #5

  6. #6
    I would really like to be able to bring this to the connected ea, but once I tried my hand, it just reported errors.
    Is there any chance you might examine this for me?
    I have attached the clean (unmessed around by me) ea.
    Here's hoping
    Thank you
    Jim

    Quote Originally Posted by ;
    I believe TIME might be more relevant.

    Timing[0] stores the start period of this current live pub so...

    In the minute your EA thinks it might want to close the transaction at the end of this pub then save Time[0] into a variable.
    Then keep checking it from Timing[0].
    The moment a new bar appears Time[0] will be greater than your saved value.

    EG.

    Datetime thisbartime;

    if (CloseTradeOnNextOpenCondition ==true)

    thisbartime = Timing[0];
    else thisbartime =0;


    if ((thisbartime ! =0) (Time[0] ! =thisbartime))

    //shut trade
    https://forexintuitive.com/attachmen...1506626558.mq4

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