Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 35

 
oDin48:

In fact, the only issue is to assign a bar number and write it into a variable, which can then be compared to the current value.

There's no need. Each bar already has its own number. All you need to know is on which bar a stop position was closed. What are the variables for? What if the Expert Advisor is restarted? The value of the variable will be lost. And this way, you can find the bar at which any selected closed position was closed, at any given time.

If you have programming experience, you can understand and implement the logic I've described.

 
artmedia70:

All you need to know is on which bar the stop position was closed.

This is not a problem as I need the first and second not to open on the same bar.

I write something like:

if ((Total==0)&&(Condition)) {Opn_B=true;} //example.

The second order will not open, but if the first one fails, it closes at stop and the condition triggers again and the second bar opens, which is exactly what I do not need. But if the next bar triggers SL and the condition is fulfilled, then you are welcome.

I apologize if I am being obtuse.

But the way I see it is as follows.

1) When opening an order, we should write the number of the bar in which it is opened into a variable.

2) When the number of orders is 0. We check the profit of the last trade (already written).

3) When opening the next order based on the signal, we check if the previous order was profitable or not. If it was losing, we check the numbers of the current bar and the bar, the last order was opened on. If they do not match, we open an order. (no problem to write)

Conclusion: I just need a function that allows me to know the number of the bar so I can assign this value to the variable in step 1 and compare it with the current value (number of the bar) in step 3.

 
oDin48:

This is not a problem as I need the first and second not to open on the same bar.

I write something like:

if ((Total==0)&&(Condition)) {Opn_B=true;} //example.

The second order will not open, but if the first one fails, it closes at stop and the condition triggers again and the second bar opens, which is exactly what I do not need. But if the next bar triggers a SL and the condition is fulfilled, then you're welcome.

I apologize if I am being obtuse.

But the way I see it is as follows.

1) When opening an order, we should write the number of the bar in which it is opened into a variable.

2) When the number of orders is 0. We check the profit of the last trade (already written).

3) When opening the next order based on the signal, we check if the previous order was profitable or not. If it was losing, we check the numbers of the current bar and the bar, the last order was opened on. If they do not match, we open an order. (no problem to write)

Conclusion: I just need a function that allows me to know the number of the bar so I can assign this value to the variable in step 1 and compare it with the current value (number of the bar) in step 3.

Anyway... go to Igor Kim's thread - you'll find plenty of examples there. I don't have time yet, sorry...
 
artmedia70:
Use a delta of 2 to 3 points when checking the MASK deviation


Do I add pips to each? Is it possible to program these two or three points?
 
oDin48:

This is not a problem as I need the first and second not to open on the same bar.

I write something like:

if ((Total==0)&&(Condition)) {Opn_B=true;} //example.

The second order will not open, but if the first one fails, it closes at stop and the condition triggers again and the second bar opens, which is exactly what I do not need. But if the next bar triggers a SL and the condition is fulfilled, then you're welcome.

I apologize if I am being obtuse.

But the way I see it is as follows.

1) When opening an order, we should write the number of the bar in which it is opened into a variable.

2) When the number of orders is 0. We check the profit of the last trade (already written).

3) When opening the next order based on the signal, we check if the previous order was profitable or not. If it was losing, we check the numbers of the current bar and the bar, the last order was opened on. If they do not match, we open an order. (no problem to write)

Conclusion: I just need a function that allows me to know the number of the bar so I can assign this value to the variable in step 1 and compare it with the current value (number of the bar) in step 3.



This function returns the bar number of the last position closed

Calling

if(Total==0 && NumberOfBarCloseLastPos()!=0)
   {
   Opn_B=true;
   }
 

Thank you very much. I already thought I was explaining something wrong, knowing that the solution should be simple.

You have been very helpful.

 

Can anyone tell me, when writing a script or an EA, what is the maximum number of elements I can fit into an array?

 
Dikii:

Can anyone tell me, when writing a script or an EA, what is the maximum number of elements I can cram into an array?

From a neighbouring thread........

 

guys!

how to specify in OrderSend the expiry time of the pending order "today".

 
smartemiy:

guys!

how to specify in OrderSend the expiry time of the pending order "today".

More correctly would be DeleteOrder at the appointed time. Rarely does the DC perform this expiry and delete the order at the command of the EA!
Reason: