Jump to content

( Ask) How to fix this code?


zoop

Recommended Posts

i'm using this code to stop my ea trading when the bands come together

 

double upper1=iBands(NULL,bbtimeframe,bbperiod,deviation,0,PRICE_OPEN,MODE_UPPER,0);
double lower1=iBands(NULL,bbtimeframe,bbperiod,deviation,0,PRICE_OPEN,MODE_LOWER,0);


if((upper1==lower1))return(0);

 

 

it works great, however, return(0); also stops the whole ea from functioning

 

Question: how to add code so that (upper1==lower1) justs stop ea from placing new orders, rather than stopping the whole ea

 

my place order and close order code is

 

 

if ( filter1>filter2) buy=true;

  }
  
  if(
  filter1<filter2) sell=true;

  }

  if((filter1<filter2))closebuy();
  if((filter1>filter2))closesell();

 

 

 

much thanks

 

zoop

Link to comment
Share on other sites

Re: ( Ask) How to fix this code?

 

i'm using this code to stop my ea trading when the bands come together

 

double upper1=iBands(NULL,bbtimeframe,bbperiod,deviation,0,PRICE_OPEN,MODE_UPPER,0);
double lower1=iBands(NULL,bbtimeframe,bbperiod,deviation,0,PRICE_OPEN,MODE_LOWER,0);


if((upper1==lower1))return(0);

 

 

it works great, however, return(0); also stops the whole ea from functioning

 

Question: how to add code so that (upper1==lower1) justs stop ea from placing new orders, rather than stopping the whole ea

 

my place order and close order code is

 

How about adding this little thing to your code??

if ( filter1>filter2 && upper1!=lower1) buy=true;

  }
  
  if(
  filter1<filter2 && upper1!=lower1) sell=true;

  }

  if((filter1<filter2 ))closebuy();
  if((filter1>filter2 ))closesell();

 

 

 

much thanks

 

zoop

 

Please try it and let me know.

 

Best wishes,

a New Year 2011 has come, and the challenge has just started 8-)
Link to comment
Share on other sites

Re: ( Ask) How to fix this code?

 

Hi zoop,

 

Good day,

 

It is simple and here is a short explanation as well.

 

Let's say that Value1==Value2 ............... This means that both values have the same values.

 

If you want them NOT to equal, simply remove one equal sign from (==) to (!=).

 

So now you can see that (==) means equal in value.

 

And (!=) means not equal in value.

 

sometimes you can use ! in front of a constant function. For example, !IsDemo...... This means it won't send orders.

 

They are opposite of each other.

 

I hope this is clear to you.

 

Best wishes,

a New Year 2011 has come, and the challenge has just started 8-)
Link to comment
Share on other sites

Re: ( Ask) How to fix this code?

 

You can use boolean to prevent the ea from new order opening as well.

For example:

 

// --------------------------------------
bool openneworder = true;
if (upper1==lower1) openneworder = false;
// --------------------------------------
Before the OrderSend line you should insert this code:
if (openneworder)

 

Hope this helps!

Link to comment
Share on other sites

Re: ( Ask) How to fix this code?

 

You can use boolean to prevent the ea from new order opening as well.

For example:

 

// --------------------------------------
bool openneworder = true;
if (upper1==lower1) openneworder = false;
// --------------------------------------
Before the OrderSend line you should insert this code:
if (openneworder)

 

Hope this helps!

 

 

yes great help,

 

thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...