How can I get the highest/lowest price of the past 10 hours of a forex security, say EURUSD?
I am trying to do this in C# but so far, no luck.
I tried to use Relative Strenght Index, but it does not work and I can't get any value from it when I tried to debug it to the console, it keeps coming up as zero.
public override void Initialize()
{
//var _rsi = new RelativeStrengthIndex(10,MovingAverageType.Exponential);
SetStartDate(_year, 1, 1);
SetEndDate(_year, 12, 30);
SetCash(_cashValue);
AddForex(_symbol, Resolution.Minute);
// initiating EMA
_rsi = RSI(_symbol,10,MovingAverageType.Simple,Resolution.Daily);
:
Then, if I try to Debug it in OnData() function, such as:
Debug("OpenPrice: "+_rsi+" CurrentPrice: "+Math.Round(_currentPrice,5)+" "+Time);
it does not show anything for OpenPrice... it only shows zero as the value.
Vladimir
Eddie De Meira ,
> How can I get the highest/lowest price of the past 10 hours
You may use Donchian Channel indicator, Resolution.Hour, PERIOD = 10 for that..
HH = UpperBand, LL = LowerBand
Here is Python version.
Eddie De Meira
Hi Vladimir,
Thanks a lot for your reply :)
In C# (so far what I've found...) there is a similar function: MAX(symbol, period, resolution) which returns a decimal value. I've been trying to use this, but for some reason, if I set the resolution to Hourly, it does not return anything.
I am suspicious that this function only works for Equities and it does not work for forex. I don't know...
So, rather than use this function, what I've done is taking the close price of the last day and just 5 minutes before the time I want to trade I compare it to the current price by taking an average of the difference and then using this value as a reference to what I want: if greater do this, if smaller do that...
Seems to be working...
Shile Wen
Hi Eddie,
I am thinking that you might not be warming up the indicator. I suggest calling SetWarmUp to warm up the indicators before use. If this doesn't address the problem, please attach a simplified backtest that demonstrates the issue.
Best,
Shile Wen
Eddie De Meira
Shile Wen , you are right, I am not warming it up.
I will setup the SetWarmUp function and test it to see if it works, than I will get back to you here :)
Thanks a lot
Derek Melchin
Hi Eddie,
See the attached backtest for an example of using the MAX method on a forex security with an hourly resolution.
Best,
Derek Melchin
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.
Eddie De Meira
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!