- Simple experts
- The miracles continue!
- vps problem
Show your attempt if you need coding help.
When explaining my doubt I ended up thinking of an alternative... go through the history of positions until I find the record of step 1, using the POSITION_COMMENT in DEAL_ENTRY_IN. And while this does not happen, add the DEAL_PROFIT of the DEAL_ENTRY_OUT records. It worked, I got the result I needed...
I'll share the query code here and anyone who has a better idea or consideration to contribute...
Thanks!
Examples of values registered in the comment field, to help understand the code:
Cycle 32154, with 3 steps:
S-1-32154
S-2-32154
S-3-32154
//+------------------------------------------------------------------+ //| Function | //+------------------------------------------------------------------+ double getTotalProfitOfCycle() { HistorySelect(0,TimeCurrent()); string symbol; long entry; long magic; ulong ticket = 0; double totalProfit = 0; bool gotCycleProfit = false; for(int i = HistoryDealsTotal()-1; i>=0; i--) { if((ticket=HistoryDealGetTicket(i))>0) { symbol = HistoryDealGetString(ticket,DEAL_SYMBOL); entry = HistoryDealGetInteger(ticket,DEAL_ENTRY); magic = HistoryDealGetInteger(ticket,DEAL_MAGIC); if(symbol==Symbol() && entry==DEAL_ENTRY_IN && magic == mgNumber) { // check if it is still running data from the current cycle... string strArrStep[]; StringSplit(HistoryDealGetString(ticket,DEAL_COMMENT) ,StringGetCharacter("-",0),strArrStep); if(ArraySize(strArrStep) >= 3) { // if we reach step 1 of the current cycle, it should stop adding profit // cycleKey -> global variable that contains the identifier of the cycle that is in POSITION_COMMENT if((int)strArrStep[1] == 1 && (int)strArrStep[2] == cycleKey) { gotCycleProfit = true; } } } if(!gotCycleProfit && symbol==Symbol() && entry==DEAL_ENTRY_OUT && magic == mgNumber) { totalProfit += HistoryDealGetDouble(ticket,DEAL_PROFIT); } } } return totalProfit; }
Hello friend, using the martingale is never a good choice, most traders prefer to actually lower the risk when things are looking difficult, just an advice, think about the big picture and living to trade another day, martingale puts more psychological preasure and is the nearest thing to revenge trading, if its a lost, take the lost and move on, just an advice.
I understand and thank you for your concern, but the question is just technical. Martingale in this case is part of the strategy and is not used indiscriminately, but strategically, for sure the use of this technique without criteria is the end for any trader.
Thanks!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use