Jump to content
Sign in to follow this  
CrispyWings

Automatically set the stop-loss and take-profit levels for open trades with an EA.

Recommended Posts

Hello, Coders. I'm a beginner with no programming experience.

Just so you know, I manually open the trades for my own testing purposes only.

I created an EA to automatically set the SL (60 pips) and TP (1,400 pips) of open trades on 1-digit, 2-digit, 3-digit, 4-digit, and 5-digit symbols (including crypto BTCUSD), but it partially failed and I'm not sure why. Problems include:

1) While some trades are successfully and correctly assigned with SL & TP, the vast majority of symbols are not assigned with SL & TP at all.

2) My settings for SL=60 pips and TP=1,400 pips, some pairs are correctly set with 60 / 1,400 pips, but some pairs are only set with 0.6 / 140 pips.

Share this post


Link to post
Share on other sites

Your EA is modifying all trades off all the charts you are running it on, so if you run it on XAU, it will try to modify your EU trades as well, resulting in incorrect point information.

Share this post


Link to post
Share on other sites

Chimoong,


I'll have to think about the rounding issue tomorrow because it's past my bedtime. I suspect it has more to do with the fact that you multiplied the point by ten. Remove the multiplier and manually multiply your stops by 10.


I should correct myself as well. You are not required to use OrderClosePrice to calculate the stops. I just realized I was getting an error with OrderOpenPrice because I was running the EA on a day-old trade with price action that had moved beyond the stops. If you only run on new trades, openprice is fine; if you run on old trades, closeprice is preferable, but your stops will not be accurate based on entry price.

Share this post


Link to post
Share on other sites
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

FinanceHeaven

Info

Any opinions or market advice expressed in the community sections do not necessarily reflect the views of FinanceHeaven or its affiliates. The comments and opinions expressed are those of traders who are either inexperienced or inexperienced. FinanceHeaven.net or its affiliates do not review or research the comments. If you choose to base your decisions or trades on the comments, you do so at your own risk. FinanceHeaven and its affiliates are not liable for any losses incurred as a result of using the content provided.

WARNING

FOREX trading carries a high level of risk and may not be suitable for all investors. Leverage increases risk and loss exposure. Before you decide to trade foreign exchange, think about your investment goals, level of experience, and risk tolerance. Your initial investment may be lost in part or entirely. Do not put money into investments that you cannot afford to lose. Educate yourself on the risks of foreign exchange trading, and if you have any questions, seek advice from an independent financial or tax advisor. Any data and information is provided "as is" for informational purposes only and is not intended for trading or advice. Past performance is not a predictor of future outcomes.

×
×
  • Create New...