NexusFi: Find Your Edge


Home Menu

 





Sample Advanced Automated Strategy v1.0


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one dsraider with 36 posts (41 thanks)
    2. looks_two wgreenie with 21 posts (1 thanks)
    3. looks_3 gg80108 with 11 posts (6 thanks)
    4. looks_4 Ducman with 7 posts (0 thanks)
      Best Posters
    1. looks_one MXASJ with 3 thanks per post
    2. looks_two dsraider with 1.1 thanks per post
    3. looks_3 gg80108 with 0.5 thanks per post
    4. looks_4 eman with 0.4 thanks per post
    1. trending_up 49,862 views
    2. thumb_up 64 thanks given
    3. group 27 followers
    1. forum 117 posts
    2. attach_file 15 attachments




 
Search this Thread

Sample Advanced Automated Strategy v1.0

  #41 (permalink)
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87

Good luck and goodnight,

Dave

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
What broker to use for trading palladium futures
Commodities
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
 
  #42 (permalink)
 wgreenie 
Cambridge, Ontario
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Zen-Fire
Trading: 6E
Posts: 1,778 since Dec 2009
Thanks Given: 1,258
Thanks Received: 1,203

Hi Dave

With your best wishes, my 3 computers (I borrowed one from my hubby) have been working very diligently this morning.

1. One is running 4 strategies (3 YM and 1 ES) with trail.

i. ES is the only one that seems normal and no looping trades. It did 2 trades and both marginally profitable. It does have CalculateOnBarClose @false.

ii. 2 YM ones @false and one @true. All chopped a nice short ride into numerous trades. The 2 @false ones chopped it into 8 while the @true one made it into 4.

Well, I have no clue what's going on. Oh, even one of the 3 YM charts looked different from the other two. I may have overloaded my computer LOL!

2. One was running 2 strategies on ES and YM until 12:00 noon before Ninja got frozen and I had to close it .. sigh ..

3. With one I was doing Market Replay on the strategies with trail on early March data. Looping trades again and the worst one so far chopped a nice trade into 20 trades - gosh!

I will need to research more on how to have a trail code that will not cause choppy trades. Plus I will review my strategies again to locate any coding issues that may have caused it and not the trail code.

Dave, I am very grateful for your assistance. Will knock at your door when I need your advice. Thank you!!!!!

Beth

Visit my NexusFi Trade Journal Reply With Quote
  #43 (permalink)
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87


Geeze...

Just so I know, this is WITH FirstTickOrBar and [1] in the exits as well as the entries?

Reply With Quote
  #44 (permalink)
 wgreenie 
Cambridge, Ontario
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Zen-Fire
Trading: 6E
Posts: 1,778 since Dec 2009
Thanks Given: 1,258
Thanks Received: 1,203

Yes Dave. Newbie me followed your kind suggestion to the dot!

Visit my NexusFi Trade Journal Reply With Quote
  #45 (permalink)
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87

Hmm...then I'm afraid I'm out of ideas. There's obviously a conflict in the code but I'm truly no expert. With any luck, someone will download yours, as it's very good, and find it. So, I'll keep my fingers crossed for you.

D

Reply With Quote
  #46 (permalink)
 wgreenie 
Cambridge, Ontario
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Zen-Fire
Trading: 6E
Posts: 1,778 since Dec 2009
Thanks Given: 1,258
Thanks Received: 1,203

.. knock .. knock .. Dave, need to pick your brains please (for my learning purpose).

For ES, I have the following:

 
Code
privateint breakEvenTicks = 4;
privateint plusBreakEven = 0;
privateint trailProfitTrigger = 4;
privateint trailStepTicks = 1;
 
privatedouble initialBreakEven = 0;
privatedouble previousPrice = 0;
privatedouble newPrice = 0; 

privateint stoplossticks = 10;
 
case MarketPosition.Long:
// Once the price is greater than entry price+ breakEvenTicks ticks, set stop loss to breakeven
if (Close[0] == Position.AvgPrice + breakEvenTicks * TickSize && previousPrice == 0)
{
initialBreakEven = Position.AvgPrice + plusBreakEven * TickSize;
debug ("Moving stop up to "+Position.AvgPrice);
SetStopLoss(longEntryID, CalculationMode.Price, initialBreakEven, false);
previousPrice = Position.AvgPrice;
PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\AutoTrail.wav");
PrintWithTimeStamp("previousPrice = "+previousPrice);
PrintWithTimeStamp("newPrice = "+previousPrice);
}
// Once at breakeven wait till trailProfitTrigger is reached before advancing stoploss by trailStepTicks size step
elseif (previousPrice != 0////StopLoss is at breakeven
&& Close[0] > previousPrice + trailProfitTrigger * TickSize)
 
{
newPrice = previousPrice + trailStepTicks * TickSize;
SetStopLoss(longEntryID, CalculationMode.Price, newPrice, false);
previousPrice = newPrice;
//print the previous price before it's changed
PrintWithTimeStamp("previousPrice = "+previousPrice);
PrintWithTimeStamp("newPrice = "+previousPrice);
PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\AutoTrail.wav");
}
break;
For the enclosed chart, there's a long @1039. It went up to 1041 yet the trade was closed @1039.25 (a SL order). My understanding on the above code is SL to BE after a 4-tick move. Then SL will be adjusted 1 tick continuously as the trade is working before getting stopped out.


Instead, the trade was closed early (in my mind) and the system re-entered again at 1041!? If the trail code was working, shouldn't the trade be closed around 1040 and there would not be a re-entry?

Please help fixing my understanding! Thank you.

Beth

Attached Thumbnails
Click image for larger version

Name:	ES 06-10  3_11_2010 (MedianRenko 4 Ticks).jpg
Views:	300
Size:	162.0 KB
ID:	9577  
Visit my NexusFi Trade Journal Reply With Quote
  #47 (permalink)
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87

Your understanding is right on. That's exactly what it should have done. Did you have more than one position open at the time? Also, the reentry shouldn't have anything to do with the trail, but with your entry. Did you add FirstTickOfBar and set everything back a bar on this one too? I couldn't tell if you added this strat to each instrument or created different ones for each.

Reply With Quote
  #48 (permalink)
 wgreenie 
Cambridge, Ontario
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Zen-Fire
Trading: 6E
Posts: 1,778 since Dec 2009
Thanks Given: 1,258
Thanks Received: 1,203

Great to learn that my understanding is right on even it's not doing what it's supposed to do.

Yes, the strategy has FirstTickOfBar and I've set everything back a bar on both entry and exit conditions. My strategy only allows one trade (one open position) at a time and no multiple-trades.

I checked the long trade in question and its closing was not triggered by one or both of the exit conditions. Sooo, it's another mystery ooo .. I may soon be a collector of mysteries .. haha ..

Thanks again Dave!

Beth

Visit my NexusFi Trade Journal Reply With Quote
  #49 (permalink)
stockdisk
toronto,ontario
 
Posts: 15 since Nov 2009
Thanks Given: 6
Thanks Received: 33

hi , i downloaded the strategy and inported the file with success, i am connected and charttrader is disabled but still my strategy icon is diabled same thing when i click right on chart ,strategy is greyed out .am i doing something wrong. thanks for the help

thaks

Reply With Quote
  #50 (permalink)
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87


stockdisk,

Are you using the free version of NT? If so, it doesn't allow for strategies.

Reply With Quote




Last Updated on November 16, 2011


© 2024 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 - Privacy Policy - Downloads - Top
no new posts