Help with coding

 

Hi there,

I need to make a change on a simple expert advisor that is based on 2 slope direction lines.

This lines, changes to blue when on uptrend and red when on downtrend.

The expert advisor gets a global variable=1 when both uptrend (2 slope=blue) and a global variable=2 when both on downtrend (2 slope=red).

When global variable=1 the ea opens a position BUY, when global variable=2, the ea opens a position SELL.

The problem is that when the profit is reached, it closes the position but if both signals are still there, it opens an additional position. For instance, I am on a position BUY when both slopes are blue with a profit targer=20. When 20 pips are reached, the position is closed BUT IF BOTH SLOPES ARE STILL BLUE, it opens another position...

Can anyone help me with a code that does not open a second position like this? I want to be able to open several positions for the same currency pair, but not when one of them is closes.

I need something that creates a second global variable that after a position is closed it adds a value to it that will be also compared when both slopes gets with the same color, and besides the BLUE / RED conditions it also tests this global variable.

I have been thinking on the following:

- Both slopes becames RED;

- EA opens SELL;

- Second variable gets the NoOpenCondition=TRUE;

- When the position reaches its profit target (or stoploss) it is closed;

- The advisor waits for NoOpenCondition = FALSE and from this moment it waits for a new signal for potential positions.

This NoOpenCondition can be tested by waiting that at least one of the slopes became on the oposite color and when they get the same color again it is a moment for new positions.

Hope you can help me

Best regards

Paulo

 
batalhadematos:
Hi there, I need to make a change on a simple expert advisor that is based on 2 slope direction lines. This lines, changes to blue when on uptrend and red when on downtrend. The expert advisor gets a global variable=1 when both uptrend (2 slope=blue) and a global variable=2 when both on downtrend (2 slope=red). When global variable=1 the ea opens a position BUY, when global variable=2, the ea opens a position SELL. The problem is that when the profit is reached, it closes the position but if both signals are still there, it opens an additional position. For instance, I am on a position BUY when both slopes are blue with a profit targer=20. When 20 pips are reached, the position is closed BUT IF BOTH SLOPES ARE STILL BLUE, it opens another position... Can anyone help me with a code that does not open a second position like this? I want to be able to open several positions for the same currency pair, but not when one of them is closes. I need something that creates a second global variable that after a position is closed it adds a value to it that will be also compared when both slopes gets with the same color, and besides the BLUE / RED conditions it also tests this global variable. I have been thinking on the following: - Both slopes becames RED; - EA opens SELL; - Second variable gets the NoOpenCondition=TRUE; - When the position reaches its profit target (or stoploss) it is closed; - The advisor waits for NoOpenCondition = FALSE and from this moment it waits for a new signal for potential positions. This NoOpenCondition can be tested by waiting that at least one of the slopes became on the oposite color and when they get the same color again it is a moment for new positions. Hope you can help me Best regards Paulo

Yes, after your order filled, set a "Trade" variable to false. This variable will be re-set to true when one of the slope change its color.

FerruFx

 
FerruFx:
Yes, after your order filled, set a "Trade" variable to false. This variable will be re-set to true when one of the slope change its color.FerruFx

Dear FerruFX,

Thank you. I have thought about this solution and works when a specific profit target is reached since I can code this moment. But the problem is when an order is closed on a specific stop loss. I am unable to get a code that gives me the information that the order was closed on stop loss...

Regards

Paulo

 
batalhadematos:
Dear FerruFX,Thank you. I have thought about this solution and works when a specific profit target is reached since I can code this moment. But the problem is when an order is closed on a specific stop loss. I am unable to get a code that gives me the information that the order was closed on stop loss...RegardsPaulo

Just check in the history trades if the last one is in profit or loss.

FerruFx

 

Hi FerruFX:

This is the REAL TRO.

I noticed that you think everyone that uses one of my indicators is TRO over on FF and TSD.

Do you know that there are over 1 million people where I live? Do you think I am the ONLY FOREX trader here? Don't you think that some of them might know me and just might use my code, too? Did you know that my code is being used by traders on 6 out of the 7 continents?

Not sure why you seem to have such a problem with me. What have I ever done to you?

I know you don't like my donational indicators because people can get about 200 indicators from me for less than the price of one of yours.

And you probably don't like my free indicators either since they compete with your for sale indicators. Why pay for something when you can get it free?

And I know you don't like to share your source code because then the people using the code wouldn't have to rely on you for modications. Other coders could enhance the code. But you prefer keeping traders dependent on you.

But if you have a problem with me, you don't have to take it out on other people. Our investment group meets at the public library. When we log on, we all have the same IP Address. So I guess that's why you think some people have signed up more than once.

It's too bad that we can't all just get along.

 
therumpledone:
Hi FerruFX:This is the REAL TRO.I noticed that you think everyone that uses one of my indicators is TRO over on FF and TSD. Do you know that there are over 1 million people where I live? Do you think I am the ONLY FOREX trader here? Don't you think that some of them might know me and just might use my code, too? Did you know that my code is being used by traders on 6 out of the 7 continents?Not sure why you seem to have such a problem with me. What have I ever done to you?I know you don't like my donational indicators because people can get about 200 indicators from me for less than the price of one of yours.And you probably don't like my free indicators either since they compete with your for sale indicators. Why pay for something when you can get it free?And I know you don't like to share your source code because then the people using the code wouldn't have to rely on you for modications. Other coders could enhance the code. But you prefer keeping traders dependent on you. But if you have a problem with me, you don't have to take it out on other people. Our investment group meets at the public library. When we log on, we all have the same IP Address. So I guess that's why you think some people have signed up more than once.It's too bad that we can't all just get along.

Not sure why you post this here ???

For your info, I received a PM on FF with the exact same blabla ... coincidence !!!

PS: I don't have nothing against you. You're just little bit paranoid ...

 
FerruFx:
Not sure why you post this here ???For your info, I received a PM on FF with the exact same blabla ... coincidence !!!PS: I don't have nothing against you. You're just little bit paranoid ...

Why here? Because I can't post on those other forums.

Coincidence? NO. One of my friends PMed you after he saw what you wrote about me.

Paranoid? NO. I saw the FALSE ACCUSATIONS you wrote on Forex-TSD.

 
therumpledone:
Why here? Because I can't post on those other forums.Coincidence? NO. One of my friends PMed you after he saw what you wrote about me. Paranoid? NO. I saw the FALSE ACCUSATIONS you wrote on Forex-TSD.

Still don't understand why posting here in this "help with coding" thread.

And you may confuse with someone else. I don't remember make accusations about you on TSD forum.

FerruFx

Reason: