floating point invalid operation. skilled programmer help.

Questions about MultiCharts and user contributed studies.
zumthor
Posts: 23
Joined: 17 Mar 2011
Has thanked: 1 time

floating point invalid operation. skilled programmer help.

Postby zumthor » 25 Mar 2011

i keep getting this floating point invalid operation message when i try to backtest and im pretty sure its coming from my money management block of code which ive included below. i think its pretty clear what im trying to do there. could one of the programming whizzes out there please point out the error and suggest a more elegant way of doing it.....also why on earth isnt there a built in function like 'equity' in multicharts? thats a really basic thing that you would think would be in there.

Code: Select all

[inputs: InitialCapital(10000),stoploss(0.005),risk(0.01),pip(0.0003);

variables: equity(0),tradesize(0);

equity= InitialCapital + I_ClosedEquity + I_OpenEquity;

if equity<>0 then
tradesize=(equity*risk)/stoploss
else if equity=0 then tradesize=0;

if condition1 and condition3 then sellshort tradesize contracts next bar at (close+pip) limit]

zumthor
Posts: 23
Joined: 17 Mar 2011
Has thanked: 1 time

Re: floating point invalid operation. skilled programmer hel

Postby zumthor » 26 Mar 2011

Newby error. How do I create a variable for my rolling equity balance then?

User avatar
TJ
Posts: 6572
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1902 times

Re: floating point invalid operation. skilled programmer hel

Postby TJ » 28 Mar 2011

zumthor wrote:Newby error. How do I create a variable for my rolling equity balance then?

Have you tried PositionProfit, GrossProfit or NetProfit?
You might have to add an accumulator to get the number you want.

for more strategy keywords:

press [F1]

Image
Attachments
keywords.jpg
keywords.jpg (46.76 KiB) Viewed 295 times

zumthor
Posts: 23
Joined: 17 Mar 2011
Has thanked: 1 time

Re: floating point invalid operation. skilled programmer hel

Postby zumthor » 28 Mar 2011

yeah thanks, i got some joy with NetProfit.

imoneyfish
Posts: 37
Joined: 26 Oct 2011
Has thanked: 6 times
Been thanked: 2 times

Re: floating point invalid operation. skilled programmer hel

Postby imoneyfish » 31 Oct 2011

zumthor wrote:yeah thanks, i got some joy with NetProfit.



Could you share your code here or email me your money management code here, it could be just a sample one but it would really help me to get started. I am stuck on this for a very long time, no clue. Many thanks.


Return to “MultiCharts”