You run it on a Daily chart ?
It is on the M5 chart.
For instance, this piece of code below returns:
History: 1, 2, 3, 4...according to number of items in history. The only item working well.
Ticket: 2 (and stays stuck at 2 from the first order)
Symbol: WDO@N (this one is also OK)
Order: 2 (same as ticket)
DealType: 0 (stuck)
OrderType: 1 (stuck)
Profit: 0 (stuck)
double ProfitAll(datetime& XHoraPrimeiroCandle, double& XProfit) { int err=0; if (IsFirstBar()) { XHoraPrimeiroCandle = iTime(_Symbol,_Period,0); } HistorySelect(XHoraPrimeiroCandle,TimeCurrent()); for(int i = HistoryDealsTotal()-1; i >= 0; i--) { long ticket = HistoryDealGetTicket(i); string symbol = HistoryDealGetString(ticket,DEAL_SYMBOL); long magic = HistoryDealGetInteger(ticket,DEAL_MAGIC); long order = HistoryDealGetInteger(ticket,DEAL_ORDER); double dealType = HistoryDealGetInteger(ticket,DEAL_ENTRY); double orderType = HistoryDealGetInteger(ticket,DEAL_TYPE); double profitAtual = HistoryDealGetDouble(ticket,DEAL_PROFIT); Comment("Hora: ",XHoraPrimeiroCandle,"\nHistory: ",HistoryDealsTotal(),"\nTicket: ",ticket,"\nSymbol: ",symbol,"\nOrder: ",order,"\nDealType: ",dealType,"\nOrderType: ",orderType,"\nProfit: ",profitAtual); }
Hi guys I think this is related to this topic hope someone can help me out :)
I would like to set rules for my trading account.
Daily loss/gain limit setting
Example: Equity = €1000. If Equity hits €950 (-5%) all open positions close, all open orders get cancelled and no more positions can be opened on this trading day.
Once Equity cross €1025 (+2,5%) the daily loss limit loss moves to €1000 (+-0%)
Once Equity cross €1050 (+5%) daily loss limit moves to €1025 (+2,5%) and so forth until the max daily profit is reached with +25% resulting again in closing of all open positions and cancelling all open orders for this trading day.
Setting max. trades per timeframe
Limiting the opening of positions. Example 3 positions max each 30minutes.
p.s. I will give a nice tip for the one who can explain and help setting this up for me :)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone,
I am trying to code a function to return the accumulated daily Profit/Loss, but I cant make the code work. Can any guru here be so kind to help me? I Appreciate!