Risk Limit study?

mikrom

Member
Joined
Dec 14, 2022
Posts
16
Likes
9
Wild idea, but would it be possible using the current SDK to code a "Risk Limit" study that prevents you from opening a position with more than X contracts (until you disable or uninstall the study)?

When using keybindings while scalping it's easy to make mistakes, so I think this would be very useful.

Of course it would be even better if MotiveWave added native support for this type of setting. I believe it was suggested somewhere but has not been implemented yet.
 

Spin

Well-known member
Joined
May 22, 2019
Posts
480
Likes
192
Hmmm, I thought the answer to this would be a simple 'yes!', until I started digging a little deeper. So it's a good question, @mikrom :LOL:

The SDK allows us to get the current Account Position, so we could programmatically check if the next trade would tilt us over that limit or not. BUT: we can only check the size of a trade that is being fired from within a Strategy.
Using a hotkey would circumvent this check: the trade would still be opened. You could obviously have a textlabel appear somewhere on the chart yelling "SIZE SURPASSED" a tick later, but the damage would be done by then.

A workaround could be to write a Strategy that creates 'buy' & 'sell' buttons (with menu-preset lotsizes), and require the user to use those. That way, the Strategy can perform the check BEFORE the order is sent to the Thief (ahum, 'broker') and a textlabel could be displayed in case of size surpassed, NO damage being done yet.

Curious to see whether anyone has another opinion or suggestion ? :giggle:


EDIT: this kept spinning in my head and now I'm wondering whether it would be possible to programmatically halt all trades being sent to the broker (called 'Orders' in SDK-speak) for a few seconds to perform that size-surpass-check first. That would mean having a function check on every tick whether new orders are lined up to be sent (hoping hotkey-orders are included there), holding them back and performing the check. I would need to test to see if MW allows this. Still a great questoin !
 
Last edited:

mikrom

Member
Joined
Dec 14, 2022
Posts
16
Likes
9
Interesting stuff @Spin.

I was thinking about the possibility of a strategy for this as well but have no experience coding strategies in MW so I wasn't sure. Also, I have the orderflow edition so I would need to upgrade just for that. The custom buy & sell buttons from a strategy would be a downgrade in some way because I probably can't use hotkeys for those. Hmm..

Your last edit sounds like something that could possibly work with hotkey orders, if it's even possible to "catch" orders like that. If you figure it out, let me know, I wouldn't mind paying for a study or strategy like this :giggle:
 
Top