if(orderType%2==ORDER_TYPE_BUY) { price = Ask; tp = ATR*4; sl = Bid-ATR*2; if(price>(entryPrice-stopsLevel)) { entryPrice = price; orderType = ORDER_TYPE_BUY; } tpBuy = NormalizeDouble(entryPrice+tp,Digits()); slBuy = NormalizeDouble(entryPrice-sl,Digits()); }
I don't understand with this calculation. According to your code your slBuy would be Ask-Bid-ATR*2. If you want your SL to be ATR*2 difference using sl is already right you don't need to use ask price again.
And for your TP, BUY at the ASK and SELL at the BID (including SL and TP) you need to use Bid+ATR*4 instead of ATR*4.
hopefully it will help
Luandre Ezra:
Thank You. This is the first time doing this, and couldn't find an EA to do what I wanted, so I am making it myself. Those changes corrected the SL and TP points correctly. It now has SL set within 0.00200 pips and TP within 0.00400 pips using the 15M period. I will see how it works on the other periods. Thank you again.
I don't understand with this calculation. According to your code your slBuy would be Ask-Bid-ATR*2. If you want your SL to be ATR*2 difference using sl is already right you don't need to use ask price again.
And for your TP, BUY at the ASK and SELL at the BID (including SL and TP) you need to use Bid+ATR*4 instead of ATR*4.
hopefully it will help

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am working on building an EA to look for the candle to Close either above or below the BB, and ride it up or down. The additional parameters include:
I have been able to get it to find the trade setups, and enter both Buy and Sell. But I can not get the TP and SL to be set to the points I am wanting. I am using the ATR with a multiplier to set the SL based on the previous LowestLow within a range, and TP based on the risk reward ratio compared to the SL. I can not figure out how to get the R/R ratio input. And my current SL is getting put to a ridiculously far point, and do not know why. Any input to help with this would be greatly appreciated. Feel free to test it and manipulate it.