Ulrikhjul :
To insert the code, use the button
void moveStopLoss() { double sl = normalizePrice(m_position.StopLoss()); double currentPrice = normalizePrice(m_position.PriceCurrent()); for(int i=PositionsTotal()-1; i>=0; i--) { if(m_position.SelectByIndex(i)) { if(m_position.Symbol()==m_symbol.Name());// && m_position.Magic()==InpMagic) { //if buy pos if(m_position.PositionType()==POSITION_TYPE_BUY) { double slMoveLevel = sl+(NormalizeDouble(1000 * _Point, _Digits)); // DowJones : 1 point = 0,1 if(slMoveLevel <= currentPrice) { double slNew = sl;//+(NormalizeDouble(100 * _Point, _Digits )); //Move sl +10 double tpNew = m_position.TakeProfit();//+(NormalizeDouble(25*_Point, _Digits)); trade.PositionModify(m_position.Ticket(), slNew, tpNew); } } //If sell pos if(m_position.PositionType()==POSITION_TYPE_SELL) { double slMoveLevel = sl-(NormalizeDouble(1000 * _Point, _Digits)); // Ved DowJones er 1 point = 0,1 if(slMoveLevel >= currentPrice) { double slNew = sl;//-(NormalizeDouble(100 * _Point, _Digits )); //Move sl -10 double tpNew = m_position.TakeProfit();//-(NormalizeDouble(25*_Point, _Digits)); trade.PositionModify(m_position.Ticket(), slNew, tpNew); } } } } } }
Like that :)
Thanks

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
Hi.
I have made an EA which I want to improve by moving SL and TP while a position is running.
What I do not understand is how this method changes my backtesting result??!?
<Deleted> when i'm not calling this method - but when I'm calling the method my EA breaks down pretty fast...
As you can see I have out-commented the lines where it actually makes changes - so now it should not make any changes - but still the EA breaks.
When I debug and step though the code it seems like it doesen't make changes.
Does the execution-time matter that much? Or what can be my problem?
Code;
***