Problem with setting stop loss

 
I'm somewhat of a VB convert to MQL4 and am trying to figure out some demo code that I found. I'm running back testing with this piece of code, and have noticed that sometimes my stop loss doesn't seem to set at all.....it will enter into a position and just sit there, sometimes for days, and then all of a sudden close out at a huge loss. Can anyone point me in the right direction as to what isn't right with this code? Thanks!
Files:
 
brian2mn wrote >>
I'm somewhat of a VB convert to MQL4 and am trying to figure out some demo code that I found. I'm running back testing with this piece of code, and have noticed that sometimes my stop loss doesn't seem to set at all.....it will enter into a position and just sit there, sometimes for days, and then all of a sudden close out at a huge loss. Can anyone point me in the right direction as to what isn't right with this code? Thanks!

hi, just a question: why dont you send a stoploss in the OrderSend and than modify it with your Ordermodify and get the getlasterror send you the problem ?

By the way, I dont see any getlasterror in your coding for modifyorder (there is only in the ordersend), maybe it would help you alot ?

 
Thanks for the response.....this code was really a sample MACD test that came preloaded with Meta Trader 4 that I downloaded from forex.com, so I didn't write it myself. Do you know where in the code that I would put that modification and how? Thanks!