Serious problem with Logic of trade entry point

 

I am learning MQL and writing an EA to carry out trades for me. I am new to programming, and have been working for two days now trying to work out how to solve this problem, with different scenarios and logic within the program.

The problem I have is that I would like my EA to trade for me at a certain value (X) but I would like the EA to know if it was above or below this value and to initiate the correct trade, if the price moves in either direction.

.

So if X == 1.5000 and the price was 1.4000 I would not want a trade to be put on until the price moved to 1.5000, and then I would want it to be a BUY trade. Same vice versa.

.

The problem I have is I do not know how to stop the EA from trading until it reaches this pre-determined price.

I could solve this by entering a STOP when the price is determined, but I would like not to show the broker my positions if this is at all possible. The other option is to enter the trade manually, but this is not convenient especially for testing purposes and if a TP point is reached, I need the program to reconsider a starting value again so that re-entry to the market is automatic.

.

 

First define entry condition and exit conditions. If you have a trade active do you alow further trades?

Sugest you try to read and understand how the MACD Sample EA works which is supplied with MT4

 
Ickyrus:

First define entry condition and exit conditions. If you have a trade active do you alow further trades?

Sugest you try to read and understand how the MACD Sample EA works which is supplied with MT4


i have defined entry condition and exit condition. Just now, if there can only be one trade on.

I will read that sample EA, thanks

 
MickGlancy:


i have defined entry condition and exit condition. Just now, if there can only be one trade on.

I will read that sample EA, thanks


with iHighest() and iLowest() you can determine ich price was higher or lower then value (X) .

if price was lower and Close[0]>value(x) Open Buy

 
MickGlancy:

I am learning MQL and writing an EA to carry out trades for me. I am new to programming, and have been working for two days now trying to work out how to solve this problem, with different scenarios and logic within the program.

The problem I have is that I would like my EA to trade for me at a certain value (X) but I would like the EA to know if it was above or below this value and to initiate the correct trade, if the price moves in either direction.

.

So if X == 1.5000 and the price was 1.4000 I would not want a trade to be put on until the price moved to 1.5000, and then I would want it to be a BUY trade. Same vice versa.

.

The problem I have is I do not know how to stop the EA from trading until it reaches this pre-determined price.

I could solve this by entering a STOP when the price is determined, but I would like not to show the broker my positions if this is at all possible. The other option is to enter the trade manually, but this is not convenient especially for testing purposes and if a TP point is reached, I need the program to reconsider a starting value again so that re-entry to the market is automatic.

.



I'm from the UK and have problems interpreting this statement. Exmple "but I would like to know if IT was above or below this value" here IT refers to the last object mentioned which would be EA but that makes no sense so perhaps IT refers to "trade at a certain value" but still makes no sense as the price you are going to trade at must be known so asking if the self reference is above or below a known value makes no sense so I must conclude that IT refers to something not mentioned in the preceeding words so we guess at price which does make a little sense, however I loose all understanding as the sentence continues. I am sorry but I am just not intelligent enough to interpret this post.
 
Ickyrus:

I'm from the UK and have problems interpreting this statement. Exmple "but I would like to know if IT was above or below this value" here IT refers to the last object mentioned which would be EA but that makes no sense so perhaps IT refers to "trade at a certain value" but still makes no sense as the price you are going to trade at must be known so asking if the self reference is above or below a known value makes no sense so I must conclude that IT refers to something not mentioned in the preceeding words so we guess at price which does make a little sense, however I loose all understanding as the sentence continues. I am sorry but I am just not intelligent enough to interpret this post.


Sorry, please let me explain better. I am from the UK too. This is new to me, so please excuse my poor attempt at explaining my problem.

ok. I have a fixed price which I would like to make a trade at. eg, 1.50000

When I switch on MT4, the price may be above or below my intended entry point but the entry point is still there.

I want the EA to enter the trade as a BUY if the price moves to my entry point (1,5000) from below

I want the EA to enter the trade as a SELL if the price moves to my entry point (1.5000) from above

I can define the entry point but I do not know how to make the EA decide on which direction it is coming from. My attempts to do this have only caused two opposing trades to be entered at the same time.

Does that make more sense ?

 

What is your exit condition?

 

Do you want the EA to quit after entering the order? Do you want the EA to quit or another way of putting in detach itself from the chart when the trade is closed? So you can then use the EA to start a new entry condition. Manually what you are asking can be achieved with pending orders BUY_STOP etc.

 
Ickyrus:

What is your exit condition?


My exit condition is when it reaches TP or if it doesnt I want to put in a trailing SL but Ive not worked out how to do that yet either,

I was going to try and get the EA buying for me at the right moment, then develop it to meet my exit point

 
Ickyrus:

Do you want the EA to quit after entering the order? Do you want the EA to quit or another way of putting in detach itself from the chart when the trade is closed? So you can then use the EA to start a new entry condition. Manually what you are asking can be achieved with pending orders BUY_STOP etc.


I know about the pending orders, I think that would be simpler even on the EA than what I am trying to do, but I want the EA to work completely without sending pending orders or Stop Loss ? Take Profit levels to the broker
 
MickGlancy:

I know about the pending orders, I think that would be simpler even on the EA than what I am trying to do, but I want the EA to work completely without sending pending orders or Stop Loss ? Take Profit levels to the broker

I looked at other Ea's but they seem to specify lots of conditions, but not a specific price, as the only condition for market entry