|March 31st, 2011, 06:16 PM||#1 (permalink)|
Futures Experience: Intermediate
Favorite Futures: CL,ZB,TF
Posts: 17 since Sep 2009
Thanks: 45 given, 27 received
Could someone please copy and paste the code from SampleAdvancedAutomatedStrat to my ThreeBarsLONG strategy? I have tried and tried but I can't get it to ever compile. I know the ThreeBarsLONG strategy is simple and probably not really good (more for example than anything) but I am trying to learn a little and if I could see where the code should be placed and the right way to do it I think I would understand what I'm doing wrong. I will attach both strategies below plus paste the code I'm trying to use. If anyone wants to take the time to look at it for me......THANK YOU!
protected override void OnBarUpdate()
// After our strategy has a PnL greater than $1000 or less than -$400 we will stop our strategy
if (Performance.AllTrades.TradesPerformance.Currency.CumProfit > 1000
|| Performance.AllTrades.TradesPerformance.Currency.CumProfit < -400)
/* A custom method designed to close all open positions and cancel all working orders will be called.
This will ensure we do not have an unmanaged position left after we halt our strategy. */
// Halt further processing of our strategy
// Checks to see if the day of the week is Saturday or Sunday. Only allows trading if the day of the week is not Saturday or Sunday.
if (Time.DayOfWeek != DayOfWeek.Saturday && Time.DayOfWeek != DayOfWeek.Sunday)
/* Checks to see if the time is during the following hours (format is HHMMSS or HMMSS).
The timezone used here is (GMT-05:00) EST. */
if ((ToTime(Time) >= 101500 && ToTime(Time) <= 151500)) //|| (ToTime(Time) >= 140000 && ToTime(Time) < 154500))
if (Historical) return;