Hello!
Got another question here. I was wondering how to use the MAX method to record the highest price of a symbol. Currently, my resolution is in seconds and using data[symbol].High
only records the highest price for the last tick bar. Instinctually I want to implement something like this if (symPrice is greater than lastSymPrice)
{
symPrice = data[symbol].Price;
}
Though that doesn't logically work. I was also trying to implement a rolling window to look back at the previous bars but kept getting errors. Take a look at my code and you'll see that I've implemented a TradeBar consolidator to consolidate my second resolution into a minute resolution. It functions correctly but I still end up losing money because I have to wait a minute for the price to update.
In short. What I'm trying to do is set a trigger after reaching 3% profits and then set a stop that's 10% under that 3%.
EX: 400 shares of stock ABC at price 2.5 = $1000
3% of 1000 is 30 and 10% of 30 is 3.
30-3 = 27
27 = new stop
If the profits rise to 35 then the new stop becomes 31.5
if current profits go below 27 then you sell.
Michael Handschuh
Hey Travis, would it be easier to place a LimitOrder at your 3% target and a StopLimitOrder at your stop price right when you open your position? This will probably be easier than trying to track it and then issuing market orders. If you require the max (or min) price over a certain time frame, you could also use the Maximum indicator.
Travis Teichelmann
Hey Micheal, Sorry about the late response but I was working on wrapping my brain around how to implement stop and limit orders. I realized that although it was a good suggestion, it's imperative to be able to store the maximum value and keep track of it over time. I tried to create a new Maximum indicator with
var maxind = new MAX(symbol, 10, resolution, selector);
but I couldn't get anything to work. Eventually, I turned my consolidator resolution to seconds then set the period lookback to 2 seconds. Now it successfully stores the highest price. *sigh of relief*Travis Teichelmann
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!