MODIFIED VERSION OF FOUR ARROW KEYS AND CHART CLICK

 
//MODIFIED VERSION 
//--------------------------------------- 
#define KEY_LEFT 37 
#define KEY_UP 38 
#define KEY_RIGHT 39 
#define KEY_DOWN 40 
//+------------------------------------------------------------------+ 
//| | 
//+------------------------------------------------------------------+ 
void OnInit() 
{ 
Comment("PRESS ' UP ARROW ' TO DISPLAY BOTH ORDERS"+ 
" "+"\nPRESS ' DOWN ARROW ' TO CLOSE BOTH ORDERS" 
" "+"\nPRESS ' LEFT ARROW ' TO CLOSE BUY AND PLACE NEW BUY ORDERS" 
" "+"\nPRESS ' RIGHT ARROW ' TO CLOSE SELL AND PLACE NEW SELL ORDERS" 
" "+"\nMOUSE CLICK ON CHART TO PLACE BUY OR SELL ORDER" 

); 

} 

//+------------------------------------------------------------------+ 
//| ChartEvent function | 
//+------------------------------------------------------------------+ 



bool Points; 
//+------------------------------------------------------------------+ 
//| | 
//+------------------------------------------------------------------+ 
void OnChartEvent(const int id, 
const long &lparam, 
const double &dparam, 
const string &sparam) 

{ 

if(id==CHARTEVENT_CLICK) 
{ 

int result_message=MessageBox("BUY ORDER TO BE PLACED PRESS YES ELSE PRESS NO FOR SELL ORDER ?","Warning",MB_YESNOCANCEL); 

if(result_message==IDYES) 
{ 
if(OrdersTotal()<2) 
{ 
Points=OrderSend(Symbol(),0,0.1,Ask,3,0,0,"AUTO BUY",0,0,clrNONE); 
OrderPrint(); 
GlobalVariableSet("BUY VOLUME",OrderLots()); 
} 

} 

if(result_message==IDNO) 
{ 
if(OrdersTotal()=2 && result_message!=IDCANCEL) 
{ 
MessageBox("NOT POSSIBLE TO PLACE ORDER THERE IS 2 OR MORE ORDERS PRESENT"); 
} 
} 
if(id==CHARTEVENT_KEYDOWN) 
{ 

if(lparam==KEY_UP) 
{ 
BOTH_ORDERS_EXECUTED(); 
} 
if(lparam==KEY_DOWN) 
{ 
CLOSE_ALL_RECORDS(); 
} 

if(lparam==KEY_LEFT) 
{ 
BUY_CLOSE_THEN_NEW_BUY(); 

} 
if(lparam==KEY_RIGHT) 
{ 
SELL_CLOSE_THEN_SELL(); 
} 

} 

} 
//+------------------------------------------------------------------+ 
void BOTH_ORDERS_EXECUTED() 
{ 
if(OrdersTotal()==0) 
{ 
GlobalVariableSet(AccountNumber(),AccountBalance()+10); 

Points=OrderSend(Symbol(),0,0.1,Ask,3,0,0,"AUTO BUY",0,0,clrNONE); 
OrderPrint(); 
GlobalVariableSet("BUY VOLUME",OrderLots()); 
Points=OrderSend(Symbol(),1,0.1,Bid,3,0,0,"AUTO SELL",0,0,clrNONE); 
OrderPrint(); 
GlobalVariableSet("SELL VOLUME",OrderLots()); 
} 
if(OrdersTotal()>0) 
{MessageBox("WILL NOT EXECUTE THERE IS "+OrdersTotal()+" RECORD");} 

} 
//+------------------------------------------------------------------+ 
//| | 
//+------------------------------------------------------------------+ 
void CLOSE_ALL_RECORDS() 
{ 
int TN1;int TN2; 
if(AccountProfit()>0) 
{ 
Points=OrderSelect(0,SELECT_BY_POS); 
TN1=OrderTicket(); 
Points=OrderSelect(1,SELECT_BY_POS); 
TN2=OrderTicket(); 
Points=OrderCloseBy(TN1,TN2,clrNONE); 
OrderPrint(); 
Points=OrderSelect(0,SELECT_BY_POS); 
Points=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,clrNONE); 
OrderPrint(); 
} 
if(AccountProfit()<0) 
{MessageBox("NOT SATISFIED");} 
if(GlobalVariableGet(AccountNumber())=10 && OrderType()==OP_BUY) 
{ 
BV=OrderLots(); 
Points=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,clrNONE); 
OrderPrint(); 

Points=OrderSend(Symbol(),0,BV-0.01,OrderOpenPrice(),3,0,0,"AUTO BUY",0,0,clrNONE); 
OrderPrint(); 
} 
//---------------------------------------------- 
Points=OrderSelect(1,SELECT_BY_POS); 
if(OrderProfit()>=10 && OrderType()==OP_BUY) 
{ 
BV=OrderLots(); 
Points=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,clrNONE); 
OrderPrint(); 

Points=OrderSend(Symbol(),0,BV-0.01,OrderOpenPrice(),3,0,0,"AUTO BUY",0,0,clrNONE); 
OrderPrint(); 

} 
if(OrderProfit()=10 && OrderType()==OP_SELL) 
{ 
VS=OrderLots(); 
Points=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,clrNONE); 
OrderPrint(); 

Points=OrderSend(Symbol(),1,VS-0.01,OrderOpenPrice(),3,0,0,"AUTO SELL",0,0,clrNONE); 
OrderPrint(); 
} 
//--------------------------------------------------------------------- 
Points=OrderSelect(1,SELECT_BY_POS); 
if(OrderProfit()>=10 && OrderType()==OP_SELL) 
{ 
VS=OrderLots(); 
Points=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,clrNONE); 
OrderPrint(); 

Points=OrderSend(Symbol(),1,VS-0.01,OrderOpenPrice(),3,0,0,"AUTO SELL",0,0,clrNONE); 
OrderPrint(); 
} 
MessageBox("CONDITION NOT MET FOR SELL ORDER"); 
} 
//+------------------------------------------------------------------+ 
//| | 
//+------------------------------------------------------------------+
 

Hello,

bool Points; 

Please read MQL4 reference on Trade Functions.  This is still wrong, change (Points) to (int) don't use (Bool)

Points=OrderSend(Symbol(),0,0.1,Ask,3,0,0,"AUTO BUY",0,0,clrNONE); 

BTW you don't need to start a new thread.

 
How to delete both link of mine. I made a new one with all error free from computer but can't be seen from mobile why.
 
Rethu Mathew:
How to delete both link of mine. I made a new one with all error free from computer but can't be seen from mobile why.

Hello,

To start with I would get rid of this.

Comment("PRESS ' UP ARROW ' TO DISPLAY BOTH ORDERS"+ 
" "+"\nPRESS ' DOWN ARROW ' TO CLOSE BOTH ORDERS" 
" "+"\nPRESS ' LEFT ARROW ' TO CLOSE BUY AND PLACE NEW BUY ORDERS" 
" "+"\nPRESS ' RIGHT ARROW ' TO CLOSE SELL AND PLACE NEW SELL ORDERS" 
" "+"\nMOUSE CLICK ON CHART TO PLACE BUY OR SELL ORDER" 

); 

I'm not any expert, but really?

if(OrderProfit()=10 && OrderType()==OP_SELL) 
{ 
VS=OrderLots(); 
Points=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,clrNONE); 
OrderPrint(); 

Points=OrderSend(Symbol(),1,VS-0.01,OrderOpenPrice(),3,0,0,"AUTO SELL",0,0,clrNONE); 
OrderPrint(); 
} 

read the MQL4 reference..

bool Points;