Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 269
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
int res;
bool nomber = OrdersHistoryTotal();
bool tip=OrderType();
if(OrderSelect(nomber,SELECT_BY_POS,MODE_HISTORY)==true)
{
tip=OrderType();
}
ma=iMA(NULL,0,MovingPeriod,120,MODE_SMA,PRICE_CLOSE,1);
if(Bid<ma)
if(tip!=OP_SELL)
{
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,Bid-TP*Point,"",MAGICMA,0,Red);
return;
}
I wrote it here but it still does not work. What is wrong? Please advise.
Good afternoon.
How to write the condition in the four: if the first Friday of the month was a bull, and
Thesecond Monday is bearish, then we open a sell trade.
the second Monday is bearish then open a sell trade.
Now this is an interesting problem: it can show the sequence of steps to solve any problem
Determine the current month MM and year YYYY. Take the date 1.MM.YYYY and determine the day of the week for it.
2. Think of a formula or two (for this we make up two tables of 7 rows) and use these formulas to determine the dates of the days in which you are interested
3. If the second date in the future - output.
4. Using the dates we determine the numbers of corresponding bars on the daily chart
5. Determine the number of bars by their belonging to the bulls - bears.
6. Making a conclusion about entering the market
This is an interesting problem: it can be used to show a sequence of steps to solve any problem
Determine the current month MM and year YYYY. Take the date MM.YYYY and determine the day of the week for it.
2. Think of a formula or two (for this we make up two tables of 7 rows) and use these formulas to determine the dates of the days in which you are interested
3. If the second date in the future - output.
4. Using the dates we determine the numbers of corresponding bars on the daily chart
5. Determine the number of bars by their belonging to the bulls - bears.
6. Making a conclusion about entering the market
In fact, I still haven't seen the answer in the form of a code ... The algorithm is clear ...
If the algorithm is clear, write a program... If you have difficulties, ask...
If the algorithm is clear - write a program... If you have problems - ask ...
You must be a genius)) You think if I knew I would ask here? Just write the day of the week is not a problem ... The question is how to determine what week of the month? The Mt4 book doesn't say anything about it.
Any questions from newbies in MQL4, help and discussion on algorithms and codes
bool tip=OrderType();
if(OrderSelect(nomber,SELECT_BY_POS,MODE_HISTORY)==true)
{
tip=OrderType();
}
Here I have preselected it, but it still doesn't work. What's wrong? Please advise.
Let's look at this part. In the first line, the variable nomber stores the number of orders in the history. Let's put the cursor on OrdersHistoryTotal() and press F1. Here you can see:
intOrdersHistoryTotal();
The function returns an integer number. But a bool has only two values. Well, how can a bool contain a value of int type?
The second line contains the same error and one more. You put the cursor on OrderType() and press F1. We see:The order must be preselected using the OrderSelect() function.
The third line contains a horrible situation. 1) if(OrderSelect( - if an order is selected, something is executed. But what if an error occurs here? Your program is still running. 2) An order with the number nomber should be selected. But is there an order with such a number? What is the minimum and maximum order number if the total number is nomber? 3) Instead of if(OrderSelect(nomber,SELECT_BY_POS,MODE_HISTORY)==true) almost anyone would write simply if(OrderSelect(nomber,SELECT_BY_POS,MODE_HISTORY)) and one more little thing.
My advice is this - start learning the language with simple elements, write simple scripts and display the result. Check the result of each line
Why do you need to know which week of the month it is? It's not in my algorithm. (only put a space after punctuation marks)
Why do I need to know what week of the month it is? In my algorithm, it does not. (put a space only after punctuation marks)
I'm sorry, you probably weren't paying attention to the question.
How do you write the condition in the four: if the first Friday of the month was bullish and
the second Monday is bearish then we open a sell trade.
DayOfWeek()==1 Monday is clear, but what Monday of the month?)
In fact, I never saw an answer in the form of a code ... The algorithm is clear ...