rafael.rpd:
Hello, I'm trying to add Martingale to my EA, from another file that defines lots. But I researched and I couldn't solve a mistake, forgive me because it seems simple, please help ...
Please edit your code so that it is readable. It is a mess with all the broken and empty lines.
Please edit your code so that it is readable. It is a mess with all the broken and empty lines.
Keith Watford:
Please edit your code so that it is readable. It is a mess with all the broken and empty lines.
I'm sorry, edited.
Thank you sir.
- rafael.rpd: I'm sorry, edited.Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - 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.11Why it won't work: Calculate Loss from Lot Pips - MQL5 programming forum 2017.07.11
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello, I'm trying to add Martingale to my EA, from another file that defines lots. But I researched and I couldn't solve a mistake, forgive me because it seems simple, please help ...
EA code:
#property strict #include "SetLotSize.mq4" #define MAGICMA 20050643 extern int Frames=2; extern int Shift=0; extern int TakeProfitX=50; extern int StopLossX=1; extern int Expiration=360; //|--------------------expiration in minutes extern string Note = "Horario para rodar"; extern int StartTrading = 5; // Start of trading session extern int StopTrading = 18; // end of trading session extern int FechaTudo = 18; datetime LastTime; int TicketB, TicketS, TicketBS, TicketSS; double LotSize=0.05; int Fractals(int bar) { bool Up=true; bool Dn=true; int i; for (i=1;i<=Frames;i++) { if (High[bar+Frames+i]>=High[bar+Frames] || High[bar+Frames-i]>=High[bar+Frames]) Up=false; if (Low[bar+Frames+i]<=Low[bar+Frames] || Low[bar+Frames-i]<=Low[bar+Frames]) Dn=false; } if (Up) { if (Dn) { return (2); // Up and Dn } else { return (1); // Up } } else { if (Dn) { return (-1); // Dn } else { return (0); // None } } } int FindUpFractal(int bar) { int bar_=bar; int Fr; while (bar_<Bars-Frames) { Fr=Fractals(bar_); if (Fr==2 || Fr==1) return (bar_); bar_++; } return (-1); } int FindDnFractal(int bar) { int bar_=bar; int Fr; while (bar_<Bars-Frames) { Fr=Fractals(bar_); if (Fr==2 || Fr==-1) return (bar_); bar_++; } return (-1); } int init() { LastTime=Time[0]; return(0); } int deinit() { return(0); } void CalculateOrders(string symbol) { TicketB=0; TicketS=0; TicketBS=0; TicketSS=0; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA) { if(OrderType()==OP_BUY) TicketB=OrderTicket(); if(OrderType()==OP_SELL) TicketS=OrderTicket(); if(OrderType()==OP_BUYSTOP) TicketBS=OrderTicket(); if(OrderType()==OP_SELLSTOP) TicketSS=OrderTicket(); } } return ; } int start() { int Expire=0; if(Expiration>0)Expire=TimeCurrent()+(Expiration*60)-5; int Frac; int res; double OpenPrice; double SL; double CL; double RafaPara; double TakVai; double TakVem; int UpFractal, DnFractal; UpFractal=-1; DnFractal=-1; int i=0; if(Hour() >= FechaTudo && FechaTudo != 0) { for(i=0;i<OrdersTotal();i++) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderType()==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),Bid,3,Red); continue; } if(OrderType()==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),Ask,3,Red); continue; } if(OrderType()==OP_BUYSTOP||OP_BUYLIMIT||OP_SELLSTOP||OP_SELLLIMIT) { OrderDelete(OrderTicket()); continue; } } } if (LastTime!=Time[0]) { UpFractal=FindUpFractal(1); DnFractal=FindDnFractal(1); if (UpFractal>0 && Hour() >= StartTrading && Hour() < StopTrading ) // Up fractal { CalculateOrders(Symbol()); if (TicketB==0 && TicketBS==0) //BUY OU BUY STOP { CL=Low[Frames+DnFractal]-Shift*Point; //Usa stop ou nem if (StopLossX != 0) RafaPara = High[Frames+UpFractal]-StopLossX*Point; else RafaPara = CL; OpenPrice=High[Frames+UpFractal]+Shift*Point; TakVai=High[Frames+UpFractal]+TakeProfitX*Point; res=OrderSend(Symbol(),OP_BUYSTOP,SetLotSize(),OpenPrice,5,RafaPara,TakVai,"",MAGICMA,Expire,Blue); } ...SetLotSize:
#property strict double SetLotSize() { static double LastAccountBalance; if (LastAccountBalance > AccountBalance()) { if (LotSize== 0.05) LotSize= 0.10; else if (LotSize== 0.10) LotSize= 0.20; else if (LotSize== 0.20) LotSize= 0.40; else if (LotSize== 0.40) LotSize= 0.50; else if (LotSize== 0.50) LotSize= 0.75; else if (LotSize== 0.75) LotSize= 1.00; } if (LastAccountBalance < AccountBalance()) LotSize=0.05; LastAccountBalance= AccountBalance(); return LotSize; }Compile return 3x 'LotSize' - undeclared identifier