Dears,
Im trying to implement a simple martingale strategy, that is, every time I have a deal with a loss, the next deal will have twice the volume of the previous.
I have no clue about why it is not working, I have tryed to work with positions, instead of deal, but got an error message.
Thanks in advance for the help! :)
Im trying this way:
- www.mql5.com
Hi, angevoyageur!
Actually I was not doing that, lol :P
After your comment I tryed this:
ulong lastDeal= mresult.deal; if(HistoryDealGetDouble(lastDeal,DEAL_PROFIT)<0) {mrequest.volume=HistoryDealGetDouble(lastDeal,DEAL_VOLUME)*2;} OrderSend(mrequest,mresult);
Again it didnt work.
I really dont know if I dont know yet how to use the correct function to the problem, or if I should take a differente approach. For example, Im no sure if the deal number I should use, must be the deal number in the sell operation (which closes the position, assuming I have already a buy position), or the same number of the buy order. I tried both without success. :(
Hi, angevoyageur!
Actually I was not doing that, lol :P
After your comment I tryed this:
Again it didnt work.
I really dont know if I dont know yet how to use the correct function to the problem, or if I should take a differente approach. For example, Im no sure if the deal number I should use, must be the deal number in the sell operation (which closes the position, assuming I have already a buy position), or the same number of the buy order. I tried both without success. :(
You have to use HistorySelect() or HistorySelectByPosition() before using HistoryDealGetDouble().
See second part of the following article for full explanation.
- 2011.02.01
- MetaQuotes Software Corp.
- www.mql5.com
Dears,
Estoy tratando de poner en práctica una estrategia martingala simple, es decir, cada vez que tengo un trato con una pérdida, el siguiente acuerdo tendrá el doble del volumen de la anterior.
No tengo ni idea de por qué no está funcionando, He intentado trabajar con las posiciones, en vez de acuerdo, pero nos dieron un mensaje de error.
Gracias de antemano por la ayuda! :)
Im tratando de esta manera:
The simplest is to control the outcome of the open position: if negative doubles the previous lot. Before we define the variable volLot as global or at least visible to the module in which we work. For example...
double result= resultNetoPosicion(simb); if(result<0) volLot= volLot*2;
//--------------------------------- RESULTADO NETO DE POSICION ------------------------------------ double resultNetoPosicion(string simb) { double resp= 0; if(PositionSelect(simb)) resp= PositionGetDouble(POSITION_PROFIT)+ PositionGetDouble(POSITION_SWAP)+ PositionGetDouble(POSITION_COMMISSION); return(resp); }
angevoyageur and josemiguel1812,
sorry for the late answer, I was very busy due the hollydays.
Thank you guys SO MUCH for the answers!!! Im going to try to program both in this weekend, then I post the result. :)
Best wishes!
Guys, after a long time away from forex, I finally started to implement the bloody martingale.
First I did for systems that use only stoploss and take profits and exit criteria. Like this:
double ultimopreco = MinhaOperacao.mrate[0].close; double meustop = MinhaOperacao.mrequest.sl; double meutp = MinhaOperacao.mrequest.tp; if(ultimopreco < meustop) { Lote = Lote * 2; } if(ultimopreco > meutp) { Lote = 0.1; }
I simply put that lines before the function that send the order.
Translating what I did (for long positions): if the last price < stoploss (then, if it happened I should be stopped with a loss), then double the last lot used for the next order, when it comes;
if the last price > takeprofit, then, I should have closed the position with profit, then turn back the lot to the initial amount.
Im having hard time in figure out how to work with deals, instead of positions or orders. If one wants to get track of the last profit or loss, this should be the way to go, isnt it?
Josemiguel1812, thank you so much for your solution, Im trying to addapt. The thing is it only buys twice the volume. For instance, if you have 4 losses in a row, the system will buy 1 lot, 2, 2 and 2 lots.
Best wishes,
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dears,
Im trying to implement a simple martingale strategy, that is, every time I have a deal with a loss, the next deal will have twice the volume of the previous.
I have no clue about why it is not working, I have tryed to work with positions, instead of deal, but got an error message.
Thanks in advance for the help! :)
Im trying this way: