Tiny EA adjustment

MRT

Trader
Apr 29, 2022
4
0
6
33
Hello Coders!

So I found these two EAs and modified them little bit to make sure that they will immediately open a buy/sell position on the next open candle.
Everything works brilliant.

However now I need to "force" them to open a buy/sell position on the next candle but X points away from the open price.
When it comes to the short position -> open trade if BID is 10 points away from new candel's open price,
e.g. Open Price is 127.947 - 10 points = 127.937 EA opens a short position.
Same case when it comes to the long position but obviously Open Price + 10 points instead minus.

No idea how to do it
1f641.png

Could somebody please help me with this modification ?
 

Attachments

  • Trade_Candle_Open v1.1_SELL_ART.mq4
    1.2 KB · Views: 7
  • Trade_Candle_Open v1.1_BUY_ART.mq4
    1.2 KB · Views: 4

Enivid

Administrator
Staff member
Nov 30, 2008
18,530
1,355
144
Odesa
www.earnforex.com
The EA only looks at the previous candle's Open and Close, it has nothing to do with the current Ask/Bid rates. Also, your Sell can in no way open a Buy trade or vice versa. Perhaps, you've attached the wrong files...
 

MRT

Trader
Apr 29, 2022
4
0
6
33
The EA only looks at the previous candle's Open and Close, it has nothing to do with the current Ask/Bid rates. Also, your Sell can in no way open a Buy trade or vice versa. Perhaps, you've attached the wrong files...
I've attached the correct files. At the moment they work fine.
Sell is open when the new candle opens. Same when it comes to the Buy.
Not even one point delay from the open price.
What I need now is that delay.
Just don't know how to modificate the code.
I've tride add lines such as OPEN - 10*Point or BID-10*Point but I don't know anything about coding so that is just guessing.
Can someone assist me with a solution please ?
 

3ther8up222

Trader
Jul 21, 2022
4
0
6
Hello Coders!

So I found these two EAs and modified them little bit to make sure that they will immediately open a buy/sell position on the next open candle.
Everything works brilliant.

However now I need to "force" them to open a buy/sell position on the next candle but X points away from the open price.
When it comes to the short position -> open trade if BID is 10 points away from new candel's open price,
e.g. Open Price is 127.947 - 10 points = 127.937 EA opens a short position.
Same case when it comes to the long position but obviously Open Price + 10 points instead minus.

No idea how to do it
1f641.png

Could somebody please help me with this modification ?
Very easy, I've coded an EA like this before. The standard functions iOpen will be the one used for this plan as it returns a value/price if you wish to execute the order on the previous candle . As for the Buy/Sell conditions, I'm not clear on them as you haven't explained them. However, "X Points" away from the previous candle, or current candle? If current candle, then you'll just use MarketInfo function: "MarketInfo(_Symbol,MODE_STOPLEVEL);" of course, make the data type a double, name the variable something like "minimum_distance", then use it in the OrderSend() function in the price parameter of that function like so: Ordersend(Bid-minimum_distance) (Fore sells) and OrderSend(Ask+minimum_distance) for Buys. Since you stated that you wanted the order execution 10*Points away, the minimum distance is usually 10 points away anyways on most brokers, so it'll work in your favor. I know this is a late reply, but I'm new to this forum.