It is not clear just from looking at the code what is going on. You would need to do more detailed debugging, regardless of the length of code of the script. That is the only way to have clarity on the logic of the script.
Some things to note are:
- You are submitting exit orders in your custom method with the variable exitContractAmount as the quantity. It is not clear from the logic of the script how that variable is calculated. You should do further debugging related to the logic that goes into calculating this variable for further clarity.
- You are also submitting some exit orders with just a different variable simply called 'quantity' taken from your custom method. You would need to do further debugging to determine what the quantity actually being supplied to the exit order is.
- In OnOrderUpdate, you are also submitting exit orders with the 'quantity' parameter taken from OnOrderUpdate. If you want the exit order to use the actual current quantity of the order, use order.Quantity instead.
You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services.
Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.

Comment