Click here to Login





                                                   MM Error report

  0

0
allan nathan
2013-03-18 18:14:49


Hi,
I am running a money management script posted by another user.I keep on getting an error message..

OnEndPeriod : Compilation error in 'OnEndPeriod':
Unable to cast object of type 'System.Double' to type 'System.String'.

OnEndPeriod : Compilation error in 'OnEndPeriod':
Unable to cast object of type 'System.Double' to type 'System.String'.

The user has checked the code and it works fine for him.No issues.Why would I be getting that error message and what does it mean?

Allam



clonex
2013-03-18 18:52:10

  0

Best Answer
I sent you an email with fixed code:

double vixPeriod = (double)Variables.GetVariable("MA Period");
double newPercent = (double)Variables.GetVariable("New Percent to Invest");
double perInvested = (double)Variables.GetVariable("per_invested");
string inst = (string)Variables.GetVariable("Instrument");
string mav = (string)Variables.GetVariable("Type MA");


TimeSeries ts = Data.ParseFormula("a = close < ma(close, " + Math.Round(vixPeriod, 0) + ","+mav+");").GetTimeSeries(""+inst+"", "a");
//TimeSeries ts = Data.ParseFormula("a = close < sma(close, " + Math.Round(vixPeriod, 0) + ");").GetTimeSeries(""+(string)inst+"", "a");

Divers.Output("inst"+inst);
Divers.Output("ma:"+mav);


if(ts[0] == 1)
{

if(perInvested != newPercent)
{
Portfolio.UpdateCategorySettings("long", (double)newPercent, TradingSystemSettings.NbPositions, Orders.CloseMarketOrder());
Portfolio.UpdateCategorySettings("short", (double)newPercent, TradingSystemSettings.NbPositions, Orders.CloseMarketOrder());



}
}
else
{

{

Portfolio.UpdateCategorySettings("long", 100, TradingSystemSettings.NbPositions, Orders.CloseMarketOrder());
Portfolio.UpdateCategorySettings("short", 100, TradingSystemSettings.NbPositions, Orders.CloseMarketOrder());

}
}


Clonex



clonex
2013-03-18 19:05:48

  0

Or you can download updated script.

Clonex



umair
2013-03-18 19:51:24

  0

hey Clonex, can you so kindly make a MM script for a intraday strategies where the strategies buys X amount of positions and ends all position if the net P&L on all positions is X

for example a traders daily goal is: 200$, when the net P&L (combined pnl on all 10 positions) is $200, the system exits all positions
or if the net loss on all position is 200$, the system exits all positions.

That would be much appreciated!



allan nathan
2013-03-18 20:48:03

  1

Thank you Clonex.Thank you so much.I downloaded it and it appears to work as hoped.Excellent!!

Allan



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Standard Error Bands
Commitments of Traders Report for Financial Futures
Standard Error of the Estimate of a Regression Line
Earnings Whispers: Whisper Report
Economic Data - Retail Trade Report

How-to Lessons
How to add a metric in the trading system simulation report
How to automate the data downloading process
How to calculate the average of a time series using the money man...
How to add custom position-based metrics to your trading system
How to use a custom drawing tool

Related Forum Threads
Error during report creation
Error Graph should automatically scale
Error in formula
Error in formula
Resizing Trading simulation report

Blog Posts
Create a HTML or PDF Report of your Trading System Backtesting Re...
Trading Forex with the commitments of traders report
Trading System Analysis: Backtesting report and custom measures
Quantitative Analysis: Price Channels
How to use QuantShare screener to trade penny stocks









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.