NexusFi: Find Your Edge


Home Menu

 





Same Strategy, Same Market, Same Time = Different trades!


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one MXASJ with 13 posts (0 thanks)
    2. looks_two RJay with 4 posts (1 thanks)
    3. looks_3 mrticks with 2 posts (0 thanks)
    4. looks_4 max-td with 2 posts (1 thanks)
    1. trending_up 11,308 views
    2. thumb_up 2 thanks given
    3. group 0 followers
    1. forum 22 posts
    2. attach_file 2 attachments




 
Search this Thread

Same Strategy, Same Market, Same Time = Different trades!

  #11 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

I looked at the original "exampleATMstrategy" and think I found the problem. Recoded, compiled, and running against a market replay file now.

The strats were running on different but identical charts, RJay.

I'll tell ya... losing real money is a great motivator for learning more about Ninjascript.

I'll tackle the ADXVMA max pointed out next...

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Exit Strategy
NinjaTrader
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
35 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
19 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Spoo-nalysis ES e-mini futures S&P 500
14 thanks
  #12 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: RTY
Posts: 683 since Jun 2009
Thanks Given: 758
Thanks Received: 787


MXASJ View Post
I looked at the original "exampleATMstrategy" and think I found the problem. Recoded, compiled, and running against a market replay file now.

The strats were running on different but identical charts, RJay.

I'll tell ya... losing real money is a great motivator for learning more about Ninjascript.

I'll tackle the ADXVMA max pointed out next...

The reason I asked this about multiple charts, is be sure that all charts have the exact same historical start point.

If they start at different times, I find charts don't match up.

RJay

Reply With Quote
  #13 (permalink)
 
Saroj's Avatar
 Saroj 
Arcata, CA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: index futures, oil
Posts: 485 since Jun 2009
Thanks Given: 232
Thanks Received: 415



RJay View Post
The reason I asked this about multiple charts, is be sure that all charts have the exact same historical start point.

If they start at different times, I find charts don't match up.

RJay

RJay, is that by specifying the same number of bars or the same number of days or either? (in the Format Data Series Dialogue Box) or am I totally on the wrong track?

Reply With Quote
  #14 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

Well its not quite there yet. Attached two photos... one of the strat executing the ATM and one of the strat executing draw arrow. There are four instances where the strat with the ATM "missed" buy signals and one instance where it did a "buy" when it should not have.

When those two strats run live against incoming data, the indicators look exactly the same.

Attached Thumbnails
Click image for larger version

Name:	ES 09-09  7_17_2009 (5 Min) AROOWS.jpg
Views:	234
Size:	145.0 KB
ID:	801   Click image for larger version

Name:	ES 09-09  7_17_2009 (5 Min) STRAT.jpg
Views:	214
Size:	98.0 KB
ID:	802  
Started this thread Reply With Quote
  #15 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

In a way it was good to be out of some of that chop... I just need to figure out why the code does not work the same between both strats.

Go Long ATM:
// ATM Strategy code cut-and-paste from NT
// Make sure this strategy does not execute against historical data
if (Historical)
return;
 
// Submits an entry limit order at the current low price to initiate an ATM Strategy if both order id and strategy id are in a reset state
// **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'ES 2 w BE and Trail' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK ****
// in the line below I've deleted && Close[0] > Open[0] from the default sampleATMstrategy code
if (orderId.Length == 0 && atmStrategyId.Length == 0 )
{
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Action.Buy, OrderType.Market,
0, 0, TimeInForce.Day, orderId, "ES 2 w BE and Trail", atmStrategyId);

}
 
// Check for a pending entry order
if (orderId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderId);

// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
if (status.GetLength(0) > 0)
{
// Print out some information about the order to the output window
Print("The entry order average fill price is: " + status[0]);
Print(
"The entry order filled amount is: " + status[1]);
Print(
"The entry order order state is: " + status[2]);
// If the order state is terminal, reset the order id value
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
orderId =
string.Empty;
}
}
// If the strategy has terminated reset the strategy id
elseif (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
atmStrategyId =
string.Empty;
 
if (atmStrategyId.Length > 0)
{
// You can change the stop price
if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
AtmStrategyChangeStopTarget(
0, Low[0] - 3 * TickSize, "STOP1", atmStrategyId);
// Print some information about the strategy to the output window
Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
Print(
"The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
Print(
"The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId));
Print(
"The current ATM Strategy Unrealized PnL is: " + GetAtm

Started this thread Reply With Quote
  #16 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

Go long arrow:

DrawArrowUp("My up arrow" + CurrentBar, true, 0, High[0]+TickSize, Color.Green);
// delete to enable PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\LongES.wav");
// delete to enable Log("ES Sound Only LONG signal", LogLevel.Information);


Started this thread Reply With Quote
  #17 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

Mission today for me:

1. Compare each strat's code once again, line by line.
2. Run both on the same chart using Market Replay 1x speed.
3. Work on hard coding an "ATM like" exit strategy as Mike suggested weeks ago . I've started that already on a strat I use on FESX, but struggling with how to "tighten" stops after trailing for a while.

It's 9am where I live, which gives me 5 hours until FESX opens. Let the Games begin!

Started this thread Reply With Quote
  #18 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: RTY
Posts: 683 since Jun 2009
Thanks Given: 758
Thanks Received: 787


Saroj View Post
RJay, is that by specifying the same number of bars or the same number of days or either? (in the Format Data Series Dialogue Box) or am I totally on the wrong track?

Saroj,

As a test, open charts with market data disconnected. Open and set up charts with same start date or bar #.

let charts load from resident historic data.

now connect market data source. after load is complete, run comparison testing.

RJay

Reply With Quote
Thanked by:
  #19 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800


MXASJ View Post
Mission today for me:

1. Compare each strat's code once again, line by line.
2. Run both on the same chart using Market Replay 1x speed.
3. Work on hard coding an "ATM like" exit strategy as Mike suggested weeks ago . I've started that already on a strat I use on FESX, but struggling with how to "tighten" stops after trailing for a while.

It's 9am where I live, which gives me 5 hours until FESX opens. Let the Games begin!

Just to update this thread. My problem was solved with Action #1 above. A single typo in my strat code had it trading against an indicator parameter that was different than the plotted parameter.

I've found the bug, and it was me.

On the ATM-like hard code, I'm still playing around with it. To be honest the only reason for it seems to be the issue of backtesting using data from different time frames. Important, but I need to prioritize what I need to do in NT.

Started this thread Reply With Quote
  #20 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: RTY
Posts: 683 since Jun 2009
Thanks Given: 758
Thanks Received: 787



MXASJ View Post
Just to update this thread. My problem was solved with Action #1 above. A single typo in my strat code had it trading against an indicator parameter that was different than the plotted parameter.

I've found the bug, and it was me.

On the ATM-like hard code, I'm still playing around with it. To be honest the only reason for it seems to be the issue of backtesting using data from different time frames. Important, but I need to prioritize what I need to do in NT.

MXASJ,

Good for you!!!

I think it is very important that everyone learn how to test and tweak your own programs.

Personally, I am glad I took the time to learn how to do this.

I usually tweak nearly every indicator I test or use.

RJay

Reply With Quote




Last Updated on January 29, 2010


© 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