NexusFi: Find Your Edge


Home Menu

 





Strategy Help


Discussion in NinjaTrader

Updated
    1. trending_up 1,906 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 2 attachments




 
Search this Thread
  #1 (permalink)
 
sdt929's Avatar
 sdt929 
Dallas, Texas
 
Experience: Intermediate
Platform: NT
Broker: Amp/CQG
Trading: CL,ZB,TF
Posts: 17 since Sep 2009
Thanks Given: 46
Thanks Received: 27

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. */
StopStrategy();

// Halt further processing of our strategy
return;
}
// 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[0].DayOfWeek != DayOfWeek.Saturday && Time[0].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[0]) >= 101500 && ToTime(Time[0]) <= 151500)) //|| (ToTime(Time[0]) >= 140000 && ToTime(Time[0]) < 154500))
{
if (Historical) return;


Attached Files
Elite Membership required to download: SampleAdvancedAutomatedStratv1point1.cs
Elite Membership required to download: ThreeBarsLONG.cs
Follow me on X Started this thread Reply With Quote

 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks




Last Updated on March 31, 2011


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts