Kelly Money Management Multicharts [EXCEPTION} Floating-point invalid operation. - futures io
futures io futures trading



Kelly Money Management Multicharts [EXCEPTION} Floating-point invalid operation.


Discussion in MultiCharts

Updated by Midline
    1. trending_up 893 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 2 replies
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Kelly Money Management Multicharts [EXCEPTION} Floating-point invalid operation.

(login for full post details)
  #1 (permalink)
Kitchener Ontario Canada
 
 
Posts: 1 since Mar 2020
Thanks: 0 given, 0 received

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)

---------------------------------------------------------------------------------------------------

Vars:
GL( 0 ),
GP( 0 ),
NWT( 0 ),
TT( 0 ),
Tradevolume( 0 ),
Equity( 0 ),
ProfitFactor( 0 ),
WTP( 0 ),
KellyCriterion( 0 ),
Kelly( 0 );

//Equity
Equity = Round ((InitialCapital + NetProfit + OpenPositionProfit),0);


//Kelly Criterion Variables
GL = grossloss/numlostrades;
GP = grossprofit/numwintrades;
NWT = Numwintrades;
TT = Totaltrades;

//Kelly Criterion Calculation
kelly[(NWT/TT) - (1-(NWT/TT)/(GP/GL))];

//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");

Reply With Quote

Can you help answer these questions
from other members on futures io?
ThinkScript help with SchaffTrendCycle
Traders Hideout
US OTCQB STOCK Brooker for UK BASED RESIDENT
Brokers
TOS Script (Code attached): Close inbetween 30 and 50 ma with 30ma<50ma<100ma
ThinkOrSwim
Anyone with Overcharts license/experience?
Platforms and Indicators
Sending an ACH from BoA to GFF Brokers
Brokers
 
 
(login for full post details)
  #2 (permalink)
 Vendor: www.abctradinggroup.com 
Hamburg Germany
 
Experience: Advanced
Platform: Multicharts, Tradestation
Broker: DTN IQ
Trading: ES
 
Posts: 2,208 since Apr 2013
Thanks: 391 given, 1,444 received

BrianMichaelWall,

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.

Regards,

ABCTG


BrianMichaelWall View Post
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)

---------------------------------------------------------------------------------------------------

Vars:
GL( 0 ),
GP( 0 ),
NWT( 0 ),
TT( 0 ),
Tradevolume( 0 ),
Equity( 0 ),
ProfitFactor( 0 ),
WTP( 0 ),
KellyCriterion( 0 ),
Kelly( 0 );

//Equity
Equity = Round ((InitialCapital + NetProfit + OpenPositionProfit),0);


//Kelly Criterion Variables
GL = grossloss/numlostrades;
GP = grossprofit/numwintrades;
NWT = Numwintrades;
TT = Totaltrades;

//Kelly Criterion Calculation
kelly[(NWT/TT) - (1-(NWT/TT)/(GP/GL))];

//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");


Follow me on Twitter Visit my Facebook Reply With Quote
 
(login for full post details)
  #3 (permalink)
Basking Ridge
 
 
Posts: 7 since Mar 2020
Thanks: 2 given, 8 received


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.

Reply With Quote


futures io Trading Community Platforms and Indicators MultiCharts > Kelly Money Management Multicharts [EXCEPTION} Floating-point invalid operation.


March 29, 2020


Upcoming Webinars and Events
 

Technical Analysis Workshop w/NinjaTrader

Oct 27
 

Bookmap

Oct TBD
 

SharkIndicators

Oct TBD
 

Carley Garner

Oct TBD
 

Ironbeam

Oct TBD
 

Zytrade

Oct TBD
 

GruttePier

Oct TBD
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts