[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 917
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
How do I create a function and call it?
artemida70, put together my first EA using S. Kovalev's tutorial. It turned out that its criterion function worked with losses. Wrote my criterion function. Checked it for errors and then compiled the Expert Advisor. As a result of the work, I got:
- on criteria function: O - errors, 1 warning;
-for compilation of Expert Advisor: О - errors, О - warnings.
But the work in the Strategy Tester did not go, put test ALERTS in functions int init, int start, int deinit. I see in the responses that control is passed from Terminal to the int init function and control is not passed to the int start function - no response ALERT. When the EA is unloaded, there is a response from the int deinit function.
Please, your advice on this situation. Very much need advice from an experienced professional.
THANK YOU
Read a tutorial... :)
Here you have a strange structure. You are doing the standard loop of orders of the terminal. From zero to OrdersTotal() -1. And then you check the complete absence of orders in the terminal in the loop. Why don't you check the ticket for orders? Or a magik? And your flag =0 for some reason. And why not false? However, you are the boss. Your logic, you must understand it... :)
Thanks for the tip))) Exactly at this point:. From zero to OrdersTotal() -1... That's the reason why the tester didn't continue placing orders))))
I use this scheme because I learned it from someone else's classes. If you could describe a more rational method, I'd be very grateful))))
I've been screwed, I haven't gotten out of mql4 for almost a month, I think I'm going crazy or what?
i have no idea what i am trying to do with it.
I'm putting it out there, at least give me a hint, what's wrong? Gurus, help the dummies!
extern double TakeProfit=50.0;
extern double Lots=1;
extern int total;
int start()
{
double Price_1, Price_2, min, max;
RefreshRates();
Price_1=Bid;
Price_2=Ask;
min=iLow(NULL,0,2);
max=iHigh(NULL,0,2);
total=OrdersTotal();
if(total<1)
{
if(Price_1>max)
OrderSend(Symbol(),OP_BUY,Lots,Ask,5,Bid-StopLoss*Point,Ask+TakeProfit*Point, "My order#",16384,0,Green);
if(Price_2<min)
OrderSend(Symbol(),OP_SELL,Lots,Bid,5,Ask+StopLoss*Point,Bid-TakeProfit*Point, "My order#",16384,0,Green);
}
}
return(0);
artemida70, put together my first EA using S. Kovalev's tutorial. It turned out that its criterion function worked with losses. Wrote my criterion function. Checked it for errors and then compiled the Expert Advisor. As a result of the work, I got:
- on criteria function: O - errors, 1 warning;
-for compilation of Expert Advisor: О - errors, О - warnings.
But the work in the Strategy Tester did not go, put test ALERTS in functions int init, int start, int deinit. I see in the responses that control is passed from Terminal to the int init function and control is not passed to the int start function - no response ALERT. When the EA is unloaded, there is a response from the int deinit function.
Please, your advice on this situation. Very much need advice from an experienced professional.
THANK YOU
I don't understand what it means - IC's criteria function works with losses. After all, any function, if it tracks the opening criteria, may either work correctly or incorrectly, and therefore it may have errors. But the strategy itself - it can be losing or profitable... The criteria function only tracks the criteria set by the strategy and sends signals to the trading function.
Thanks for the tip))) Exactly at this point:. From zero to OrdersTotal() -1... That's the reason why the tester didn't continue placing orders))))
I use this scheme because I learned it from someone else's classes. If you could describe a more rational method, I'd be very grateful)))).
There are many ways. All depends on what you want to find.
In any case, you can start looping through the orders
for (int i =0; i<OrdersTotal(); i++)
then check exactly what you want to find in the loop.
if (OrderSelect(i, SELECT_BY_POS) // If the order is selected (here, I omitted the MODE_TRADES function parameter since it is selected by default)
and then - you already check the parameters of the order that you need, for example, magik
if (OrderMagicNumber()==Magic) // if the order has the given magic number, then... then this is the order we need...
Well... Or its type...
if (OrderType()==OP_BUY || OrderType()==OP_SELL) // if the order type is Buy or Sell...
etc..
Although, we can do it completely differently... It all depends on your habits, and on the code's requirements...
Hi all! I have the following code in my Expert Advisor (see below). As I understand it, the signal to open a position is taken from the indicators of two indices. How can we make the orders open based on only one indicator, e.g. CCI? Thank you very much.
Help, advisor does not close all orders when reaching a profit