Welcome to NexusFi: the best trading community on the planet, with over 200,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I've coded a Kelly money management signal for Multicharts off of the risk capital set and I've been getting the error: [EXCEPTION} Floating-point invalid operation.
I've searched for the solution, and found that others have gotten around the problem by removing the scenario where their equation divides by zero.
I've tried to identify where there is a zero that I'm dividing by, and attempted to add exceptions however the error persists.
I havn't put any code in my signal code to associate to the money management code.
Any advice is appreciated.
//#Number of Units = Account Total * Risk Capital * ( Kelly Ratio % - Win % Change Buffer )
//Kelly Ratio = % of trades that win - (1 - % of trades that win) / ($ Winnings per trade / Expected Loss per trade)
//Entries
If Entryprice > 0
Then pmms_strategy_set_entry_contracts(0,((Equity * Kelly)/Entryprice));
//Exceptions
IF GL=0 then raiseruntimeerror("!!!alarm GL=0");
IF GP=0 then raiseruntimeerror("!!!alarm GP=0");
IF NWT=0 then raiseruntimeerror("!!!alarm NWT=0");
IF TT=0 then raiseruntimeerror("!!!alarm TT=0");
IF Tradevolume=0 then raiseruntimeerror("!!!alarm Tradevolume=0");
IF Equity=0 then raiseruntimeerror("!!!alarm Equity=0");
IF ProfitFactor=0 then raiseruntimeerror("!!!alarm ProfitFactor=0");
IF WTP=0 then raiseruntimeerror("!!!alarm WTP=0");
IF KellyCriterion=0 then raiseruntimeerror("!!!alarm KellyCriterion=0");
IF Kelly=0 then raiseruntimeerror("!!!alarm Kelly=0");
If Entryprice = 0 then raiseruntimeerror("!!!alarm Entryprice=0");
Can you help answer these questions from other members on NexusFi?
it's a good practice to add checks for every division done within your code. The code snippet below contains several divisions without "protective" checks and these might cause the error.
Without any trades any reserved word returning the number of trades (or winning/losing trades) will return zero for example.
I'm new to Easylanguage but I notice that you're checking for 0 values after you do the divisions therefore the exception gets thrown and execution halts before you check for 0 values.. You might find the offending 0 value if you move the divisions below after checking for 0 values.
Typically you would check for zero in an if statement before conducting the division.