NexusFi: Find Your Edge


Home Menu

 





Gapless indicators


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 12 posts (84 thanks)
    2. looks_two Big Mike with 7 posts (10 thanks)
    3. looks_3 viki with 6 posts (5 thanks)
    4. looks_4 cory with 4 posts (10 thanks)
      Best Posters
    1. looks_one Fat Tails with 7 thanks per post
    2. looks_two Sim22 with 4 thanks per post
    3. looks_3 cory with 2.5 thanks per post
    4. looks_4 Big Mike with 1.4 thanks per post
    1. trending_up 23,091 views
    2. thumb_up 127 thanks given
    3. group 14 followers
    1. forum 42 posts
    2. attach_file 28 attachments




 
Search this Thread

Gapless indicators

  #1 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,399 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,539

I'm putting this in the NT programming section since there are more NT users here

I need some help creating some gapless indicators. Let's just start with a simple request, a gapless EMA. I will convert it to EasyLanguage after.

Let's say my chart is a RTH chart. The opening session gaps down 100 ticks from the prior day close. I would like to have my EMA 20 "close that gap". In other words, the first bar of the new session would take into account the gap (from session to session) and then it would automagically close the gap.

Some suggestions on making this happen? I can measure the gap, but then what action should I be taking? Should I use the length of the MA (ie, 20) and then do what with it? You guys know my math skills are terrible, so I'm just stuck here trying to figure out how to properly handle this.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Futures True Range Report
The Elite Circle
Exit Strategy
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
GFIs1 1 DAX trade per day journal
22 thanks
NexusFi site changelog and issues/problem reporting
22 thanks
The Program
19 thanks
  #3 (permalink)
 
jagui's Avatar
 jagui 
Italy - Roma
 
Experience: Intermediate
Platform: Ninja + proprietary
Broker: IB
Trading: Index futures, Forex, Stocks
Posts: 205 since Jul 2010
Thanks Given: 298
Thanks Received: 313


Don't know if I understand well... for the 20 ema the logic could be:

- if the 20 bars are all in the same session, then calculate ema normally
- if some of this 20 bars are in the previous session, then add (or subtract) the gap to the bars of the previuos session and calculate ema accordingly.

This way you should have an ema that "gaps with the price".

Reply With Quote
  #4 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844

i don't know if it would work, but i would try to create new data series that builds on the first bar and then feed it into any calculation,

if bar = bar1 then nclose[0] = close[0]
if bar > bar1 then nclose[0] = nclose[1] + close[0] - open[0]
EMA = EMA(nclose[0],period)


you know what i mean?

Reply With Quote
  #5 (permalink)
 fluxsmith 
Santa Maria
 
Experience: Advanced
Platform: NinjaTrader, ThinkOrSwim
Broker: Mirus/Zen-Fire
Trading: ES
Posts: 290 since May 2010
Thanks Given: 97
Thanks Received: 322

I'm really not sure I understand the goal, but if I do, then I think it's easy for an EMA. Attached is how I'd approach it.

Attached Thumbnails
Click image for larger version

Name:	jhlEMAGapAdj.png
Views:	567
Size:	83.2 KB
ID:	17808  
Attached Files
Elite Membership required to download: jhlEMAGapAdj.zip
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #6 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,399 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,539


fluxsmith View Post
I'm really not sure I understand the goal, but if I do, then I think it's easy for an EMA. Attached is how I'd approach it.

Thanks, I think you got it right. Sometimes I just can't see simple solutions I will convert to EasyLanguage when I have some time.

Thank you
Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #7 (permalink)
 Michael.H 
CA
 
Experience: Master
Platform: Marketdelta and Ninja
Broker: Velocity
Trading: NQ
Posts: 663 since Apr 2010
Thanks Given: 64
Thanks Received: 529

Is there any way to do that for the Wolume weighted moving average for ninja( not VWAP)?
Thanks

Reply With Quote
  #8 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


Big Mike View Post
I'm putting this in the NT programming section since there are more NT users here

I need some help creating some gapless indicators. Let's just start with a simple request, a gapless EMA. I will convert it to EasyLanguage after.

Let's say my chart is a RTH chart. The opening session gaps down 100 ticks from the prior day close. I would like to have my EMA 20 "close that gap". In other words, the first bar of the new session would take into account the gap (from session to session) and then it would automagically close the gap.

Some suggestions on making this happen? I can measure the gap, but then what action should I be taking? Should I use the length of the MA (ie, 20) and then do what with it? You guys know my math skills are terrible, so I'm just stuck here trying to figure out how to properly handle this.

Mike

I understand that you want to create a moving average that reflects the current session only. So you would want to restart it again and again, when the session starts.

There is a catch: The EMA or SMA formulae may not work, because the logic used only applies to continuous moving averages. I encountered this problem, when coding the anchored VWMA for the current session. I wanted to smooth it with a SMA(3). Could not use the native Ninja SMA for smoothing, because it would look back into the previous session. So only smoothed starting from the third bar of the new session onwards.

If you want to use a session related moving average, the anchored VWAP is quite interesting. You can then use the difference between an EMA(20) and the anchored VWAP as a trend filter.

Reply With Quote
  #9 (permalink)
 viki 
italy
 
Experience: Intermediate
Platform: tradestation
Broker: tradestation
Trading: fesx, es
Posts: 14 since Dec 2009
Thanks Given: 1
Thanks Received: 7


Big Mike View Post
I'm putting this in the NT programming section since there are more NT users here

I need some help creating some gapless indicators. Let's just start with a simple request, a gapless EMA. I will convert it to EasyLanguage after.

Let's say my chart is a RTH chart. The opening session gaps down 100 ticks from the prior day close. I would like to have my EMA 20 "close that gap". In other words, the first bar of the new session would take into account the gap (from session to session) and then it would automagically close the gap.

Some suggestions on making this happen? I can measure the gap, but then what action should I be taking? Should I use the length of the MA (ie, 20) and then do what with it? You guys know my math skills are terrible, so I'm just stuck here trying to figure out how to properly handle this.

Mike

I have used this method that i found at Tradestation forums, the author is John Mc.
The code is free and it is for Tradestation but it should work without problems for MULTICHART
My English is not good so I make the cut and paste of the explanation:

"
thought I’d share a method I use for handling opening gaps that seems to work well for both indicators and strategies.

There are approximately 17 hours between the close of the market one day and the open the next day. Significant trading volume may occur during after-hour trading. The opening gap up or down from the previous day's close is misleading. Trading just prior to the open may be sideways or converging from the opposite direction. Usually traders have to either restart their indicators at day beginning or allow enough bars to pass for their indicators to settle down.

I use a routine I call, "gapless," which avoids these problems by treating separate days in a manner similar to continuous contracts.

Vars:
RelO(0), // Relative Open
RelH(0), // Relative High
RelL(0), // Relative low
RelC(0), // Relative Close
gap(0), // the opening gap (modified by the gap coefficient)
GapCoef(1.0), // Gap Coefficient
Accum(0); // The sum of all the daily gaps

if date<>date[1] then
begin
gap = GapCoef*(O-C[1]);
Accum = Accum+gap;
end;

RelO = O-Accum;
RelC = C-Accum;
RelH = H-Accum;
RelL = L-Accum;

// Gapless - end

Reply With Quote
Thanked by:
  #10 (permalink)
 viki 
italy
 
Experience: Intermediate
Platform: tradestation
Broker: tradestation
Trading: fesx, es
Posts: 14 since Dec 2009
Thanks Given: 1
Thanks Received: 7


This is how it works: The opening “gap” is recorded for the first bar of each trading day.

A relative stream of OHLC's are calculated by subtracting this “gap” from the actual prices. This relative stream of OHLC’s are maintained right along side of the real OHLC’s. If the EL programmer needs to convert between the relative prices and the real price data, the sum of all the gap values is stored in the variable, “accum,” which makes the conversion simple.

If you’re squeamish about eliminating the opening gap altogether, I’ve included a “GapCoef,” that you can set between 0.00 and 1.00 to reduce part or all of the gap as you choose. For example, set the coefficient to 0.5 to reduce the gap by half. I prefer to eliminate the gap altogether so I set the coefficient to 1.0, which eliminates 100% of the opening gap.

Indicators, such as RSI and Stochastics, (see below examples) work fine with this relative price stream and never need to be converted back to real prices.

If you have an indicator that needs to be displayed on the same scale as the underlying data, simply add “accum,” i.e. (indicator + accum) as the last step prior to plotting. You can see an example of this with the Bollinger Band below (code included below in Gapless.ELD).

In order to work correctly, all manipulations (adding, averaging, etc...) should only be done with the relative data (RelO, RelH, RelL and RelC), then if the data needs to be returned to the real domain the variable "accum" is added as the last step.

Below, I've included several examples of indicators using "GapLess" code. The code for each is included below in GAPLESS.ELD. It includes %R, ATR, RSI, Fast Stochastics and Bollinger Bands. You'll see from the examples that any indicator or stategy can take advantage of this code.

The images below show the dramatic difference this approach can make.

Reply With Quote
Thanked by:




Last Updated on February 4, 2014


© 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