[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 186
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
if (c % 2==0) //even
I wouldn't check double for equality to anything.
I wouldn't check double for equality with anything.
I thought I wrote before that only for integers. Or don't you read it well?
Question for a puzzle).
How to determine programmatically whether a number is even or odd?
For example:
int a, b, c;
a=2;
b=3;
c=a+b
c is even or odd?
If the numbers are integers, check for the remainder of division by 2.
clarify code errors
Good afternoon!
Please who is not lazy to look at the code and advise what my errors are. I got a bunch of errors on compilation. This is my first EA, I have just started to understand it. The idea of the Expert Advisor is as follows: on Monday at a given time we place pending orders in both directions at a distance of X points from the previous week's close. On Friday, at a given time we will close the market orders and delete the pending ones. That's all.
Week_1.mq4 (4.52 KB)
to begin with:
1) put ; at the end of each operator
2) use correct functions, for example Hour()
Can you please tell me how to run a for loop on already closed loss-making orders? Or maybe someone already has a function: when a loss trade is closed, multiply the lot?
any tips?
suggest a tip!
Show me your own attempts to implement this function - the "newbie help" thread.
or search for "search for the last closed order" or similar - the topic has been around for a long time
Well, give me a hint.
See the owls of the Avalanche branch.
I'm learning a programming language, and I'm having trouble understanding the behaviour of the programme. I have written an EA based on the textbook, but I have twisted it to a slightly different principle of operation.
The Expert Advisor is based on 2 muwings averaging. The idea is simple, moving averages cross, order is closed and opposite one is opened. I wrote an EA and it works fine. Of course it is at a slight disadvantage, but in accordance with the idea. The entire problem is as follows (in bold):
A=iMA(NULL,0,Period_MA_1,0,MODE_SMA, PRICE_CLOSE,1); // A
B=iMA(NULL,0,Period_MA_2,0,MODE_SMA,PRICE_CLOSE,1); // B
C=iMA(NULL,0,Period_MA_1,0,MODE_SMA,PRICE_CLOSE,2); // C
D=iMA(NULL,0,Period_MA_2,0,MODE_SMA,PRICE_CLOSE,2); // D
If I change the way of calculating moving averages (it can show plus sign) and put exponential method( MODE_SMA) instead of simple one (MODE_EEMA ) and one more(MODE_SMMA), so called smoothed method, everything goes wrong. The working principle becomes even more amusing (in the strategy tester) as the EA opens an order at the very beginning of the period set and closes it at the end. I.e., for a year it opens one single trade at the beginning of the period, and closes it at the end. As a result, the Expert Advisor has shown me a plus, but I do not need such a plus. I can flip a coin myself and open either Buy or Sell order and look, whether I'm winning or losing in a year. By the way, if I set MODE_SMA to MODE_LWMA (Linear Weighted Moving Average), the programme works fine.
Please, advise me, what is wrong? The principle is the same, but the way of calculation of moving averages has just been changed a bit.
The entire code is in attached file.
I have had replies here, but they are not competent and not on the merits. Allegedly I use 4 moving averages. This is not true, there are two moving averages, but for each moving average taken values for two bars (a total of 4 array calls, A, B, C, D):1 and 2 . In addition, they wrote that when an order is closed, we should lower the number of Total orders, but there is no need in this because the orders are counted using the Odertotal function and if I close an order, the order total itself changes its value at the next iteration. They also suggest using the so-called magic numbers to keep track of orders but I haven't got to that part of the manual yet. I should repeat that the program works when MODE_SMA and MODE_LWMA are used but not when MODE_EMA and MODE_SMMA are used. Who knows why, write me an answer please.
Please give me a hint.
I'm learning a programming language, and I'm having trouble understanding the behaviour of the programme. I have written an EA based on the textbook, but I've twisted it to a slightly different principle of operation.
The Expert Advisor is based on 2 muwings averaging. The idea is simple, moving averages cross, order is closed and opposite one is opened. I have written an EA and it works fine. Of course it is at a slight disadvantage, but in accordance with the idea. The entire problem is as follows (in bold):
A=iMA(NULL,0,Period_MA_1,0,MODE_SMA, PRICE_CLOSE,1); // A
B=iMA(NULL,0,Period_MA_2,0,MODE_SMA,PRICE_CLOSE,1); // B
C=iMA(NULL,0,Period_MA_1,0,MODE_SMA,PRICE_CLOSE,2); // C
D=iMA(NULL,0,Period_MA_2,0,MODE_SMA,PRICE_CLOSE,2); // D
If I change the way of calculating moving averages (it can show plus sign) and put exponential method( MODE_SMA) instead of simple one (MODE_EEMA ) and one more(MODE_SMMA), so called smoothed method, everything goes wrong. The working principle becomes even more amusing (in the strategy tester) as the EA opens an order at the very beginning of the period set and closes it at the end. I.e., for a year it opens one single trade at the beginning of the period, and closes it at the end. As a result, the Expert Advisor has shown me a plus, but I do not need such a plus. I can flip a coin myself and open either Buy or Sell order and look, whether I'm winning or losing in a year. By the way, if I set MODE_SMA to MODE_LWMA (Linear Weighted Moving Average), the programme works fine.
Please, advise me, what is wrong? The principle is the same, but the way of calculation of moving averages has just been changed a bit.
The entire code is in attached file.
I have had replies here, but they are not competent and not on the merits. Allegedly I use 4 moving averages. This is not true, there are two moving averages, but for each moving average taken values for two bars (a total of 4 array calls, A, B, C, D):1 and 2 . In addition, they wrote that when an order is closed, we should lower the number of Total orders, but there is no need in this because the orders are counted using the Odertotal function and if I close an order, the order total itself changes its value at the next iteration. They also suggest using the so-called magic numbers to keep track of orders but I haven't got to that part of the manual yet. I should repeat that the program works when MODE_SMA and MODE_LWMA are used but not when MODE_EMA and MODE_SMMA are used. Who knows why, write me an answer please.
I would also double-check conditions. There may be a problem there