Your function lot does return the value, but you are not storing it. And you should (have to) use different names for variables.
CHANGE: double Lots; to: //double Lots; Lots(); to: //Lots(); Or delete that two lines t = OrderSend(Symb,OP_BUY, Lots,Ask,2,0,0,"",1,0,Green); to: t = OrderSend(Symb,OP_BUY, Lots(),Ask,2,0,0,"",1,0,Green);
i have not checked your Lots() function but with these two errors no trade could get executed. You might also check the log, there you can see why an order doesn't get executed.
Your function lot does return the value, but you are not storing it. And you should (have to) use different names for variables.
i have not checked your Lots() function but with these two errors no trade could get executed. You might also check the log, there you can see why an order doesn't get executed.
Тhank you very much. This is very stupid mistake. I will fix it. But now i have another problem. It always says "Division by zero". I made some tests and saw that the variable Step, that must be inited in the beginning equals zero after initialization. How can I fix that?
Symb = OrderSymbol(); //Get the symbol we are trading MinLot = MarketInfo(Symb,MODE_MINLOT); //Get the minimum trading lot MaxLot = MarketInfo(Symb,MODE_MAXLOT);//Gett the maximum trading lot Step = MarketInfo(Symb,MODE_LOTSTEP); OneLot = MarketInfo(Symb,MODE_MARGINREQUIRED); Ticket = 0;This is the init code. And Step equals zero.
Symb = OrderSymbol(); //Get the symbol we are trading MinLot = MarketInfo(Symb,MODE_MINLOT); //Get the minimum trading lot
You can't use OrderSymbol() until you've done an orderSelect
You want the chart symbol, use Symbol()
or simply use MarketInfor(NULL ...)
- 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 am in forex for a couple of months and i decided try to write a simple EA. After reading many EA codes from this forum, i still can't make it trade. I have not codded the strategy, because it is useless sinc it does not want to trade whit this simple code.
Please, help me. Where is my mistake?