Take Profit using Closing Price plus ATR


Need help with this idea for a take profit function. the idea is as follows:

When entry is made the take profit level should be entry price+atr but it doesnt close the position unless the closing price of a candle is greater than or equal to the entry price+atr.

No SL, necessary just the take profit

stout0181: When entry is made the take profit level should be entry price+atr

You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit and open at the Ask.

  1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

  2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
              MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

  3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
    Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).


@William Roeder Thanks for that.

to clarify here is a picture of what i have traded manually in the past.

red line= entry

blue line= entry+atr value

yellow line is the actual close. note that the bar closes above the entry+atr. that is when i would like to close the trade. the same thing for short positions. 

i thought that the best way to accomplish this would look something like iClose (returning the closing price of the bar), and then comparing that to the ask/bid + ATR value. do you think that this is a good way to about it or do you have another way that you would accomplish this task?

as far as handling spreads i believe i could include a do not trade function to limit the closing hour of the day. 

again, thanks for the help. im on deployment right now and just trying to make the most of my time here by learning something new.