OrderContext // Getting Account Balances

Joined
Dec 6, 2024
Posts
20
Likes
7
1748944642622.png
I was looking to create an indicator to help track how far you are from daily loss limit / target that can both be manually input along with maybe adding more stuff. The issue is with a study (not a strategy) I don't think I have access to Order Context and presumably the account balance also since that's the only way I can see to access it. I have Orderflow version... Does anyone know if there's a way to get the account balance without using a strategy since I'm on a lower version
 
Hi, you can get access to the cashBalance but not the balance as far as I can see. Its a real pain. i have the Ultimate Edition and it makes it very difficult to get a an accurate drawdown. To the point where I have asked MotiveWave Support to include it in v7. For thta reason and others, I along with a colleague of mine) have come up with a solution that exposes various metrics including live drawdown via API. We'll be going into public testing shortly so ping me a DM if you want to be a tester.

Cheers
S
 
Under OrderContext ctx, the account balance should be:

double accBalance = ctx.getCashBalance() + ctx.getAccountUnrealizedPnL();
 
Hi, @AnthonyK that's not the current balance. That's th ecurrent balance for the strategy in question. Its a small distinction but certainly relevant for my requirements. I need to know how much drawdown is really availabel in an account. Not how much was available just for that startegy as I often have multiple strategies working inthe same account. Its also an issue when there are crashes or resets or force quits.
Cheers
 
Hi, @pandalover ,

Looking at each of the components, I fail to see that it refers to the strategy balance but rather the account balance.

double getCashBalance() - Gets the current cash balance for the account.
(For completeness, what would the cash balance for a strategy comprise of?)

float getAccountUnrealizedPnL() - Gets the average entry price for the current position on the selected account.
This seems to be a typo / carry over of the information at the getAccountAvgEntryPrice.

double getUnrealizedPnL() - Gets the PnL for the open position. This value will change with every tick.

The wrong information above notwithstanding, the presence of both getAccountUnrealizedPnL() and getUnrealizedPnL() suggests the two provide different functions.

I've got acceptable results from the above, but if it is not giving you want you want from your testing then it is wrong for your use case.
 
Hi @AnthonyK it's been a while since I looked into this but I'll do some checks and get back to you when I have a moment. The issue I had is that I can derive the 2 balances during a single strategy session but not if the cashbalance and accoutnbalance have changed since the beginning of the day. I have been in contact with MotiveWave support about this and they confirmed the behaviour, and I requested an updat ein MotiveWave 7 though I have no visibility if there will be a change.

I'll get back here with more details when I have time during the week. It's enough of a problem for me that I am logging in with Rithmic as well to have live accurate figures across multiple concurrently runnign strategies which are able to restart and reconnect if MotiveWave fails in some way (crash, force quit etc).

Cheers
S
 
Top