Page 1 of 1

Can you check why is my EA not placing tp and sl on market orders ?

Posted: Sun Apr 16, 2023 8:39 am
by xzerax
my ea uses pending and market orders to place trades when conditions met ,, however it is not placing any tp or sl on market orders ,, i tried changing the code and disable market orders even ,, but i ran into many orders ... help me please ?

my try to disable market orders (faild) :

// Disable market orders
bool send_order = false;

// Check if the order type is market
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
send_order = false;
}

Re: Can you check why is my EA not placing tp and sl on market orders ?

Posted: Fri Jan 26, 2024 2:52 am
by JohnnyRy
I see that your favorite indicator in your forum profile is Renko in MT4, and your OrderSend code uses NULL as the traded symbol. If you're running the EA on an offline Renko chart, I'm not sure if NULL as the traded symbol within the EA's OrderSend function will work. I also see that your Symbol() code seems to be working. Maybe try replacing NULL with Symbol(). Of course, you must have Offline Chart unchecked in your MT4 chart properties.

Also, I see that your code incorporates your stops (SL's and TP's) into your initial order. if you're trading with an ECN broker, your stops must be sent in a separate order modification after an initial naked order has been sent.

Re: Can you check why is my EA not placing tp and sl on market orders ?

Posted: Fri Jan 26, 2024 4:11 am
by JohnnyRy
One more thing... If your Renko chart generator creates a unique custom symbol like EURUSD_Renko, then you'll have to hard code the source chart symbol (EURUSD) into all of your EA's trading code (OrderSend, OrderClose, OrdersTotal, etc.). Your technical analysis/conditions code can continue to use Symbol(). In this way, your EA analyzes the offline chart but executes all trade related functions based on the standard source chart.