It may be just that Im very tired, but it looks like OrdersTotal() happens to be the index of the next lotsize, so a loop to find the next lotsize is unnecessary.
int nxtlot[] = {Lot1,Lot2,Lot3,Lot4,Lot5,Lot6,Lot7,Lot8,Lot9,Lot10}; if(logic to open a new trade){ lotsize = nxtlot[OrdersTotal()] int res = OrderOpen(.....) [handle res appropriately] }
assuming that your ea only works on one symbol at a time, otherwise youd have to count the orders that are open on the relevant symbol.
As an aside; martingale looks like it works right up to the moment it doesnt.
Does your code compile?
You declare
int nxtlot[10];
in Init(). That means that it is locally declared and cannot be accessed from any other function.
int start() { int totalopen = OrdersTotal(); int start()
You can't have 2 functions called start and you cannot declare a function inside another function.
Rethink your code and post code that compiles and somebody may be able to help you.
In future please post in the correct section
I will move your topic to the MQL4 and Metatrader 4 section.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi forum,
Can somebody please review my code. Im currently trying to developing a lot martingale strategy for expert advisor. And stuck at the problem now. As you can see in my piece of code its a not working one. I'm not sure how to use the Array and For Loop for my code problem ( Yes, im a noob in MQL4). The main rule of this code is :
2. I want to limit until the total opened Orders = 11 orders, so i put a limit in the Loop
Your help will really relief me! Happy green pips :)