How to draw an arrow where the stop loss or the take profit have closed a buystop order

 

I'd appreciate if someone could help me. Instead of using market orders with the stop loss and take profit internally coded in my EA, I want to try with pending orders with the stop loss and take profit embedded in them. The thing is that the OrderSend() function draws an arrow when the order is opened, but it doesn't draw anything where the stop or the take profit are executed, nor draws the line that links order open and close points. Is there a simple way to draw both the closing arrow and the connector line after the stoploss and takeprofit?


Thank you!

 
JdR9966:

I'd appreciate if someone could help me. Instead of using market orders with the stop loss and take profit internally coded in my EA, I want to try with pending orders with the stop loss and take profit embedded in them. The thing is that the OrderSend() function draws an arrow when the order is opened, but it doesn't draw anything where the stop or the take profit are executed, nor draws the line that links order open and close points. Is there a simple way to draw both the closing arrow and the connector line after the stoploss and takeprofit?


Thank you!

This is how I would do it: (not sure how correct it would be)

I'm not 100% sure what you're asking for; but try write a for loop that picks up when order closes at stop or t.p then use object create for the EA to draw the arrow at that price/ time. Or alternatively, if I have misunderstood what you are asking, my apologies.

 
Buystop's are never closed; they are only deleted or become buy orders.
 
WHRoeder:
Buystop's are never closed; they are only deleted or become buy orders.
Yes, you're right. I meant an order sent as a buystop, that became buy order, and then was closed by the TP or the ST
DeanDeV:

This is how I would do it: (not sure how correct it would be)

I'm not 100% sure what you're asking for; but try write a for loop that picks up when order closes at stop or t.p then use object create for the EA to draw the arrow at that price/ time. Or alternatively, if I have misunderstood what you are asking, my apologies.

Yes, you understood well. Thank you for the help. I was wondering if there was a more straightforward way to do it, and now I guess there isn't so I will have to use the ObjectCreate()
 
JdR9966:
Yes, you're right. I meant an order sent as a buystop, that became buy order, and then was closed by the TP or the STYes, you understood well. Thank you for the help. I was wondering if there was a more straightforward way to do it, and now I guess there isn't so I will have to use the ObjectCreate()

Hi,


Did you manage to complete the task with the Object Create() function?

 
JdR9966: but it doesn't draw anything where the stop or the take profit are executed,

nor draws the line that links order open and close points. Is there a simple way to draw both the closing arrow and the connector line after the stoploss and takeprofit?
  1. Yes it does


  2. Go to Account History tab and drag the order to the chart. There's your arrows and line. Shift drag and there is all the orders (including any deleted ones.)
 
JdR9966:

I'd appreciate if someone could help me. Instead of using market orders with the stop loss and take profit internally coded in my EA, I want to try with pending orders with the stop loss and take profit embedded in them. The thing is that the OrderSend() function draws an arrow when the order is opened, but it doesn't draw anything where the stop or the take profit are executed, nor draws the line that links order open and close points. Is there a simple way to draw both the closing arrow and the connector line after the stoploss and takeprofit?


Thank you!


I think your broker does not allow us to set SL and/or TP value in OrderSend function. If so, then  we should let SL/TP value to 0 and add OrderModify function to set SL/TP value.

(just aware that this thread is old)

 
William Roeder #:
  1. Yes it does


  2. Go to Account History tab and drag the order to the chart. There's your arrows and line. Shift drag and there is all the orders (including any deleted ones.)
I know this is an old thread (as most are), but I had no idea this worked (dragging the order onto the chart). Here's my situation. I have stop orders that get placed and eventually executed. On my live chart, when the order gets closed, it draws the line from the order open to to the order close, but here's where it gets a little more complicated. I have a function that closes only part of an order (OrderLots()/2). For example; buy stop opened, hits a certain price and closes half of the OrderLots. It draws a line to that point on my chart, but the remaining portion becomes a new ticket number. Then when that ticket eventually closes (the remaining lots from the initial order), no line is drawn to it. However, from what I just learned from you William (dragging the order onto the screen), it then draws the line to it. How can I easily automate this? I mean, I know I can track and associate the two orders within my EA with quite a bit of code, but it seems there may be an easier way seeing as how dragging and dropping said order onto the chart draws the line. It looks like it's just drawing a line from the related OrderOpen (the original stop order converted to market) to the OrderClose (itself). When I run the same EA in the strat tester, it does the line from the original market order to both the first order close and the second order close, but not on live charts. On live charts it only does the first order close.