Help with code - page 2

 
Archael:
Jon

Dear Jon,


Thank you very much.

The way it works is exactly what I want.


Regards


Paulo

 

Hi Paulo,

[ I know that it is more than 2 years that this thread had seen any new response, but the answer to the question which I looked at is confusing and somewhat is not clear and apparently I had stumbled across the same issue with out any clear answer and here is my brief on the solution I found out and also recording here so as to help out any other coming onto this thread looking for what is appropriate to do ]

I had come across this issue very frequently and was frustrated enough to do my own quest of searching the solution and apparently I had found out that in context with your explanation of the price level change(invalid stops or invalid price) and particularly the error 130 is meant to describe the invalid stops and MODE_STOP_LEVEL can help you figure out what the symbol pair allow the minimum stop level to be but despite all of that -- the problem is with the brokers as in most brokers do not comply the orders sending the takeprofit/stops information along with the sending of the order/creating the order; so I figured out that it is perfectly okay to send the order without stoploss information in the OrderSend() function and then use OrderModify() to impose the stoploss and takeprofit for the order in the context. Believe me, I have hardly had any error with the OrderSend or invalid price type errors(particularly the error 130) since then!

So, in summary -- first use OrderSend() with stoploss and takeprofit as 0, then use OrderModify() to set your appropriate stops and profit levels, (ofcourse, MODE_STOP_LEVEL should be complied).

Cheers!

Reason: