Well use the debug mode not only to check a certain value but even the reason - single calculation by single calculation - why this value was assigned to the variable.
Carl Schreiber:
Well use the debug mode not only to check a certain value but even the reason - single calculation by single calculation - why this value was assigned to the variable.
Well use the debug mode not only to check a certain value but even the reason - single calculation by single calculation - why this value was assigned to the variable.
Hello,
After I close and open and debug again, there are reasonable values now. Don't know what happened, but this bug is not my worries now.
If you got the time, I wish you would answer my new bug. Any help would be appreciated:
https://www.mql5.com/en/forum/346215
Trailing stop loss only work in next bar, not every single tick as intended.
- 2020.07.08
- www.mql5.com
Hello everyone! So I have a stop loss check in the Ontick function like this: Some part of the code is hide away for simplicity...
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 am pretty new here and to the platform.
So I wanna deal with trailing stop loss, so I will have to get access to the stop loss of the current postion.
Here is the way I open a position, which has no problem as far as I know.
However, when it enters the function
void CheckTrailingStop(double now_price, double SLTrigger){ double SL = NormalizeDouble(now_price - SLTrigger, _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 && now_price > PositionGetDouble(POSITION_PRICE_OPEN) + 0.5*SLTrigger){ ExtTrade.PositionModify(PositionTicket, now_price,0); } } } }And I use debug mode an watch the value of CurrentStopLoss, it gave me 8.3575835936946108E-312, which makes no sense.
Attached is the time when I watch the variable, as you can see, the position ticket gives me 2, which I guess means that there indeed has a position.
Thanks a lot. Any help will be appreciated.