I want to create a function to open an order and one to close the pending order or the position.
No problem with opening the position/order, but the issue is with the closing function.
I will get this error
> UnboundLocalError: local variable 'result' referenced before assignment.
Even if I set `result` as global, it will do nothing.
Any help would be welcomed!
Although I dont code python, you are using a variable without it being assigned a value before.
Your code says:
position_id=result.order
in the beginning of the function. But what is supposed to be in the variable result.order ?
Maybe I am wrong here, but it seems to me, this value is missing at that point of time?
It could be, your ticket number is placed in result.deal instead of result.order.
Although I dont code python, you are using a variable without it being assigned a value before.
Your code says:
in the beginning of the function. But what is supposed to be in the variable result.order ?
Maybe I am wrong here, but it seems to me, this value is missing at that point of time?
It could be, your ticket number is placed in result.deal instead of result.order.
Well...that's my problem and I don't understand how to fix it

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to create a function to open an order and one to close the pending order or the position.
No problem with opening the position/order, but the issue is with the closing function.
I will get this error
> UnboundLocalError: local variable 'result' referenced before assignment.
Even if I set `result` as global, it will do nothing.
Any help would be welcomed!