Hello.. i cant figure out whats wrong with my code..
the lot decreases on next signal instead to increase
if i change this it will increase lot on every new signal.. but will continue to increase if Total Orders is = 0
with this.. it will restart if Total orders is =0
Ill really appreciate mod to my code
Hello,
try something this....
input string MartinGale = "===< MartinGale Settings >==="; input double Risk=1.0; input double Multi=0.5; double MinLot,MaxLot,Contract,lot; int DealNumber; long Leverage; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { Leverage=AccountInfo.Leverage(); MinLot=SymbolInfo.LotsMin(); MaxLot=SymbolInfo.LotsMax(); Contract=SymbolInfo.ContractSize(); DealNumber=0; return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnTick() { if(buysignal()) { if(OrdersTotal()>0) DealNumber++; else DealNumber=0; int ticket=-1; Lot=AccountInfoDouble(ACCOUNT_FREEMARGIN)*Risk/100*Leverage/ContractSize; if(DealNumber>1) Lot=Lot*Multi*(DealNumber-1); Lot=NormalizeDouble(Lot,2); if(Lot<MinLot) Lot=MinLot; if(Lot>MaxLot) Lot=MaxLot; MqlTick last_tick; double price = last_tick.ask; ticket = sendbuy(ORDER_TYPE_BUY, price,stoplossB(),Btp1(), Lot, ""); } }
Tried this also lot not increasing on new signals
input string MartinGale = "===< MartinGale Settings >==="; input double Risk=1.0; input double Multi=0.5; double MinLot,MaxLot,Contract,lot; int DealNumber; long Leverage; input double LotIncrease =0.9; input double StartLot=0.5; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { Leverage=AccountInfo.Leverage(); MinLot=SymbolInfo.LotsMin(); MaxLot=SymbolInfo.LotsMax(); Contract=SymbolInfo.ContractSize(); DealNumber=0; return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnTick() { if(buysignal()) { if(OrdersTotal()>0) DealNumber++; else DealNumber=0; int ticket=-1; Lot=AccountInfoDouble(ACCOUNT_FREEMARGIN)*Risk/100*Leverage/ContractSize; if(DealNumber>1) Lot=Lot*Multi*(DealNumber-1); Lot=NormalizeDouble(Lot,2); if(Lot<MinLot) Lot=MinLot; if(Lot>MaxLot) Lot=MaxLot; MqlTick last_tick; double price = last_tick.ask; ticket = sendbuy(ORDER_TYPE_BUY, price,stoplossB(),Btp1(), mart() , ""); } } double mart() { double ask=SymbolInfo.Ask(),bid=SymbolInfo.Bid(); double fb1,fb2; double lots=0; fb1= StartLot; fb2=fb1*LotIncrease; if(nbuy()==0) fb1= StartLot; else if(nbuy()>0 && ask<=fbo()) fb1=fb1*LotIncrease; return(fb1); } int nbuy() { int buy=0; for(int i=0;i<OrdersTotal();i++) { int sb=OrderSelect(i); if(PositionGetInteger(POSITION_TYPE)==0 && PositionGetString(POSITION_SYMBOL)==Symbol() && PositionGetInteger(POSITION_MAGIC)==MagicNumber) buy++; } return buy; } double fbo() { ENUM_POSITION_TYPE type=(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE); // type of the position double openprice = PositionGetDouble(POSITION_PRICE_OPEN); double z=0,zz=0; for(int i=OrdersTotal();i>=0;i--) { int a=OrderSelect(i); if(type==POSITION_TYPE_BUY && PositionGetString(POSITION_SYMBOL)==Symbol() && PositionGetInteger(POSITION_MAGIC)==MagicNumber) { z=openprice; if(z<zz || zz==0)zz=z; } } return zz; }
Oooohh..
since youre counting buy orders, who not just calculate the lostize of the next buy order in that function?
each time through the loop your global buy_lotsize variable gets increased accordingly.
Although martingale is a fools errand..... Ive seen a proof that shows that probability of doubling your account is always exactly equal to the probability of a single winning outcome, and the probability of zeroing your account is equal to the probability of a single losing outcome....
i want to try something with martingale..
can you modify the wrong part of my code!!
i want to try something with martingale..
can you modify the wrong part of my code!!
You code not working.
Please fix your code first.
Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum 2015.02.11
Why it won't work: Calculate Loss from Lot Pips - MQL5 programming forum 2017.07.11
You code not working.
Please fix your code first.
hi.. thanks for your responses .. i have tried many possible ways .. still not working
can you highlight the wrong thing in my code
Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum 2015.02.11
Why it won't work: Calculate Loss from Lot Pips - MQL5 programming forum 2017.07.11
Hi.. yes i know i just want to try something with it!!!
//--// some pseudocode used in this example: do not copypasta: fix it. double lotsize(void){ if (OrdersTotal() == 0) return(StartLot); //does this even need a comment?? // OrdersTotal must be >0 to get to this line double ret=StartLot; // ret is just short for "return value" for(int i=OrdersTotal();i!=0;i--){ // you may as well count down as up, often its easier and comparing to zero usually takes less clock cycles if(get the right order type) ret *= LotIncrease; //since you have a nice exponential lotsize formula, just use it } // ret should now be the next lotsize in the sequence. return(ret); //ummm?? }

- 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.. i cant figure out whats wrong with my code..
the lot decreases on next signal instead to increase
if i change this it will increase lot on every new signal.. but will continue to increase if Total Orders is = 0
DealNumber++;
with this.. it will restart if Total orders is =0
DealNumber--;
Ill really appreciate mod to my code