Input needed on some code...should be very easy

 

This is closing partial lots BUT...not exactly doing what I expected. Maybe you can see the issue here.

should close 1 lot when there is a BUY and the price goes .00071(just a random number i'm testing on a 1 minute chart)

or close 1 lot when there is a SELL and price goes .00071 down

using a 5 digit broker by the way. There is only 1 trade ever open and only by this EA, so no scrolling through orders

THANKS for INFORMATION!

if (IsConnected() && IsTradeAllowed()) while (IsTradeContextBusy()) Sleep(75);
if (OrdersTotal()>0) {OrderSelect(0, SELECT_BY_POS,MODE_TRADES);
RefreshRates();
if (Ask >= (OrderOpenPrice()+ (.00071)) && OrderLots() == 2 && (OrderType() == OP_BUY)) {
OrderClose(OrderTicket(),1,Ask,10,Red); }
if (Bid <= (OrderOpenPrice()- (.00071)) && OrderLots() == 2 && (OrderType() == OP_SELL)) {
OrderClose(OrderTicket(),1,Bid,10,Blue); }}

 
spacechimp:

This is closing partial lots BUT...not exactly doing what I expected. Maybe you can see the issue here.

should close 1 lot when there is a BUY and the price goes .00071(just a random number i'm testing on a 1 minute chart)

or close 1 lot when there is a SELL and price goes .00071 down

using a 5 digit broker by the way. There is only 1 trade ever open and only by this EA, so no scrolling through orders

THANKS for INFORMATION!

if (IsConnected() && IsTradeAllowed()) while (IsTradeContextBusy()) Sleep(75);
if (OrdersTotal()>0) {OrderSelect(0, SELECT_BY_POS,MODE_TRADES);
RefreshRates();
if (Ask >= (OrderOpenPrice()+ (.00071)) && OrderLots() == 2 && (OrderType() == OP_BUY)) {
OrderClose(OrderTicket(),1,Ask,10,Red); }
if (Bid <= (OrderOpenPrice()- (.00071)) && OrderLots() == 2 && (OrderType() == OP_SELL)) {
OrderClose(OrderTicket(),1,Bid,10,Blue); }}

Any messages in the Experts/Journal tabs?

 
i had the ask and bid screwed up...will know for sure after some more watching
 

if (OrdersTotal()>0) {
OrderSelect(0, SELECT_BY_POS,MODE_TRADES);
Tick = OrderTicket(); // Number of selected order
Tip =OrderType(); // Type of selected order
Price =OrderOpenPrice(); // Price of selected order
Lot =OrderLots();
if (Bid >= (Price + (TakeProfit * Point)) && Lot == 2 && (Tip == OP_BUY)) {
OrderClose(Tick,1,Bid,10,Red); }
if (Ask <= (Price - (TakeProfit * Point)) && Lot == 2 && (Tip == OP_SELL)) {
OrderClose(Tick,1,Ask,10,Blue); }}

changed to that on a 4 digit broker but it still won't seem to operate properly.

TakeProfit is external and 10 pips.. tesing this on a 1 minute chart on G/J for debug

anybody spot what the issue is with this?

Reason: