//+------------------------------------------------------------------+ //| Lida1.mq4 | //| Copyright © 2009, xroot | //| http://pycckue.org | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, Lida1 v0.4 by xroot" #property link "xroot@pycckue.org" #property indicator_separate_window #define MAX_PAIRS 20 string open_trade_symbols[MAX_PAIRS]; int num_sell_orders[MAX_PAIRS]; int num_buy_orders[MAX_PAIRS]; double total_sell_amount[MAX_PAIRS]; double total_buy_amount[MAX_PAIRS]; double avg_sell[MAX_PAIRS]; double avg_buy[MAX_PAIRS]; double commissions[MAX_PAIRS]; //commissions are the same for both order types double sell_lots[MAX_PAIRS]; double buy_lots[MAX_PAIRS]; double swap[MAX_PAIRS]; // swaps are the same for both order types color txt_color = Gray; color neutral_color = Gray; color negative_color = Red; color positive_color = Green; string font_str = "Courier New"; int window_index = -1; string ind_name = "Lida 0.4"; // column offsets int col_symbol = 40; int col_plsell = 100; int col_samtk = 160; int col_avgsell = 215; int col_avgbuy = 270; int col_bamtk = 330; int col_plbuy = 395; int col_amtk = 460; int col_grosspl = 520; int col_netpl = 600; int col_commissions = 650; int col_swap = 710; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorShortName(ind_name); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { ObjectsDeleteAll(WindowFind(ind_name)); return(0); } // aligns numbers // string align_str( double x, int num_digits) { int rc = 3; string str = ""; double x1 =0; string final_str = ""; if (num_digits >= 4) { num_digits = 4; rc -= 2; } if (num_digits == 3) { num_digits = 2; } if (x < 0) rc--; if ( x == 0) rc += num_digits; x1 = MathAbs(x); x1 /= 10; while( x1 >= 1) { rc -= 1; x1 /= 10; } for (int i=0; i 0) avg_buy[k] = avg_buy[k] / buy_lots[k]; if (sell_lots[k] > 0) avg_sell[k] = avg_sell[k] / sell_lots[k]; } } } void make_headers() { txt_color = DimGray; ObjectCreate("Symbol", OBJ_LABEL, window_index, 0, 0); ObjectSetText("Symbol","Symbol", 8, font_str, txt_color); ObjectSet("Symbol", OBJPROP_CORNER, 0); ObjectSet("Symbol", OBJPROP_XDISTANCE, col_symbol); ObjectSet("Symbol", OBJPROP_YDISTANCE, 2); ObjectCreate("plsell", OBJ_LABEL, window_index, 0, 0); ObjectSetText("plsell","P/L Sell", 8, font_str, txt_color); ObjectSet("plsell", OBJPROP_CORNER, 0); ObjectSet("plsell", OBJPROP_XDISTANCE, col_plsell); ObjectSet("plsell", OBJPROP_YDISTANCE, 2); ObjectCreate("S Amt (K)", OBJ_LABEL, window_index, 0, 0); ObjectSetText("S Amt (K)","S Amt(K)", 8, font_str, txt_color); ObjectSet("S Amt (K)", OBJPROP_CORNER, 0); ObjectSet("S Amt (K)", OBJPROP_XDISTANCE, col_samtk); ObjectSet("S Amt (K)", OBJPROP_YDISTANCE, 2); ObjectCreate("Avg Sell", OBJ_LABEL, window_index, 0, 0); ObjectSetText("Avg Sell","Avg Sell", 8, font_str, txt_color); ObjectSet("Avg Sell", OBJPROP_CORNER, 0); ObjectSet("Avg Sell", OBJPROP_XDISTANCE, col_avgsell); ObjectSet("Avg Sell", OBJPROP_YDISTANCE, 2); ObjectCreate("Avg Buy", OBJ_LABEL, window_index, 0, 0); ObjectSetText("Avg Buy","Avg Buy", 8, font_str, txt_color); ObjectSet("Avg Buy", OBJPROP_CORNER, 0); ObjectSet("Avg Buy", OBJPROP_XDISTANCE, col_avgbuy); ObjectSet("Avg Buy", OBJPROP_YDISTANCE, 2); ObjectCreate("B Amt (K)", OBJ_LABEL, window_index, 0, 0); ObjectSetText("B Amt (K)","B Amt(K)", 8, font_str, txt_color); ObjectSet("B Amt (K)", OBJPROP_CORNER, 0); ObjectSet("B Amt (K)", OBJPROP_XDISTANCE, col_bamtk); ObjectSet("B Amt (K)", OBJPROP_YDISTANCE, 2); ObjectCreate("P/L Buy", OBJ_LABEL, window_index, 0, 0); ObjectSetText("P/L Buy","P/L Buy", 8, font_str, txt_color); ObjectSet("P/L Buy", OBJPROP_CORNER, 0); ObjectSet("P/L Buy", OBJPROP_XDISTANCE, col_plbuy); ObjectSet("P/L Buy", OBJPROP_YDISTANCE, 2); ObjectCreate("AMT (K)", OBJ_LABEL, window_index, 0, 0); ObjectSetText("AMT (K)","AMT(K)", 8, font_str, txt_color); ObjectSet("AMT (K)", OBJPROP_CORNER, 0); ObjectSet("AMT (K)", OBJPROP_XDISTANCE, col_amtk); ObjectSet("AMT (K)", OBJPROP_YDISTANCE, 2); ObjectCreate("Gross P/L", OBJ_LABEL, window_index, 0, 0); ObjectSetText("Gross P/L","Gross P/L", 8, font_str, txt_color); ObjectSet("Gross P/L", OBJPROP_CORNER, 0); ObjectSet("Gross P/L", OBJPROP_XDISTANCE, col_grosspl); ObjectSet("Gross P/L", OBJPROP_YDISTANCE, 2); ObjectCreate("Net P/L", OBJ_LABEL, window_index, 0, 0); ObjectSetText("Net P/L","Net P/L", 8, font_str, txt_color); ObjectSet("Net P/L", OBJPROP_CORNER, 0); ObjectSet("Net P/L", OBJPROP_XDISTANCE, col_netpl); ObjectSet("Net P/L", OBJPROP_YDISTANCE, 2); ObjectCreate("Commissions", OBJ_LABEL, window_index, 0, 0); ObjectSetText("Commissions","Commiss", 8, font_str, txt_color); ObjectSet("Commissions", OBJPROP_CORNER, 0); ObjectSet("Commissions", OBJPROP_XDISTANCE, col_commissions+8); // :-) ObjectSet("Commissions", OBJPROP_YDISTANCE, 2); ObjectCreate("Swap", OBJ_LABEL, window_index, 0, 0); ObjectSetText("Swap","Swap", 8, font_str, txt_color); ObjectSet("Swap", OBJPROP_CORNER, 0); ObjectSet("Swap", OBJPROP_XDISTANCE, col_swap+15); // ;-) ObjectSet("Swap", OBJPROP_YDISTANCE, 2); } void displayit() { int hpos = 0; // accumulates position of the column int vpos = 0; // accumulates position of the line int digits = 2; for (int i=0;i