Please help me point out any issue associated with the code which compile convenient with no error but seems not to trail the stoploss on vix75 index
Please learn to use the Code Styler, so that your code is readable. If you want our help, it is the least you can do to facilitate our reading your code.
I've made no changes. This is the exact same code, just run through the Styler and removing some of the extra empty lines. See how it is much more readable?
//Create an instance of CTrade #include<Trade\Trade.mqh> CTrade trade; void OnTick() { double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); if (PositionsTotal()==0) trade.Buy(0.30, NULL, Ask, (Ask-1000*_Point), 0, NULL); CheckTrailingStop(Ask); } void CheckTrailingStop(double Ask) { double SL=NormalizeDouble(Ask-150*_Point, _Digits); for(int i=PositionsTotal()-1; i>=0; i--) { string symbol=PositionGetSymbol(i); if (_Symbol==symbol) { ulong PositionTicket=PositionGetInteger(POSITION_TICKET); double CurrentStopLoss=PositionGetDouble(POSITION_SL); if (CurrentStopLoss<SL) { trade.PositionModify(PositionTicket, (CurrentStopLoss+10*_Point), 0); } } } }
Fernando Carreiro #:
Please learn to use the Code Styler, so that your code is readable. If you want our help, it is the least you can do to facilitate our reading your code.
I've made no changes. This is the exact same code, just run through the Styler and removing some of the extra empty lines. See how it is much more readable?
Thank You So much. Is the code correct with styler
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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