Hi... i'm trying to edit/recreate and EA.. but looks like alot of error.. still learning.. help needed
Something like this.
extern double Price_Target=0.0; //The Price at which you want to CLOSE & DELETE all Orders. extern string Profit_Target= "ENTER ABOVE THE PRICE YOU TARGET"; extern bool SELL = false; extern bool BUY = false; extern int Slippage=5; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- Slippage*=10; //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- Comment(""); //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { double vBid= MarketInfo(Symbol(),MODE_BID); double vAsk= MarketInfo(Symbol(),MODE_ASK); if((BUY && vAsk >= Price_Target) || (SELL && vBid <= Price_Target)) { for(int i=OrdersTotal()-1;i>=0;i--) { if(!OrderSelect(i, SELECT_BY_POS)) continue; int type = OrderType(); bool result = false; switch(type) { case OP_BUYLIMIT : result = OrderDelete( OrderTicket() ); continue; case OP_BUYSTOP : result = OrderDelete( OrderTicket() ); continue; case OP_SELLLIMIT : result = OrderDelete( OrderTicket() ); continue; case OP_SELLSTOP : result = OrderDelete( OrderTicket() ); continue; case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), vBid, Slippage, clrRed ); continue; case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), vAsk, Slippage, clrRed ); } if(result == false) { Sleep(500); } } Print ("Account Price Reached. All Pending Order Have Been Deleted"); return(0); } Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit(), "\nMy Account Profit Target: ",Price_Target); return(0); }
If you want candle close either use previous bar close or current open.
double vBid= MarketInfo(Symbol(),MODE_BID); double vAsk= MarketInfo(Symbol(),MODE_ASK); double spread = vAsk-vBid; if((BUY && iClose(Symbol(),0,1)+spread >= Price_Target) || (SELL && iClose(Symbol(),0,1) <= Price_Target)) {
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Here's what i'm trying to do,
If BUY is true, when anytime a Candle close Ask Price is above or equal to "Price Target", it will close and delete all orders.
If SELL is true, when anytime a Candle Close Bid Price is below or equal to "Price Target", it will close and delete all orders.
Once a Candle Bar Close Price reach after the EA have been attach. Not the previous Candle Bar Close Price.