Jump to content

(ASK) close all on candle color change


zoop

Recommended Posts

Re: (ASK) close all on candle color change

 

how would i write this simple code?

 

 

close all orders on candle color change

 

if((redcandle))closebuy();

if((greencandle))closesell();

 

much thanks

 

if (Close[1] < Open[1]) CloseBuy(); // previous bar closed below its open
if (Close[1] > Open[1]) CloseSell(); // previous bar closed above its open

 

If you need to write closebuy() and closesell() yourself, just loop through the orders from OrdersTotal()-1 to 0, selectively closing OP_SELL and OP_BUY. There's a lot of examples, you can find them in pretty much any EA.

 

It's a good idea to only run that code on a new bar to prevent closing any newly open orders that go "against" the previous bar.

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...