Back

Issue with PSAR Indicator

I was unnable to to add values to PSAR() on C# such as "0.02, 0.02, 0.2, Resolution.Hour".  The error says its unable to convert to decimal.

using System;
using System.Linq;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;

namespace QuantConnect.Algorithm.CSharp
{
public class TransdimensionalCalibratedCoil : QCAlgorithm

{

private string _symbol1 = "EURUSD";
private DateTime _previous1;
private ParabolicStopAndReverse _psar1;
private ExponentialMovingAverage _ema1;



public override void Initialize()
{
SetStartDate(2018, 01, 01); //Set Start Date
SetEndDate(2019, 01, 01);
SetCash(100000); //Set Strategy Cash


AddSecurity(SecurityType.Forex, _symbol1, Resolution.Hour);


_psar1 = PSAR(_symbol1, 0.02, 0.02, 0.2, Resolution.Hour);
_ema1 = EMA(_symbol1, 1, Resolution.Hour);

 

Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi,

PSAR takes in decimals as parameters. In C#, we differentiate doubles and decimals by adding an m to the end.

_psar1 = PSAR(_symbol1, 0.02m, 0.02m, 0.2m, Resolution.Hour);

 

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed