//+------------------------------------------------------------------+ //| PERSONAL_ASSISTANT.mq4 | //| INFINITE LOOP | //| | //+------------------------------------------------------------------+ #property copyright "INFINITE LOOP" #property link "" #property version "1.00" #property strict #property description "Personal assistant is there to provide you with crucial information for making investment decisions and to execute your orders!" //+------------------------------------------------------------------+ //| User input variables | //+------------------------------------------------------------------+ input int ID=3900; input bool Display_legend=true; input double LotSize=0.01; input int slippage=2; input int text_size=10; input color text_color=clrBlack; input int right_edge_shift = 350; input int upper_edge_shift = 15; //+------------------------------------------------------------------+ //| Global variables | //+------------------------------------------------------------------+ string EA_name="PERSONAL_ASSISTANT"; string global_Volume="VOLUME"; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { GlobalVariableSet(global_Volume,LotSize); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { for(int z=1; z<=20; z++) ObjectDelete(ChartID(),EA_name+"_"+(string)z); GlobalVariableDel(global_Volume); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { int x=0, y=0, open_position_counter=0, sl_counter = 0, tp_counter = 0; double EA_profit=0, EA_takeProfit=0, EA_StopLoss=0, EA_volume=0, EA_sl_volume = 0, EA_tp_volume = 0; string text=""; //******************************************************************************************************************************** // Control over opened positions for(int pos=0; pos open BUY position manually button 2 -> open SELL position manually button 3 -> CLOSE BUY or SELL position manually button 4 -> increase current Lot volume (Lots in increments of 0.01) button 5 -> decrease current Lot volume (Lots in increments of 0.01) */ if(id==CHARTEVENT_KEYDOWN) { // ********************************************************************************************************************* // button 1 if(lparam==49 || lparam==97) { if(OrderSend(_Symbol,OP_BUY,GlobalVariableGet(global_Volume),MarketInfo(_Symbol,MODE_ASK),slippage,0,0,EA_name+" "+IntegerToString(ID),ID,0,clrNONE)>0) Print("Order BUY successfully opened for ",EA_name,"_",ID); else Print("Order BUY unsuccessfully opened for ",EA_name,"_",ID); } // ********************************************************************************************************************* // button 2 if(lparam==50 || lparam==98) { if(OrderSend(_Symbol,OP_SELL,GlobalVariableGet(global_Volume),MarketInfo(_Symbol,MODE_BID),slippage,0,0,EA_name+" "+IntegerToString(ID),ID,0,clrNONE)>0) Print("Order SELL successfully opened for ",EA_name,"_",ID); else Print("Order SELL unsuccessfully opened for ",EA_name,"_",ID); } // ********************************************************************************************************************* // button 3 if(lparam==51 || lparam==99) { for(int pos=0; pos=8.00) Alert("Coution, extreme volume!"); else { GlobalVariableSet(global_Volume,GlobalVariableGet(global_Volume)+0.01); text="Lot amount = "+DoubleToString(GlobalVariableGet(global_Volume),2); createObject(4,OBJ_LABEL,0,x,y+upper_edge_shift*3,text); text="Tick value = "+DoubleToString(MarketInfo(_Symbol,MODE_TICKVALUE)*GlobalVariableGet(global_Volume),3)+" "+AccountInfoString(ACCOUNT_CURRENCY); createObject(5,OBJ_LABEL,0,x,y+upper_edge_shift*4,text); text="Margin required = "+DoubleToString(MarketInfo(_Symbol,MODE_MARGINREQUIRED)*GlobalVariableGet(global_Volume),3); createObject(6,OBJ_LABEL,0,x,y+upper_edge_shift*5,text); } } // ********************************************************************************************************************* // button 5 if(lparam==53 || lparam==101) { if(GlobalVariableGet(global_Volume)<=0.01) Alert("Volume is at minimum, it can not be decreased!"); else { GlobalVariableSet(global_Volume,GlobalVariableGet(global_Volume)-0.01); text="Lot amount = "+DoubleToString(GlobalVariableGet(global_Volume),2); createObject(4,OBJ_LABEL,0,x,y+upper_edge_shift*3,text); text="Tick value = "+DoubleToString(MarketInfo(_Symbol,MODE_TICKVALUE)*GlobalVariableGet(global_Volume),3)+" "+AccountInfoString(ACCOUNT_CURRENCY); createObject(5,OBJ_LABEL,0,x,y+upper_edge_shift*4,text); text="Margin required = "+DoubleToString(MarketInfo(_Symbol,MODE_MARGINREQUIRED)*GlobalVariableGet(global_Volume),3); createObject(6,OBJ_LABEL,0,x,y+upper_edge_shift*5,text); } } } } //+------------------------------------------------------------------+