code executed for only the first time

To add comments, please log in or register
ARRESSS23
18
ARRESSS23  

Hello Every body.

 

this message is translated from french to english via the google translation service.

I'm sorry if you find some errors.

 

I am a beginner in programming, I just studied the language mql4.

I'm training on designing some basic functions.
I want to program a very easy code:

 

I want metatraider to execute a buy order, then if the price go up or down by 30 points, it opens a second sale order.

After 60 points, it closes the 2 buy and sell orders.

 

by doing a backtest, the buy order is executed also the sell order, but only for the first time. then only buy ordrer is executed.

 

where is my errors please ???

thank you 
Files:
TEST_5.mq4 4 kb
William Roeder
20251
William Roeder  
ARRESSS23:

this message is translated from french to english via the google translation service.

by doing a backtest, the buy order is executed also the sell order, but only for the first time. then only buy ordrer is executed. where is my errors please ???
  1. Welcome. When using mechanical translation, always use simple language structure.
    You can also translate by selecting text and using the translate pull down. Translate

  2. You open a sell and set trade to false. When do you ever set it to true?
ARRESSS23
18
ARRESSS23  
whroeder1:
  1. Welcome. When using mechanical translation, always use simple language structure.
    You can also translate by selecting text and using the translate pull down.

  2. You open a sell and set trade to false. When do you ever set it to true?

Thank you Mr whroeder1;

I defined the (trade) variable as (true) at the beginning of the code.

Frankly, I used this condition:
If (trade == True)
{
OrderSend ()
trade = False;
}
And I don't know its meaning logically. I used it to avoid the execution of multiples sell orders.


William Roeder
20251
William Roeder  
ARRESSS23:I defined the (trade) variable as (true) at the beginning of the code.
bool trade=true; // Global declaration
Yes you did, but that is not what I asked. I said "You open a sell and set trade to false. When do you ever set it to true?"
ARRESSS23
18
ARRESSS23  
whroeder1:
Yes you did, but that is not what I asked. I said "You open a sell and set trade to false. When do you ever set it to true?"

hmmmmm .

Now, I understand what you mean. 


I can only put it beside to the comparison of (normalisedouble).
I tried but it did not work.
what do you think ?? 

Files:
TEST_6.mq4 4 kb
To add comments, please log in or register