#property indicator_chart_window double tsp_money = 0; int flag = 0; int h_total = 0; datetime chk_day; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { return(INIT_SUCCEEDED); } int start() { bool chk; int cnt; datetime today = TimeCurrent(); if(flag == 0) { chk_day = TimeCurrent(); flag = 1; } if(today != chk_day) { flag = 0; tsp_money = 0; cnt = 0; h_total = 0; } cnt = OrdersHistoryTotal(); if(h_total != cnt) { tsp_money = 0; for(int i = OrdersHistoryTotal() - 1; i >= OrdersHistoryTotal()-10; i--) { chk = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); if ( chk == true ) { datetime st_day = OrderCloseTime();//OrderOpenTime??? string a = TimeToStr(today); string b = TimeToStr(st_day); string c = StringSubstr(a,0,10); string d = StringSubstr(b,0,10); if(c == d) { tsp_money = tsp_money+OrderProfit(); } } } ObjectsDeleteAll(); ObjectCreate( "損益",OBJ_LABEL,0,0,0); ObjectSet("損益",OBJPROP_XDISTANCE,5); ObjectSet("損益",OBJPROP_YDISTANCE,18); ObjectSetText("損益","本日の損益:"+tsp_money,20,"MS ゴシック",clrWhite); h_total = OrdersHistoryTotal(); } return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+