Draw the profit on the candle that closed the transaction New comment diegotfcastro 2021.01.15 17:36 Hello guys, I'm trying to create an element that writes the profit from the last transaction above on the candle that ended the transaction. So far I've been able to get here, but I still haven't been able to make it do what I need. void DrawProfit() { double profit = 0; ulong ticket; string CurrDate = TimeToString(TimeCurrent(), TIME_DATE); HistorySelect(StringToTime(CurrDate), TimeCurrent()); for(int i = HistoryDealsTotal() - 1; i >= 0; i--) { ticket = HistoryDealGetTicket(i); if(ticket > 0) { if(HistoryDealGetString(ticket, DEAL_SYMBOL) == _Symbol && HistoryDealGetInteger(ticket, DEAL_MAGIC) == MagicNumber) { profit = HistoryDealGetDouble(ticket, DEAL_PROFIT); ObjectCreate(_Symbol,StringFormat("Profit %s",profit),OBJ_TEXT,0,0,0); ObjectSetInteger(0,StringFormat("Profit %s",profit),OBJPROP_FONTSIZE,8); ObjectSetInteger(0,StringFormat("Profit %s",profit),OBJPROP_COLOR,clrWhite); ObjectSetInteger(0,StringFormat("Profit %s",profit),OBJPROP_BGCOLOR,clrGreen); ObjectSetString(0,StringFormat("Profit %s",profit),OBJPROP_TEXT,profit); break; } } } } As a demonstration, follow my goal: Errors, bugs, questions Discussion on the implementation of councillors. NeverQuit's Trading Journal New comment
So far I've been able to get here, but I still haven't been able to make it do what I need.
As a demonstration, follow my goal: