NexusFi: Find Your Edge


Home Menu

 





Managing Trade when Calculate on Close = True


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one jthom with 6 posts (1 thanks)
    2. looks_two dsraider with 6 posts (2 thanks)
    3. looks_3 max-td with 2 posts (0 thanks)
    4. looks_4 aslan with 1 posts (0 thanks)
    1. trending_up 6,752 views
    2. thumb_up 3 thanks given
    3. group 1 followers
    1. forum 15 posts
    2. attach_file 0 attachments




 
Search this Thread

Managing Trade when Calculate on Close = True

  #1 (permalink)
 jthom 
Sydney / Australia
 
Experience: Intermediate
Platform: NT
Broker: AMP
Trading: Oil
Posts: 118 since Jun 2009
Thanks Given: 128
Thanks Received: 105

Ok guys and gals,

Got a problem with my current strategy setup.
I have an indicator that effectively needs to calculate at the end of bar close. Therefore the strategy is set to calculate @ close.
However I have set up a method of when the indicator triggers, an entry order is placed 1 tick - the current bar's close (buy.) A cancel order is set to trigger if the price moves 3 ticks + the current order.
However because the strategy is set to calculate @ close, there has been repeated times where an order has been placed, then the price moving 4 -5 ticks with being filled. (ie the bar has not closed.)

How is it possible to for the order to be calculated tick for tick?
I heard of using OnMarketData but have no idea how to code it?
Any help would be great. Thanks

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
Exit Strategy
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87


Hey jthom,

My only suggestion is to use CalculateOnBarClose = False, which will fix your cancel code and then use "FirstTickOfBar" in your entry code. When doing that, set your signal back one bar. So, instead of:

if (CrossAbove(EMA(20), EMA(50), 0)), use:

if (FirstTickOfBar && CrossAbove(EMA(20), EMA(50), 1))

This allows your signal to reach bar close before entering. There may be a better way out there but I THINK this will do what you want.

Dave

Reply With Quote
Thanked by:
  #4 (permalink)
 jthom 
Sydney / Australia
 
Experience: Intermediate
Platform: NT
Broker: AMP
Trading: Oil
Posts: 118 since Jun 2009
Thanks Given: 128
Thanks Received: 105

Hey bud,

I unfortunately have to use CalculateOnBarClose = True for my indicator.

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

I hear you as I like to let the bar close before entering as well but this can be used as a fix. When you add FirstTickOfBar to your entry code and set your signal back a bar, it basically tells you strat to wait until your entry bar closes (like you want) and then enter at the first tick of the next bar. I then set my entry order to Open[0]. So, for the example I gave you, at the open of the current bar, the strat would check to see if the 20 crossed above the 50 on the close of the last bar. If it did, it would enter. Using this combo prevents the strat from taking trades mid-bar.

Unless I'm missing something (or too hungover to fully understand you), I think this will do it.

Good luck,
Dave

Reply With Quote
  #6 (permalink)
 jthom 
Sydney / Australia
 
Experience: Intermediate
Platform: NT
Broker: AMP
Trading: Oil
Posts: 118 since Jun 2009
Thanks Given: 128
Thanks Received: 105

Ok im getting you. However how do i reference my signal from the previous bar?
I cannot use any price references - ie Close[1]

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

Hmm....every indicator in your code SHOULD require you to decide which bar to choose ([0] being current, [1] being one bar back). Basically, if you see a [0], try changing it to [1]. If your signal isn't secret, I'd be happy to have a look. Otherwise, let's start with that.

Reply With Quote
  #8 (permalink)
 jthom 
Sydney / Australia
 
Experience: Intermediate
Platform: NT
Broker: AMP
Trading: Oil
Posts: 118 since Jun 2009
Thanks Given: 128
Thanks Received: 105

hmm well its a custom indicator off a vendor. I have tried to use [1] but doesnt seem to work. When I set to calc at close to false, it becomes way too CPU intensive.
Is it possible to have 2 strategies running?
ie - One for the indicator, and the other being for order placement and trade management?

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

I don't think that's possible but there are many people much more experienced with programming than I am. Maybe they know better. Is your indicator a free one? If so, I'll download and try and figure out the code. If not, maybe you can post or PM me the part that only includes the numbers? Sometimes, you don't get [0] but can have "(xxx, 0)" instead.

Reply With Quote
  #10 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927


jthom,
what indicator is this - or what kind if you dont wanna show it ?
is it a closed vendors .dll or an open code-indie made for you ?

maybe you can post it in elite if you dont want to make it too public - and we can have a look at ...

max-td
Reply With Quote




Last Updated on March 24, 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