My martingale system doesn't work correctly.
In what way does it not work correctly ? what is the result ? what are the symptoms ? what does it do that it shouldn't ? what doesn't it do that it should ?
Saying X doesn't work isn't much of a description of your issue . . .
In what way does it not work correctly ? what is the result ? what are the symptoms ? what does it do that it shouldn't ? what doesn't it do that it should ?
Saying X doesn't work isn't much of a description of your issue . . .
- True, well first of all it doesn't go to level 5, aka lot size 0.32, it stops at 0.16,level 4 so i guess i missed a <,>,= sign somewhere.
- Secondly it doesnt increase orders continuously, so by that i mean that (lets say the
MARTINGALE_PROGRESSION=true;
settings) ticket #1 is 0.01 lot
ticket 2 is 0.02 lot
ticket 3 is 0.04 lot
but ticket 4 suddently jumps to 0.16 lot and skips 0.08, or sometimes it skips the 0.02 lot and jumps from 0.01 to 0.04
- Thirdly, sometimes if i run it it stops at 0.16 and doesnt go back to 0.01
Here is a backtest to show you what i`m talking about
PS: There are no programming errors like missing ; or (), only the fact that it's not working correctly.
Nevermind I figured it out :), here i post my fully working martingale code for future viewers.Although for me it's working, it would be nice if some1 could confirm it.
EXTERNALS/SETTING VARIABLES
extern double start_lot=0.01; //order lot size extern bool MARTINGALE_ACTIVATOR=false; /// wanna use martingale system? extern int MARTINGALE_LEVELS=5; // what levels to go,ex level 5= 2^5 multiplicator for lot extern bool MARTINGALE_PROGRESSION=true; int LEVEL=0; double martingale_lot=0.01; int PositionIndex; int TotalNumberOfOrders; int magic=666;
INIT()
martingale_lot=start_lot;
START()
if(MARTINGALE_ACTIVATOR){ static datetime lastClose; datetime lastClosePrev = lastClose; for(i=0; i < OrdersHistoryTotal(); i++) { OrderSelect(i, SELECT_BY_POS, MODE_HISTORY); // Only orders w/ if( OrderMagicNumber() == magic // <-- does the Order's Magic Number match our EA's magic number ? && OrderCloseTime() > lastClosePrev && OrderSymbol() == Symbol() // <-- does the Order's Symbol match the Symbol our EA is working on ? && (OrderType() == OP_BUY // <-- is the Order a Buy Order ? ||OrderType() == OP_SELL ) ) // <-- PROFITABLE O NOT ? { /////////// ////////////////////////////////// ////////////////////////////////////////// lastClose = OrderCloseTime(); start_lot=martingale_lot; //////////////////////////////////////////////////// if(MARTINGALE_PROGRESSION==false){ if(OrderProfit()<0) LEVEL++; //LOSS if(OrderProfit()>0) LEVEL=0; //PROFIT CANCEL OUT if(LEVEL>MARTINGALE_LEVELS) LEVEL=0; start_lot=martingale_lot*MathPow(2,LEVEL); } /////////////////////////////////////////////////////////////////////////////////////// if(MARTINGALE_PROGRESSION==true){ LEVEL++; if(LEVEL>MARTINGALE_LEVELS) LEVEL=0; start_lot=martingale_lot*MathPow(2,LEVEL); } ///////////////////////////////////////////////////////// } /////////////////////////////////////// } }
Note to be fully functional you should have no more than 1 open order at a time,and the code in the start should be before placing Ordersend() orders.And it works for market buy/sell orders, if you want to have pending orders just change the second if and add a
OrderType() == BUYLIMIT
or whatever.Good luck!
I used martingale on one of my EA's it made 15,000 dollars from a 500 dollar account last year. Would have been awesome if it wasn't for the 12,000 dollar hit it took this past April :(
I'm new to Forex and new to MQ4, but after a bit of research made an early decision to avoid Martingale techniques. Google "Birt Forex Envy" for example!
I'm trying to focus on Price Action with SR, trend lines, and minimal indicators..
I used martingale on one of my EA's it made 15,000 dollars from a 500 dollar account last year. Would have been awesome if it wasn't for the 12,000 dollar hit it took this past April :(
I'm new to Forex and new to MQ4, but after a bit of research made an early decision to avoid Martingale techniques. Google "Birt Forex Envy" for example!
I'm trying to focus on Price Action with SR, trend lines, and minimal indicators..
It depends on your risk tolerance, it know 100% it works,but you must be careful and plan every step ahead.Never go above level 5 and always have SL levels even if you dont have TP.This martingale code is here if you want to use it fine if not fine too.Whatever works for you man and good luck building your EA.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
My martingale system doesn't work correctly.Please i need help to make it work.I won't try to explain it since it's too complicated and my eyes hurt when looking at so much variables,so i'll copy it all here and if anyone finds any errors in the code please tell me.Thanks much:
SETTING VARIABLES:
INIT()
martingale_lot=start_lot; // this is in the init()
START()
The basic idea is that if the martingale system is on by using the settings with:
1)
MARTINGALE_PROGRESSION=true;
Then double the lot size by every trade until it hits the
Then if the (in this case) 5th trade is over,reset the lot size to the base size specified,this case 0.01 lot
2)
Then double the lot size at every losing trade only, and reset it to the base size (0.01 lot) if we got a winner trade
Also if it hits the maximum amount of levels set then reset it back to the base lot (0.01) to not overrisk the trades