Download MetaTrader 5

binary options martingale

To add comments, please log in or register
Daniel Lagoshniak
Daniel Lagoshniak  


 i want to add martingale system to MM of a robot that works with binary options. for that i need to know how previous deal in a row closed - if in profit, then i reset multiplier, if in loss, then increase power-multiplier and calculate lot size using init lot size and base and power multipliers. the problem with detecting result of previous trade: 

double Lot(){
   Print(__LINE__," mult= ",multiplier);
   if (!AllowMartingale) return BinaryLot;
   if (OrderSelect(ticket, SELECT_BY_TICKET, MODE_HISTORY)){
      Print(__LINE__," ordprofit= ",OrderProfit());
      if (OrderProfit() > 0) multiplier = 0;
      else if (OrderProfit()<0)multiplier++;
   Print(__LINE__," multAfter= ",multiplier);
   double res = (BinaryLot * MathPow(MartingaleMultiplier, MathMin(MartingaleMaxSteps,multiplier)));
   //*** lotstep
   return res;

 the result in log is "375 ordprofit= 0.0 and mult = 0" in both cases. is there any other way to get result of the deal if i have its ticket number?

I could ask for AccountBalance() and compare it to AcB before deal started, but this useless if i have two or more pairs with robot running. 

i tried with going through all deals (OrderSelect(i,SEL_BY_POS,MODE_HIST) and breaking from loop after first deal with same magic and symbol) but the result is same. maybe i need some manual on how to cook binary option robots, or article at havent found) that will discuss this point and possibly tell about other problems with bo algo trading. thank you!

Daniel Lagoshniak
Daniel Lagoshniak  

find out how to sovle it. write here, maybe sb else will need. at b/o in history one line says about open and close price, next - about result, after restarting terminal they move to one line. even though it is impossible to get OrderProfit(), it is possilbe to get OrderOpenPrice() and OrderClosePrice() and compare them keeping in mind Ordertype(). 

   double open = OrderOpenPrice();
   double close= OrderClosePrice();
   bool buy = (OrderType()==OP_BUY);
   bool res = (buy) ? (open<close) : (open>close);
   Print(__LINE__," opened=",open," closed=",close," buy?",buy," res>0?",res);

 also keep in memory last ticket that was processed, but that is another story.




To add comments, please log in or register