[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 47
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
Dear forum specialists, who also used to understand almost nothing.
I am trying to write a simple Expert Advisor that uses Parabolic Sar indicator as a training tool. Its action is supposed to be elementary: if price was below the Sar value and then got higher, then we should buy exactly at the moment when the price crosses the indicator and exactly once with setting stop loss and take profit of 10 points. And if it is vice versa, then sell.
The problem is that it always buys and sells, but it does it while there is free money on the deposit, not once. In other words, as soon as the price rises above the level of Sar, he is continuously buying until the price is higher, and as soon as the price is below Sar, he is selling all the time until the price is below.
In fact, the question is: how to make our EA make only one deal when these conditions appear, and not an endless set of them?
Here is the code of my Expert Advisor.
I want to ask you to help figure it out, I promise that when I become a guru, I will not ignore the requests of people like me.
Regards, Denis Orlov.
Dear forum specialists, who also used to understand almost nothing.
I am trying to write a simple Expert Advisor that uses Parabolic Sar indicator as a training tool. Its action is supposed to be elementary: if price was below the Sar value and then got higher, then we should buy exactly at the moment when the price crosses the indicator and exactly once with setting stop loss and take profit of 10 points. And if it is vice versa, then sell.
The problem is that it always buys and sells, but it does it while there is free money on the deposit, not once. In other words, as soon as the price rises above the level of Sar, he is continuously buying until the price is higher, and as soon as the price is below Sar, he is selling all the time until the price is below.
In fact, the question is: how to make our EA make only one deal when these conditions appear, and not an endless set of them?
Here is the code of my Expert Advisor.
I want to ask you to help. I promise that when I become a guru, I will not ignore requests of other dummies like me.
Sincerely, Denis Orlov.
Where do you keep the predictive value of the indicator? (in what variable...?) the same thing with the price value
and where do you have the indicator's previous value? (in which variable...?) the same with the price value
The point is that the previous indicator value is on the previous candle and the price crosses the indicator value on the current candle.
It's the same with price, what does "previous price value" mean, the price of the previous tick? or the close of the previous candle, but that's not it.
I understand that I have to add something, but what exactly I can't understand. Please help, this is my first experience.
>> Respectfully, Orlov Denis.
The point is that the previous indicator value is on the previous candle and the price crosses the indicator value on the current candle.
It's the same with the price, what does "previous price value" mean, the price of the previous tick? or the close of the previous candle, but that's not it.
I understand that I have to add something, but what exactly I can't understand. Help please, this is my first experience.
Sincerely, Orlov Denis.
Did you understand what you said, then? You are checking the value at a given time.
Two mutually exclusive conditions. When did he then become taller?
Did you understand what you said, then? You're checking the value at a given time.
Two mutually exclusive conditions. When did it get higher?
Maybe I formulated the comment wrong, but the essence is still true, the price level has become higher than the indicator value, you have to buy and it buys, but you have to do it once, and the EA buys as long as there is money on the deposit. You just need to limit the number of deals. Make no more than one at a time, that is what is not working.
but if there was a Sell order in the history and then the Expert Advisor closed it (in the history type, it (its close) is shown as t/p or s/l - will it be considered as the last one?
If an order (buy or sell) was closed last (the Expert Advisor closed it, or it triggered t/p or s/l) and passes under the conditions of
if(OrderSymbol()==Symbol()){
if(OrderMagicNumber()==MagicNumber){
If an order (buy or sell) was closed last (Expert Advisor closed it, or t/p or s/l was triggered) and passes the conditions
if(OrderSymbol()==Symbol()){
if(OrderMagicNumber()==MagicNumber){
Yes, it's probably because I excluded OrderMagicNumber() from the code
I want to avoid reopening orders after they have been closed. I want to make it so my orders wouldn't reopen after closing (it sometimes happens that conditions for reopening still exist). The same story with sell. I thought it would be cool to state in my conditions if I had a Buy position and had profit - not to reopen Buy position.)
((
Yes, that's probably because I excluded OrderMagicNumber() from the code
I want to make it so that orders would not reopen after closing. I thought it would be cool if I specified in the conditions, if I had a Buy position and had a profit - not to reopen Buy again. But it still opens - bastard!)))
((
The easiest way to control the number of orders opened at the same time
Read the description of OrderSend( ... ).
The magic number (magik) is assigned to an order when it is sent to the server.
This is mainly used to identify pending orders/positions.
I.e., so that the EA does not touch "alien" orders. This is done by an EA or a script.
The Magician cannot be set manually. You set the rules in the EA/Script yourself.
The magician is usually a static one but it can be dynamic if necessary.
Look at some simple examples from Kodobase, and it should become clear to you.
Why cannot you identify "your" orders by ticket number? They are unique no matter how many Expert Advisors are running.
For example, an EA opens an order, remembers the ticket, closes it, and forgets it.
Why can't you identify "your" orders by the ticket number? They are unique, no matter how many Expert Advisors are running.
For example, an EA opens an order, remembers the ticket and forgets about it, after that it closes it.