NewBar

Page 1 of 2 12 LastLast
Results 1 to 10 of 16
 0 Attachment(s)    

Thread: NewBar

  1. #1

    Question NewBar

    Hi! I've tried many methods to let the ea only open a new position after a new bar, but sometimes when I close the position manually, normally the EA will open a new position before a new bar, why does it happen? How can I change it? Thanks in advance for any help.
    Last edited by szmvscla; 06-30-2009 at 10:39.

  2. #2

    Default

    Quote Originally Posted by szmvscla View Post
    Hi! I've tried many methods to let the ea only open a new position after a new bar, but sometimes when I close the position manually, normally the EA will open a new position before a new bar, why does it happen? How can I change it? Thanks in advance for any help.
    Probably you just record bar change in your code, but you don't record trade activities (buy/sell) after it done.

  3. #3

    Default

    Declare lastime as a datetime variable on Global Scope.

    Then, in the start() function:

    if (Time[0]!=lastime) {
    //Do what you need to do here
    lastime=Time[0];
    }

  4. #4

    Thumbs up

    Quote Originally Posted by Volatily-Scalp View Post
    Probably you just record bar change in your code, but you don't record trade activities (buy/sell) after it done.
    Thanks for your reply!

  5. #5

    Question

    Quote Originally Posted by jezzer1961 View Post
    Declare lastime as a datetime variable on Global Scope.

    Then, in the start() function:

    if (Time[0]!=lastime) {
    //Do what you need to do here
    lastime=Time[0];
    }
    Thanks a lot! Is the following code right?

    in the start() function:

    if(Time[0]!=lastime)
    {
    newbar=true;
    lastime=Time[0];
    }
    else
    {
    newbar=false;
    }

    and then use the result to validate the opening of a new position.
    Last edited by szmvscla; 06-30-2009 at 16:52.

  6. #6

    Default

    Quote Originally Posted by szmvscla View Post
    Thanks a lot! Is the following code right?

    in the start() function:

    if(Time[0]!=lastime)
    {
    newbar=true;
    lastime=Time[0];
    }
    else
    {
    newbar=false;
    }

    and then use the result to validate the opening of a new position.
    newbar=false;//Global variable
    in the start() function:

    if(Time[0]!=lastime)
    {
    newbar=true;
    lastime=Time[0];
    }
    /*
    else
    {
    newbar=false;//your ea will not trade except your ea trade exact in the new bar
    }
    */
    //always check newbar variable before executing any trade
    if(newbar){
    if(buylogic){
    int ticket=ordersend(...);
    if(ticket>0)newbar=false;//it is the key to protect ea execute any trade after first trade in the same bar
    return;
    }
    // your sell logic here
    }

  7. #7

    Thumbs up

    Quote Originally Posted by Volatily-Scalp View Post
    newbar=false;//Global variable
    in the start() function:

    if(Time[0]!=lastime)
    {
    newbar=true;
    lastime=Time[0];
    }
    /*
    else
    {
    newbar=false;//your ea will not trade except your ea trade exact in the new bar
    }
    */
    //always check newbar variable before executing any trade
    if(newbar){
    if(buylogic){
    int ticket=ordersend(...);
    if(ticket>0)newbar=false;//it is the key to protect ea execute any trade after first trade in the same bar
    return;
    }
    // your sell logic here
    }
    Thank you very much! I was taking a look at your blog and I found your EA, is it only for EURCHF and EURGBP? Does the EA set time for GMT 0 or +2(AlpariUK)?

  8. #8

    Default

    Quote Originally Posted by szmvscla View Post
    Thank you very much! I was taking a look at your blog and I found your EA, is it only for EURCHF and EURGBP? Does the EA set time for GMT 0 or +2(AlpariUK)?
    Yes EG/EC, and default time set is GMT +2.

  9. #9

    Question

    Quote Originally Posted by Volatily-Scalp View Post
    Yes EG/EC, and default time set is GMT +2.
    Is the EA for TF15?

  10. #10

    Default

    Quote Originally Posted by szmvscla View Post
    Is the EA for TF15?
    Yes, it woks on 15 Minutes TF.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


NewBar


GadgetVersus GadgetVersus France W3Ask W3Ask Brasil W3Ask Deutschland W3Ask Espaņa W3Ask France W3Ask Italia W3Ask Nederland