Hi, I finally got my algo complete enough to compile. Could someone please view the coding logic and let me know why it just backtests endlessly. The backtest never stops. Thanks!
QUANTCONNECT COMMUNITY
Hi, I finally got my algo complete enough to compile. Could someone please view the coding logic and let me know why it just backtests endlessly. The backtest never stops. Thanks!
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.
John Nellman
Sorry it was this one that I backtested, the first backtest was incomplete on the coding. Thanks for looking.
-John
Jing Wu
Hi John_nellman,
By looking at your algorithm, I found two errors. First, you should create the indicator in Initialize(). Second, you set the warm-up period in Initialize() method, you need to wait until the algorithm finished warming up before you can place orders. The problem can be solved by adding a check
if (IsWarmingUp) return;
John Nellman
Hi Jing,
Thanks so much for taking to the time to read my code. It really helps as I am learning. I have gotten the file to backtest based on your recommendations but now I question if my scheduled events are coded correctly. Could you or someone please look at the coding from the attached backtest and let me know why it only Purchases EURUSD but never Sells it and the scheduled events I coded to liquidate my orders after 10 days in the market don't seem to be working. Thanks so much!!
-John
Jing Wu
ScheduleEvent function should be put into Initialize() method.
John Nellman
So this likely is not a good way to cancel trades after 10 days b/c I need the clock to start at 10 days after a trade is placed not 10 days after I start the algo? Thanks.
Jing Wu
Yes exactly. You should specify the date and time rules when you are using the schedule event function in Initialize(). It can not take the input variables in OnData().
John Nellman
Sorry another question. Can you point me towards how I Get exact time trade was placed? I would like to set that to a variable called tradeTime. Then if I can run Time rulesin OnData() I would like to use an equation like totalTime = tradeTime + Time.AddDays(10); Then I will say if(totalTime > 10) then Liquidate(). Am I on the right track? Thanks!
Jing Wu
You could take a look at this order ticket algorithm. If the Ticket status is filled, then you can get tradeTime = Time
John Nellman
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!