|
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
|
|