Taming Opening Gaps

Topic URL:https://community.tradestation.com/Discussions/Topic.aspx?Topic_ID=77574
Printed on:08/07/2020 05:41:56
Topic:


Topic author:JDM
Subject:Taming Opening Gaps
Posted on:06/01/2008 08:13:55
Message:


Hi All,

I 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.




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.

In this example of ATR you’ll notice the 14 bars at the session open are artificially high without the “GapLess” code.



It’s the same with PercentR. It takes 14 bars to settle down and return to normal. GL (GapLess) allows PercentR to show a buy signal at the 8th bar of the day which would have been missed on the non-corrected version.



Notice how the Bollinger Band acts at the opening. It gives a false BUY signal on the first bar of the day. The GL version gives a buy signal several bars later, near the relative low of the first twenty bars of the day.



Here’s the GL version of the BB.



You can see the regular RSI gave a false buy signal at the opening bar.

The GL version of RSI gave the first buy signal over twenty bars later near the actual low.



The regular Stochastic is indicating an oversold condition at the market open.

The GL version of the Stochastic indicates the open is overbought and correctly gives a sell signal near the sixth bar of the day.



I hope you find this usefull.

- John Mc

Attachment:DATA/20080601080830GAPLESS.ELD 16878 bytes


Replies:


Reply author:sunabeacho
Replied on:06/01/2008 09:56:45
Message:

One word - Excellent!!

Reply author:TradingDude
Replied on:06/01/2008 10:09:16
Message:

Outstanding! Thanks for sharing.

TradingDude



Reply author:nepenthe_sh
Replied on:06/02/2008 21:38:53
Message:

it seems in the stock&commodities there is an article talking about how to eliminate the influence of gap but I am sorry I could not remember the version

Reply author:nepenthe_sh
Replied on:06/02/2008 21:51:47
Message:

Thank you JDM

but I could not find the GL_ATR


Reply author:JDM
Replied on:06/02/2008 23:33:27
Message:

nepenthe_sh,

Here it is:

Attachment:DATA/20080602233304GL_ATR.ELD 4386 bytes

- John Mc


Reply author:nepenthe_sh
Replied on:06/04/2008 22:36:30
Message:

thank you

Reply author:dexter
Replied on:07/02/2008 07:18:08
Message:

Hi,

Here is an alternative using an exponential attenuation of gaps.

EL Function:


hth,

bv


Reply author:5TX6
Replied on:07/02/2008 09:20:12
Message:

Will this work with trend39's Klinger + ATR indicator ?

Thank you


Reply author:dexter
Replied on:07/05/2008 00:54:45
Message:

I don't know those indicators but i see no reason why that filter could not be applied to other series.
Just change trigger conditions accordingly ("if (hh[1])") and make sure your customised conditions do toggle your indicator up/down.


bv


Reply author:goose
Replied on:07/05/2008 12:06:39
Message:

Here is come code in an indicator using XAverage which U could easily adapt to any XAverage Gap concept.

It uses the IN-LINE (not a function) XAverage code to conserve CPU usage + uses Sessions instead of days + only uses functions for sessions on the first tick of a new bar.

!GT_XAvg_Gap is the (v8.3) indicator (attached).


Attachment:DATA/20080705120632XAVG_GAP 070405 I V8.3.ELD 4358 bytes


Reply author:interactive_1
Replied on:09/16/2008 01:46:03
Message:

Thanks JDM, very nice.

Reply author:alpha24
Replied on:09/16/2008 03:39:46
Message:

Very nice , thank you .

I put some code together to close open positions(when profitable) with large gap openings
and look for a retracepoint from the previous day .
I posted this before . Problem is I cant get it to work on an hourly or 15 min chart .
Maybe someone can have a look at it .



Reply author:OpusTrader
Replied on:10/07/2008 14:14:10
Message:

Nice Job

Reply author:knight09
Replied on:10/07/2008 19:04:08
Message:

Alpha
Should
value1 = HighD(1);
value2 = LowD(1);
be
value1 = HighD[1];
value2 = LowD[1];
i.e. wrong type of bracket.
K


Reply author:TradingDude
Replied on:10/07/2008 19:33:16
Message:

quote:
Originally posted by knight09
Alpha
Should
value1 = HighD(1);
value2 = LowD(1);
be
value1 = HighD[1];
value2 = LowD[1];
i.e. wrong type of bracket.
K


knight, take a look at the User Guide. Alpha is correct.

Example
In order to place a short limit order at the High of the previous day you would write:

SellShort Next Bar at HighD(1) Limit;


TradingDude



Reply author:archie007
Replied on:02/09/2009 13:12:49
Message:

this is a great idea. I'm having trouble putting this into a function for Xavg to test with some of my systems. Any help would be greatly appreciated.

Reply author:JavLn
Replied on:02/26/2009 13:07:10
Message:

John,

I wanted to thank you for your contribution. I used your code to tame an A/D indicator. Now, on a new day, the values relative to the previous day's are more in line making the indicator much more readable.

WTG!


Reply author:TheBullFlag
Replied on:02/26/2009 13:18:44
Message:

Great. Very important

Thank you


Reply author:bostonsoccermdl
Replied on:03/17/2009 10:57:27
Message:

Is there any way you can provide the code for the "DMI" indicator? I like this indicator to identify stocks trending, but gaps have been a thorn in my side trying to make this into a filter...

Reply author:bird50
Replied on:06/05/2009 22:44:49
Message:

hi ALl,

i'm a newbie. this is my first post. i've been lurking in the forums, learning what i can. i've been to several of the TS classes, the most recent having been the EasyLanguage bootcamp. i have a boll band strategy i've been working on for the past 6-8 weeks or so, and i keep seeing this post. i've tried several times, in what i believe to be different approaches, and for the life of me i cannot seem to take the gapless bollinger band indicator and turn it into a strategy. my hope is to test whether or not the gapless BB changes my strategy, for better or worse. currently, i just turn the entry portion of the strategy off the first hour to eliminate the gaps. in watching the indicator, it seems i'm missing several entry opportunities.

any assistance would be greatly appreciated. if not, i certainly understand.


Reply author:JDM
Replied on:06/06/2009 12:49:17
Message:

quote:
Originally posted by bird50
hi ALl,

i'm a newbie. this is my first post. i've been lurking in the forums, learning what i can. i've been to several of the TS classes, the most recent having been the EasyLanguage bootcamp. i have a boll band strategy i've been working on for the past 6-8 weeks or so, and i keep seeing this post. i've tried several times, in what i believe to be different approaches, and for the life of me i cannot seem to take the gapless bollinger band indicator and turn it into a strategy. my hope is to test whether or not the gapless BB changes my strategy, for better or worse. currently, i just turn the entry portion of the strategy off the first hour to eliminate the gaps. in watching the indicator, it seems i'm missing several entry opportunities.

any assistance would be greatly appreciated. if not, i certainly understand.


Hi bird.

You can make your BB strat gapless by modifying the central moving average and Standard Deviation.

For example, your BB probably uses code similar to the following to determine the upper and lower bands:





You can covert this to a gapless BB by substituting the following code for the 2 lines that calculate your average and standardDev, i.e. "Avg =" and "SDev =".






Then you just use the upperband and lowerband as you would in a normal BB strat to produce your sell and buy signals.

If you have any problem just post the lines from your BB which calculate the central moving average and Standard Deviation.

I would advise using the same BB code in both an indicator and a strat so you can display the indicator to see what's happening. It's often easier to spot problems that way.

JDM



Reply author:JDM
Replied on:06/06/2009 14:45:13
Message:

quote:
Originally posted by bostonsoccermdl
Is there any way you can provide the code for the "DMI" indicator? I like this indicator to identify stocks trending, but gaps have been a thorn in my side trying to make this into a filter...


If you insert the gapless code into your indicator, then change H to RelH, L to RelL and C to RelC it should work fine.

I would show it here but the DMI indicator in TS is copyrighted. Send me a private message if you have problems.

JDM


Reply author:TradingDude
Replied on:06/06/2009 14:57:36
Message:

quote:
Originally posted by JDM
quote:
Originally posted by bostonsoccermdl
Is there any way you can provide the code for the "DMI" indicator? I like this indicator to identify stocks trending, but gaps have been a thorn in my side trying to make this into a filter...


If you insert the gapless code into your indicator, then change H to RelH, L to RelL and C to RelC it should work fine.

I would show it here but the DMI indicator in TS is copyrighted. Send me a personal message if you have problems.

JDM


Tradestation does not have a problem anyone modifying their code and posting it in the forum. Leave their copyright statement at the bottom of the code.

TS codes have been modifyied and posted in these Forums since it began in July2002

BTW, DMI has been in the public domain for decades as well as most of the studies that is included in the TS platform.

TradingDude



Reply author:JDM
Replied on:06/06/2009 15:09:45
Message:

quote:
Originally posted by TradingDude
quote:
Originally posted by JDM
quote:
Originally posted by bostonsoccermdl
Is there any way you can provide the code for the "DMI" indicator? I like this indicator to identify stocks trending, but gaps have been a thorn in my side trying to make this into a filter...


If you insert the gapless code into your indicator, then change H to RelH, L to RelL and C to RelC it should work fine.

I would show it here but the DMI indicator in TS is copyrighted. Send me a personal message if you have problems.

JDM


Tradestation does not have a problem anyone modifying their code and posting it in the forum. Leave their copyright statement at the bottom of the code.

TS codes have been modifyied and posted in these Forums since it began in July2002

BTW, DMI has been in the public domain for decades as well as most of the studies that is included in the TS platform.

TradingDude






Thanks Dude,

Here's the modified DMI:






Attachment:DATA/20090606150816DMI_GAPLESS.ELD 4436 bytes

JDM


Reply author:mellb
Replied on:06/06/2009 23:07:03
Message:

All great posts. Thanks.
My only contribution is to paraphrase John Carter who's strategy is to "Fade" the gap (Futures). He gives statistics stating that Percentage of Gaps Filled is: 65% Mon, 77% Tues, 79% Wed, 82% Thurs, and 78% Fri. He basically Buys a Gap Down; Shorts a gap up. See "Mastering The Trade" p 120...


Reply author:TheBullFlag
Replied on:06/08/2009 12:48:19
Message:

Jdm,

Could you please create a 3MA gap less indicator and a macd indicator?

Thank you very much


Reply author:clbradley17
Replied on:06/08/2009 16:51:46
Message:

Thank you for your great addition and indicators. Wondering as Noam about a gapless MACD, but mainly interested in a gapless Parabolic Sar indicator, use that on my charts a lot. Also, is it even possible to plot the gapless RSI within the gapless Bollinger Bands in the same code? Thanks for any help.

Reply author:bostonsoccermdl
Replied on:06/08/2009 17:23:29
Message:


Thanks JDM and Tradingdude for the help!


Reply author:adko
Replied on:07/11/2009 19:25:52
Message:

Thanks for a great indicator. Is it possible to use this indicator with Klinger Vol 1.1?
Thanks in advance.


Reply author:TheBullFlag
Replied on:07/15/2009 15:16:54
Message:

Hi, can someone create a Simple Moving Average with this gap less indicator?

Thanks


Reply author:twsn1
Replied on:07/15/2009 17:33:11
Message:

quote:
Originally posted by Noam
Hi, can someone create a Simple Moving Average with this gap less indicator?

Thanks


Noam,
I copied the DMI code provided by JDM on the previous page and added the moving average. You are simply using the RelC, RelH, RelL, RelO IN PLACE OF C, H, L, O respectively.




Reply author:JDM
Replied on:07/15/2009 17:47:16
Message:

quote:
Originally posted by Noam
Jdm,

Could you please create a 3MA gap less indicator and a macd indicator?

Thank you very much


Noam,

Here are some gapless moving averages and a MACD for you to play around with.

JDM

Attachment:DATA/20090715174504MA 1-LINE GAPLESS.ELD 4324 bytes
Attachment:DATA/20090715174620MA 2-LINE GAPLESS.ELD 4585 bytes
Attachment:DATA/20090715174629MA 3-LINE GAPLESS.ELD 5055 bytes
Attachment:DATA/20090715174639MACD GAPLESS.ELD 6596 bytes


Reply author:JDM
Replied on:07/15/2009 17:52:39
Message:

quote:
Originally posted by clbradley17
Thank you for your great addition and indicators. Wondering as Noam about a gapless MACD, but mainly interested in a gapless Parabolic Sar indicator, use that on my charts a lot. Also, is it even possible to plot the gapless RSI within the gapless Bollinger Bands in the same code? Thanks for any help.


Hi clbradley17,

I just uploaded a gapless MACD on the earlier thread.

Here is a gapless parabolic SAR indicator. Check it out and see if it does what you want.

JDM

Attachment:DATA/20090715175110PARABOLIC SAR GAPLESS.ELD 11856 bytes


Reply author:JDM
Replied on:07/15/2009 18:07:15
Message:

quote:
Originally posted by twsn1
quote:
Originally posted by Noam
Hi, can someone create a Simple Moving Average with this gap less indicator?

Thanks


Noam,
I copied the DMI code provided by JDM on the previous page and added the moving average. You are simply using the RelC, RelH, RelL, RelO IN PLACE OF C, H, L, O respectively.


twsn1,

You've got the right idea, but you have to remember that the relative quotes (RelC for close for instance) gradually drift higher or lower than the actual prices - that's how the gaps are eliminated.

If you're going to display a moving average on the same scale as the actual prices you need to remember to add the accumulated offset back in. Instead of plotting average(RelC,length) you need to plot average(RelC,length)+accum. this is only true if your are using the same scale as the actual prices.

If you are plotting an indicator on its own scale such as RSI or CCI you don't need to add the accumulated offset back in.

Hope this clarifies it.

JDM


Reply author:JDM
Replied on:07/15/2009 18:28:46
Message:

quote:
Originally posted by clbradley17
Thank you for your great addition and indicators. Wondering as Noam about a gapless MACD, but mainly interested in a gapless Parabolic Sar indicator, use that on my charts a lot. Also, is it even possible to plot the gapless RSI within the gapless Bollinger Bands in the same code? Thanks for any help.


I'm trying to understand what is meant by "RSI within BBs". I not familiar with this. It sounds like the RSI is treating the upper and lower Bollinger Bands as +100 and -100 and plotting the RSI within those bands. Is this what you mean? If so, it's easily done. I just don't want to code something you don't want.

JDM


Reply author:JDM
Replied on:07/15/2009 18:38:23
Message:

quote:
Originally posted by archie007
this is a great idea. I'm having trouble putting this into a function for Xavg to test with some of my systems. Any help would be greatly appreciated.


Hi archie,

Here's the gapless exponential average.

JDM

Attachment:DATA/20090715183803MA EXPONENTIAL GAPLESS.ELD 4419 bytes


Reply author:JDM
Replied on:07/15/2009 19:17:31
Message:

quote:
Originally posted by adko
Thanks for a great indicator. Is it possible to use this indicator with Klinger Vol 1.1?
Thanks in advance.


adko,

Yes, Here is a gapless version of trend39's very popular Klinger Vol 1.1.

JDM

Attachment:DATA/20090715191415KLINGER VOL GAPLESS.ELD 9785 bytes


Reply author:TheBullFlag
Replied on:07/16/2009 01:05:31
Message:

Thank you very much

Reply author:twsn1
Replied on:07/16/2009 07:48:22
Message:

Originally posted by JDM
If you're going to display a moving average on the same scale as the actual prices you need to remember to add the accumulated offset back in.

Oops! That's what happens when things are done hastily. Thanks for the correction. BTW, Nice technique.


Reply author:adko
Replied on:07/16/2009 16:44:44
Message:

quote:
Originally posted by JDM
quote:
Originally posted by adko
Thanks for a great indicator. Is it possible to use this indicator with Klinger Vol 1.1?
Thanks in advance.


adko,

Yes, Here is a gapless version of trend39's very popular Klinger Vol 1.1.

JDM

Attachment:DATA/20090715191415KLINGER VOL GAPLESS.ELD 9785 bytes



Hello JDM,

Thanks for Klinger with Gapless, but I dont see any difference between standard Klinger Vol 1.1 and Gapless Klinger. Do I do anything wrong or in this case it's the way should be?
Attachment:DATA/20090716164248Klinger_GL.jpg 101886 bytes


Reply author:clbradley17
Replied on:07/16/2009 19:41:56
Message:

Thanks so much for coding the gapless PSAR, JDM. I wish there was a way to tighten the indicator closer to the price, tried using .01 instead of .02 as the 2nd number and helps a little. Yes, please if it's possible to plot the gapless RSI inside of a gapless BB in the same code so it plots on the same axis, that would be fantastic. I just overlay them in the same area on my charts, but have to put one or the other as no axis on the same scale, otherwise they are skewed as a line across the chart, and probably doesn't give an accurate reading. Thanks again for all your work on these fantastic indicators.

Curtis


Reply author:JDM
Replied on:07/16/2009 23:02:01
Message:

quote:

Hello JDM,

Thanks for Klinger with Gapless, but I dont see any difference between standard Klinger Vol 1.1 and Gapless Klinger. Do I do anything wrong or in this case it's the way should be?




The daily gap shows up internally in the Klinger calculations multiple times and I missed one. Hopefully, I've caught all of them now.

Here's the updated ELD.

JDM

Attachment:DATA/20090716230040KLINGER VOL GAPLESS.ELD 10080 bytes


Reply author:TradingDude
Replied on:07/17/2009 13:35:32
Message:

quote:
Originally posted by JDM
quote:

Here's the updated ELD.

JDM

Attachment:DATA/20090716230040KLINGER VOL GAPLESS.ELD 10080 bytes



Klinger Volume Trend thread:

https://community.tradestation.com/Discussions/Topic.aspx?Topic_ID=59409

Thanks JDM for adding these gapless indicators...

Added a link to this ELD on the Klinger thread so others can find it.

TradingDude



Reply author:adko
Replied on:07/17/2009 21:05:07
Message:

JDM,
Thanks so much for coding the gapless KLINGER vol. I tested today and for gap down works ok, but I dont see any difference for gap up. And again the same question, is it possible or that's the way should be?
Thanks again for all your work on these fantastic indicators.


Reply author:JDM
Replied on:07/18/2009 13:04:31
Message:

quote:
Originally posted by adko
JDM,
I tested today and for gap down works ok, but I dont see any difference for gap up. And again the same question, is it possible or that's the way should be?



adko,

Yes, it appears that is the way it should be.

If you look at the original Kilnger Vol 1.1 you'll notice that the large anomalies at the daily open only occur on the down-gaps but not the up-gaps.

It appears that the up-gaps only use “range” (high-low) in their calculations, whereas the down-gaps us “truerange” (close[1]-low) in their calculations. This has the affect of causing a distortion on the down gaps, but not the up gaps, because only the down gap compares the first bar of the day with the prior day's closing bar when determining range.

The Klinger also checks the trend direction on each bar and notes “+1” if the opening bar is up and “-1” if the opening bar is down. But, this doesn’t cause a distortion when there is a large gap up because it still only produces a trend of “+1.”

JDM


Reply author:JDM
Replied on:07/18/2009 17:17:20
Message:

quote:
Yes, please if it's possible to plot the gapless RSI inside of a gapless BB in the same code so it plots on the same axis, that would be fantastic. I just overlay them in the same area on my charts, but have to put one or the other as no axis on the same scale, otherwise they are skewed as a line across the chart, and probably doesn't give an accurate reading. Thanks again for all your work on these fantastic indicators.
Curtis


Hi Curtis,

I believe this is what you want. Both the BB and the RSI are gapless.



I've put the gapless RSI indicator at the bottom also so you can compare the RSI within the
BB to this separate RSI.

When you change the OverBought and OverSold levels of the RSI it simply expands the RSI within the BB so the upper and lower Bollinger Bands coincide with the OverBought and OverSolde levels.

Hope you find it useful. Let me know if you had something else in mind.

JDM



Reply author:JDM
Replied on:07/18/2009 17:23:44
Message:

quote:

Hi Curtis,

I believe this is what you want.


Attachment:DATA/20090718172323RSIWITHINBB GAPLESS.ELD 5675 bytes


Reply author:adko
Replied on:07/18/2009 21:59:52
Message:

JDM Thanks again for your indicator and explanation to it.
Let me test again. Regards.


Reply author:TheBullFlag
Replied on:07/18/2009 22:27:37
Message:

Hi JDM

Could you please create a Hull MA gapless?

Thank you

Noam


Reply author:adko
Replied on:07/19/2009 18:32:58
Message:

quote:
Originally posted by adko
JDM Thanks again for your indicator and explanation to it.
Let me test again. Regards.


JDM, I was wondering if you could have a look and create your indicator into VWAP_H. (I attached below.)
Thanks in advance.
Attachment:DATA/200907191831232003261542_VWAP.ELD 2266 bytes


Reply author:JDM
Replied on:07/19/2009 20:44:37
Message:

quote:
Originally posted by adko
quote:
Originally posted by adko
JDM Thanks again for your indicator and explanation to it.
Let me test again. Regards.


JDM, I was wondering if you could have a look and create your indicator into VWAP_H. (I attached below.)
Thanks in advance.
Attachment:DATA/200907191831232003261542_VWAP.ELD 2266 bytes



Hi adko,

If you're asking to make the VWAP gapless, then the answer is: it is already gapless. It resets itself and starts over on the first bar of the day and is not influenced by a gap from the prior day.

Is that what you were trying to get?

JDM


Reply author:JDM
Replied on:07/19/2009 21:17:14
Message:

quote:
Originally posted by Noam
Hi JDM

Could you please create a Hull MA gapless?

Thank you

Noam


Hi Noam,

Here's what the 21-bar Hull MA looks like normally:



And here it is gapless:



Attachment:DATA/20090719211511JTHMA GAPLESS.ELD 7111 bytes


Reply author:adko
Replied on:07/19/2009 23:13:58
Message:

quote:
Originally posted by JDM
quote:
Originally posted by adko
quote:
Originally posted by adko
JDM Thanks again for your indicator and explanation to it.
Let me test again. Regards.


JDM, I was wondering if you could have a look and create your indicator into VWAP_H. (I attached below.)
Thanks in advance.
Attachment:DATA/200907191831232003261542_VWAP.ELD 2266 bytes



Hi adko,

If you're asking to make the VWAP gapless, then the answer is: it is already gapless. It resets itself and starts over on the first bar of the day and is not influenced by a gap from the prior day.

Is that what you were trying to get?

JDM


Thank you so much for your explanation. It is clear for me now.
Best regards,
adko


Reply author:clbradley17
Replied on:07/20/2009 00:15:06
Message:

Thanks again JDM, for the RSI within BB bands gapless combo, and also for the jtHMA gapless too. This is one of the best and most helpful threads with a fantastic array of indicators that I've seen in the last year and a half since I joined TS.

Reply author:TheBullFlag
Replied on:07/20/2009 17:52:12
Message:

JDM

You are the best

Thanks


Reply author:hmal
Replied on:07/27/2009 16:57:08
Message:

JDM, I was wondering if u could help with adding ur code to this indi for me?

thanx



Reply author:twsn1
Replied on:07/27/2009 20:43:09
Message:

quote:
Originally posted by hmal
JDM, I was wondering if u could help with adding ur code to this indi for me?


Try this. To verify it is identical to your original, set the gapcoef to "0" and compare.



Reply author:hmal
Replied on:07/28/2009 09:35:21
Message:

twsn,

thanx, looks like there was no change. all levels are the same


Reply author:twsn1
Replied on:07/28/2009 18:12:12
Message:

Originally posted by hmal
looks like there was no change. all levels are the same

To prove your observation, place the indicator on the chart TWICE. Set the "gapcoef" to "0" on one and set to "1" on the other. Then compare values. If the values are the same, there are no significant gaps. If there are OCCASIONAL and/or SMALL gaps then the values of the indicator will be SLIGHTLY DIFFERENT. If there are FREQUENT and/or LARGE gaps, then the values of the indicator will be NOTICEABLE.


Reply author:hmal
Replied on:07/29/2009 09:39:16
Message:

thx tw, i'll keep an eye on it

Reply author:RRonz
Replied on:07/30/2009 10:29:51
Message:

Hi JDM,
I've tried to create a gapless CCI with no success,
could you please help.
Thanks


Reply author:JDM
Replied on:07/30/2009 18:28:03
Message:

quote:
Originally posted by RRonz
Hi JDM,
I've tried to create a gapless CCI with no success,
could you please help.
Thanks


Hi RRonz,

Here it is:



JDM

Attachment:DATA/20090730182733CCI GAPLESS.ELD 5887 bytes


Reply author:StratMan
Replied on:07/30/2009 19:27:23
Message:

John,

While I'm be a year behind, just took the time to study this topic because your jtHMA chart caught my attention - big time.

AWESOME! Very cool concept and code. Thanks so much for sharing!

I now have a new weekend project to dig into this and then possibly integrate the concept into several of my key indicators and "filters" if the results favorably can improve how I currently use them.

Silly question, though, and please forgive me before I get into this... Are there any drawbacks to the accuracy of indicator plots/signals using this algorithm concept?


Reply author:JDM
Replied on:07/30/2009 22:08:25
Message:

quote:
Originally posted by StratMan
John,
Silly question, though, and please forgive me before I get into this... Are there any drawbacks to the accuracy of indicator plots/signals using this algorithm concept?



Hi Stratman,

I don’t know of any accuracy issues when it is applied correctly (this can a bit tricky), but there are plenty of philosophical issues.

This method splices the end of one day to the beginning of the next. It is very similar to the way a continuous contract endlessly chains real contracts together.

We are dealing with a gap that occurs in the 17 hours (more or less) between the close of one day’s trading and the opening of the next. It is clearly unfair to absorb this gap in a single bar, be it 1-minute or 10-minutes.

The daily gap is the most obvious problem resulting from the 17-hour break in trading. Eliminating the gap has the effect of calming indicators as they transition from one day to the next, which brings to light other problems with daily transitions. Each indicator uses a unique combination of average, trend, volatility, a bar’s closing position, and so on. It is a bit presumptuous to think that the activity on one day’s close is still valid 17 hours later. Again, eliminating the gap doesn’t seem to make this any worse, it just enables us to see the other problems better.

One could also argue that the direction of the gap is a valid indicator (or anti-indicator) of the market pressure at the day’s open. I leave it to you to test that out.

For the most part this gapless code seemingly improves both indicators and strats, but it’s far from the perfect answer. If there is a pre-trading session for the day, you might be better off splicing it onto the beginning of the day with a custom trading session. You can also restart each indicator at the beginning of the day and not use carryover data from the prior day. This can be done by setting up a bar counter for the beginning of the day. For example:

if date<>date[1] then DailyBarCount=0;
DailyBarCount= DailyBarCount+1;
MyAvg=average(price,minlist(Length,DailyBarCount));

Or in the case of an exponential average:

If date<>date[1] then MyEAv=Price
Else MyEav=xAverage(Price,Length);

I should also mention ATR. Lot’s of indicators use ATR and the daily gap can really skew the results of ATR. You might substitute Range for TrueRange on the day’s opening bar, while leaving TrueRange valid for all the other bars. This eliminates the ballooning envelopes so common at the day’s open with Bollinger Bands.

This doesn’t really cover all the philosophical and application issues, but hopefully it will begin a dialog which may.

JDM





Reply author:RRonz
Replied on:07/30/2009 23:35:23
Message:

JDM
Thanks for you help with the CCI.
Ron


Reply author:StratMan
Replied on:08/01/2009 20:04:33
Message:

John,

Many thanks for your reply and explanation... Truly appreciate that.

Just downloaded all of your "gapless" indicators to study in hopes that the concept will improve the "acceleration" plots of several of my key indicator "filters." Since I use the jtHMA and ATR "filters" quite a lot, I'll start with those and report back.

Hopefully, your code and concepts on how to apply the gapless function are more "transparent" than how other "visible people" in America have been using that word since January 20th. If not, I'll be sure to "reach out" and ask for some additional guidance.

Again, thanks a lot and please forgive my conservative sarcasm by commingling politics into your awesome topic... Can't help it as I watch the framework and structure of our country seemingly and rapidly go down the ol' rat hole.

Hope ya'll understand.

StratMan



Reply author:RRonz
Replied on:08/02/2009 03:03:46
Message:

Hi JDM,

Attached is the HiLo indicator which I'm trying
to incorporate your gapless code with no success,
your help is appricated again.

Thanks,

Ron


Attachment:DATA/20090802025949HILOGAP.ELD 8570 bytes


Reply author:StratMan
Replied on:08/02/2009 19:30:22
Message:

JDM - John,

Great concept and, from a plot-correcting point of view, seemingly similar to Goose's version of GapAdjusting that I've seen in other topics as well as this one on page 1. After spending several hours today studying and testing your code in the jtHMA, EMA and an ATR Stop indicator, here's what I noticed:

1) Both yours and Goose's code "accelerate" the plots of indicators quite nicely, especially with the jtHMA;

2) In studying these indicator adjusted plots across various time frames (1-60 min), I noticed that many times the adjusted plot visually seemed to "over shoot" the unadjusted plot when the opening gap was huge;

3) Speaking of time frames, people may want to add a BarType<=1 condition to limit the GapAdjusting feature only to minute and tick charts depending on their application;

4) That got me to thinking about ATR and StdDev in order to look at the Opening Gap amount in relationship to yesterday's closing bar volatility. So, I did some testing based the opening gap amount being > or < the ATR (didn't test StdDev with this idea) where the GapAdjusting function would/would not "kick in" based on that relationship. Interesting results... that seemed to improve the visual plots of these indicators on the low ATR end;

5) Based on point 4 above, does anyone have any ideas on how to ratchet up/down the opening gap amount/factor based on volatility (ATR) as that seems like a conceptually valid way to reduce the indicator plot from over-reacting. Thoughts?; and,

6) If the issues in points 4 and 5 above can be addressed, then it seems like the problem with applying this "taming the gap" or "gap adjusting" code to the ATR Stop indicator possibly would get resolved. You see, John, when I applied this concept to a trailing stop indicator, the plots would always "whip-saw" when the gap was quite large in relationship to volatility when compared to my current indicators without any kind of gap adjusting functionality. Any thoughts on how to compensate for this?

That said, hopefully these comments will cause other ideas, input and feedback on this topic, which would be greatly appreciated.

In advance, thanks a lot.


Reply author:JDM
Replied on:08/02/2009 22:53:37
Message:

quote:
Originally posted by StratMan
JDM - John,

Great concept and, from a plot-correcting point of view, seemingly similar to Goose's version of GapAdjusting that I've seen in other topics as well as this one on page 1. After spending several hours today studying and testing your code in the jtHMA, EMA and an ATR Stop indicator, here's what I noticed:




Hi Stratman,

Your political comments are welcome here. It’s a nice change of pace.

2 . . . adjusted plot visually seemed to "over shoot" the unadjusted plot when the opening gap was huge;

Can you show me an example of what you are talking about with “over shoot” and the code that produced it? The jtHMA plot above seems to fall right into place as though the gap had never happened. It overshoots the unadjusted plot while the unadjusted plot catches up, but it doesn’t appear to overshoot the raw data.


3. . . . add a BarType<=1 condition

Yes, time frame is important. I typically only use gapless on 20-minute bars or less.


4 . . . (kick in when) Opening Gap amount in relationship to yesterday's closing bar volatility.

That’s a good point. I considered having the gapless code kick in only if:
Low>high[1] or highOn the opening bar of the day, but it didn’t seem to make much difference.


5 . . . ratchet up/down the opening gap amount/factor based on volatility (ATR)

There is a variable that might be used for this ratcheting. It’s called gapcoef. I imagine you’d use a ratio of ATR to gap size to adjust this somehow.


6 . . . the plots would always "whip-saw"

As in #2, can you show me what you’re running into and the code that caused it? I might be able to straighten it out.

JDM


Reply author:JDM
Replied on:08/02/2009 23:35:40
Message:

quote:
Originally posted by RRonz
Hi JDM,

Attached is the HiLo indicator which I'm trying
to incorporate your gapless code with no success,
your help is appricated again.

Thanks,

Ron




Ron,

You are very welcome.

JDM

Attachment:DATA/20090802233455Gap HiLo.ELD 9412 bytes


Reply author:msb
Replied on:08/03/2009 09:23:48
Message:

Hi JDM: Would you mind posting the underlying code for your .elds in code box form like you did at the start of this thread? There are several of us who don't import .elds due to past problems but would still like to see your code. Thanks.

Reply author:JDM
Replied on:08/03/2009 11:35:34
Message:

quote:
Originally posted by msb
Hi JDM: Would you mind posting the underlying code for your .elds in code box form like you did at the start of this thread? There are several of us who don't import .elds due to past problems but would still like to see your code. Thanks.


Hi MSB,

I'd be glad to post the code.

Here's the gapless jtHMA:




and here's the CCI gapless:




and the function you will need for CCI:




Let me know if you need any others.

JDM









Reply author:RRonz
Replied on:08/03/2009 12:06:53
Message:

Hi JDM,

Here's a screen shot of the MA 2-line gapless MA set at fast 6 red
and slow 30 blue. Indicator was downloaded without any modification,
chart is 3 mn TF day session only with 6+ point gap today.

6 seems to plot corretly, not sure what happened to 30, it starts
plooting above all prices, any thoughts?

Thanks for all you help.

Ron


Attachment:DATA/20090803115655JDM gapless.PNG 30031 bytes


Reply author:JDM
Replied on:08/03/2009 14:29:16
Message:

quote:
Originally posted by RRonz
Hi JDM,

Here's a screen shot of the MA 2-line gapless MA set at fast 6 red
and slow 30 blue. Indicator was downloaded without any modification,
chart is 3 mn TF day session only with 6+ point gap today.

6 seems to plot corretly, not sure what happened to 30, it starts
plooting above all prices, any thoughts?

Thanks for all you help.

Ron




Hi Ron,

You'll notice the 30 bar MA was already plotting well above the data on the last bar of the prior day. It simply continued plotting about the same amount above the data on the opening bar of the new day.

We can reduce the effect of the gapless offset on longer moving averages. This is consistent with the idea that we would only use the full effect of this gapless code on tick and minute charts - perhaps 30-minute bars or less. We could gradually fade out the effect as the length of the moving averages increases.

Below find the before and after images of a 2-line moving average with the offset faded out completely by the time the moving average length reaches 200 minutes. You can set this by changing the value of “NoMoreOffset.”






You'll notice that in the first image the red and blue lines jump upwards the same amount as the gap did. But in the second image the blue line (30-bar, 99-minute MA) only jumped upward 1/2 the distance of the gap.

Here's the code:




The key lines:
fade1=1-(FastLength*barinterval)/NoMoreOffset;
fade2=1-(SlowLength*barinterval)/NoMoreOffset;

will fade out the effect of the gapless code as the moving average gets longer. The gapless code has full effect on tick charts and minute charts of shorter duration, but no effect on daily or weekly charts.

The formula, fade1=1-(FastLength*barinterval)/NoMoreOffset;, was quickly put together. Someone might be able to find a better transistion formula, but this one seems to work pretty well.

JDM


Reply author:TheBullFlag
Replied on:08/03/2009 14:36:19
Message:

JDM,

Could you please create a gap less stochastic slow ?

Thanks


Reply author:JDM
Replied on:08/03/2009 14:56:12
Message:

quote:
Originally posted by Noam
JDM,

Could you please create a gap less stochastic slow ?

Thanks


Here it is:




Attachment:DATA/20090803145554STOCHASTIC SLOW GAPLESS.ELD 4882 bytes


Reply author:TheBullFlag
Replied on:08/03/2009 15:04:15
Message:

Thank you so much

Noam


Reply author:RRonz
Replied on:08/03/2009 19:35:55
Message:

JDM,
I'll make the changes.
Thanks,
Ron


Reply author:msb
Replied on:08/04/2009 08:50:46
Message:

JDM: Thx.

Reply author:JDM
Replied on:08/04/2009 13:37:26
Message:

quote:
Originally posted by StratMan
JDM - John,


2) In studying these indicator adjusted plots across various time frames (1-60 min), I noticed that many times the adjusted plot visually seemed to "over shoot" the unadjusted plot when the opening gap was huge;




StratMan,

Here's a modified version of the HMA which gradually fades out the effect of the gapless code as the moving average lengthens. It may remove the overshoot you observed and might affect the whipsaw as well. Hope it helps.

JDM





Reply author:toponder
Replied on:08/05/2009 10:33:39
Message:

JDM, this is very useful! I'm having difficulty applying this to a exponential 2 moving average cross strategy - do you have any code already put together for moving average indicators and strategies? Thanks again - nice work on this.

Reply author:QValue
Replied on:08/05/2009 11:58:22
Message:

jdm, if you get a chance, i have two questions...

1) has applying the gap adjustment to your strategies improved their performance?

2) i am intriqued with what you are doing, but not sure whether this is a philosophically correct adjustment to make. by eliminating the gap, it would seem that this eliminates the adjustment to prices on the open which is the result of discounting new information that has occurred during the preceding 17hrs.

Granted, it takes the market awhile to figure out how this information should be discounted... hence the frequent 'over-reaction' as investors attempt to digest and discount news (and subsequent filling of the gap). I guess if the probability holds true that 80% of gaps are filled, it suggests that opening gaps are frequently an incorrect over-reaction and can be eliminated, with only the risk that they are legitimate 20% of the time. Some of gap is also a function of supply/demand imbalance, which is not derived from fundamentals.

thanks for a thought provoking concept. rgds/Q.


Reply author:TradingDude
Replied on:08/05/2009 20:31:24
Message:

quote:
80% of gaps are filled


What I've read, is that gaps are filled 80 % of the time in 6 months. Not very useful for my trading style.

If one is day trading, re-setting the indicators to prevent wild misleading computations can help.

Trading futures, which I do, we use overnight 24 hour market data.

I would guess, that if one is swing trading, and holding positions overnight, re-setting gaps in equities/etf would not help.

Its a matter of what the individual prefers to use.

Adjust for a gapless or re-setting has been very useful when I was day trading equities and ETFs.

TradingDude




Reply author:QValue
Replied on:08/06/2009 08:19:51
Message:

td, thanks for your comment. that is helpful input.

anyone else care to comment on pre-gap adjusted/post-gap adjusted performance of their strategies. i'm assuming some of you have run them side by side to confirm the benefit, and i'd like to hear feedback.


Reply author:JDM
Replied on:08/06/2009 13:12:19
Message:

quote:
Originally posted by QValue
jdm, if you get a chance, i have two questions...

1) has applying the gap adjustment to your strategies improved their performance?

2) i am intriqued with what you are doing, but not sure whether this is a philosophically correct adjustment to make. by eliminating the gap, it would seem that this eliminates the adjustment to prices on the open which is the result of discounting new information that has occurred during the preceding 17hrs.

Granted, it takes the market awhile to figure out how this information should be discounted... hence the frequent 'over-reaction' as investors attempt to digest and discount news (and subsequent filling of the gap). I guess if the probability holds true that 80% of gaps are filled, it suggests that opening gaps are frequently an incorrect over-reaction and can be eliminated, with only the risk that they are legitimate 20% of the time. Some of gap is also a function of supply/demand imbalance, which is not derived from fundamentals.

thanks for a thought provoking concept. rgds/Q.


Hi Q,

1) has applying the gap adjustment to your strategies improved their performance?

Yes, it has improved my strategy performance (working with 1-minute bars). It was strategy performance that got me on this track in the first place. I was testing Bolinger Bands, RSIs and CCIs and constantly had problems with false triggering caused by gap opens. These indicators became worthless until they settled down several bars later. Performance improved nicely by using gapless code to eliminate these false signals. An alternate method is to suspend trades for “n” number of bars to allow these indicators to settle, but then I missed some good trades early in the day. At the time I was only working with 1-minute and 2-minute bars. The story may be different on longer duration bars.

2) by eliminating the gap, it would seem that this eliminates the adjustment to prices on the open which is the result of discounting new information that has occurred during the preceding 17hrs.

I believe it was Larry Williams who said the market is always right. I would have to agree that if there is a gap open there is an underlying cause and we would not want to ignore that. But, when we leave the gap in, we are ignoring something even more important and that is the fact that our charts don’t show any bars between the close and the open to graph that overnight influence against. By the time the opening bell sounds the market could be trending with or against the gap. I’ve found on average, as a scalper, it is better to remove the influence of the gap from my indicators.

Let’s pose a thought problem – one that thankfully doesn’t exist. Let’s imagine what we would do if we occasionally had 40 minute lapses in data on our charts. Our charts are plotting 1-minute bars and then they go quiet for forty minutes and suddenly start charting again with no bars for the missing forty minute period. This would nearly always produce a misleading gap and would play havoc with our indicators. The question before us is how do we make the best of this situation. In the 70’s I had a similar problem running strategies against an incomplete historical data base. I used daily bars from a data base that was missing several days here or there. I simply used straight-line interpolation to fill in the missing days so I could complete my analysis. Later when I was able to fill in the missing quotes it did not noticeably change the results. Had I ignored those days (sometimes several in a row) and collapsed the data to eliminate those bars, I’m sure the results would have been skewed.

As I see it, we have several possible solutions before us. Here are just a few: a) straight-line interpolation, b) eliminate the gap, c) dampen the gap, d) suspend trades until the indicators calm down again, e) synthesize pre-market bars.

STRAIGHT-LINE INTERPOLATION

There are approximately 1,035 minutes between the close of the ES and it’s open. This could be used for a straight-line interpolation of missing bars, but I might recommend using about 40 minutes instead, because that is closer to the proportionate volume of trading that occurs during the after-market period. By that, I mean there seems to be approximately 11% as much volume during the night session as there is during the normal session. So, with 405 minutes for the day session, I might recommend using about 40 minutes as an equivalent volume per bar for the night session. Straight-line interpolation is so often nearly level for 1-minute or 2-minute bars that we could simplify this by extending the daily open back 40 minutes and plot our indicators accordingly. Or – we could simply restart our indicators each day, ignoring the prior day’s data.

ELIMINATE THE GAP

If we have no bars to plot the overnight activity against, then we may choose to eliminate the gap entirely. This is very similar to splicing different contracts together to make a continuous contract.

DAMPEN THE GAP

This has been explored in other threads and some very good software has been produced to accomplish this, but it still favors the direction of the gap and sometimes that direction has already reversed prior to the open.

TEMPORARILY SUSPEND YOUR TRADES

This is a very safe method which has been used to advantage, but it locks out any opportunity to trade during the opening minutes.

SYNTHESIZE PRE-MARKET BARS

Where we have access to pre-market trading data we could synthesize pre-market bars to run our indicators against. It might work like this:

Collect data during the overnight session with equal-volume bars. Suggest using a volume that is equivalent to the average 1-minute normal session bars. Write this data out to an Excel spread sheet or use ADE. Input this data into your indicators as the synthetic data for the 40 minutes of trading prior to the open.

Unfortunately none of the functions or indicators currently in use are made to work with this synthetic data, so they would all have to be rewritten.

Synthesizing pre-market data sounds like the best solution, but it also seems to require a major re-write of our code.

SUMMARY

I’ve tried all of the above except synthesizing and for my trading style the gapless approach seems to work best.

TRADING STYLES

Trading style is a very important part of this discussion. Not just trading style, but also trading duration. If staying in a trade more than an hour is long-term for you, then you would not be very concerned about whether a gap is going to be filled within the next six months.

So, when you ask about results, remember they are biased heavily by trading style.

I propose that we at least categorize trading-style time frames. I don’t want to reinvent the wheel here, so if anyone knows of an extant method please let me know.

We might use:
Very Short term - Tick to 5-minute bars
Short Term - 5-minute to 30-minute
Medium Term - 30-minute to daily bars
Long Term - Daily bars and higher


When evaluating the pros and cons of different methods I believe we will find that the answer is different for each time frame. The samples given earlier in this thread are based on very short term time frames.

It seems clear that opening gaps make most indicators (BB, RSI, CCI) unworkable during the opening minutes of the market. The question is, “how do we handle it?”

JDM


Reply author:QValue
Replied on:08/06/2009 13:48:41
Message:

jdm, thank you for a thorough response. i use short-term bars (10-20min) for intraday trading and have felt i was getting distorted signals during the first 1-2hrs due to the opening gap. As a consequence, I optimize my start time, which often puts the start time 1-2hrs after the open. However, this is not always true, so in addition to diversifying the type of strategies I'm running, I also have some that start right at the open. I'm intriqued with the gapless methodology you've described and can see that this may be helpful for intraday strategies, particularly those that are sensitive to short bar lengths.

Reply author:JDM
Replied on:08/06/2009 14:25:07
Message:

quote:
Originally posted by toponder
JDM, this is very useful! I'm having difficulty applying this to a exponential 2 moving average cross strategy - do you have any code already put together for moving average indicators and strategies? Thanks again - nice work on this.


Hi To,

Here's the code with the fade out function to make it less active on longer moving averages.

JDM




Reply author:JDM
Replied on:08/06/2009 14:32:39
Message:

quote:
Originally posted by TradingDude
quote:
80% of gaps are filled

What I've read, is that gaps are filled 80 % of the time in 6 months. Not very useful for my trading style.

If one is day trading, re-setting the indicators to prevent wild misleading computations can help.

Trading futures, which I do, we use overnight 24 hour market data.

I would guess, that if one is swing trading, and holding positions overnight, re-setting gaps in equities/etf would not help.

Its a matter of what the individual prefers to use.

Adjust for a gapless or re-setting has been very useful when I was day trading equities and ETFs.

TradingDude


Thanks Dude,

I think you have stated the advantages and disadvantages well.

JDM


Reply author:twsn1
Replied on:08/06/2009 21:29:52
Message:

Originally posted by JDM
Here's a modified version of the HMA which gradually fades out the effect of the gapless code as the moving average lengthens.


JDM,

This code calls for a FIXED moving average so I don't understand the phrase highlighted in red above.

Also, I understand the "fade" to take the place of "gapcoef". Since both "gapcoef" and "fade" are fixed values and since experimenting with various values of "gapcoef" would give similar results as the "fade" computation, what is the philosophical basis for the choice of this method of dampening the gap?



fade( 1 - (length*barinterval)/NoMoreOffset ),

once if fade<0 then fade=0;

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


Reply author:JDM
Replied on:08/07/2009 11:22:10
Message:

quote:
Originally posted by twsn1
Originally posted by JDM
Here's a modified version of the HMA which gradually fades out the effect of the gapless code as the moving average lengthens.


JDM,

This code calls for a FIXED moving average so I don't understand the phrase highlighted in red above.

Also, I understand the "fade" to take the place of "gapcoef". Since both "gapcoef" and "fade" are fixed values and since experimenting with various values of "gapcoef" would give similar results as the "fade" computation, what is the philosophical basis for the choice of this method of dampening the gap?



fade( 1 - (length*barinterval)/NoMoreOffset ),

once if fade<0 then fade=0;

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


twsn,

I should have said, "as the user lengthens the moving average." If this code where used in a strategy, the user could put in a range of "lengths" and a range of "NoMoreOffset" to optimize.

"fade" and "gapcoef" are similar but produce different results. "fade" only reduces the offset for longer moving averages, whereas "gapcoef" reduces the offset equally for all moving-average lengths.

Also some strats use two or more moving averages. "fade" would affect each length differently, whereas gapcoef would not.

JDM



Reply author:LaserCut
Replied on:08/09/2009 08:54:46
Message:

JDM
When Stratman said "jtHMA chart caught my attention - big time". My attention was focused on your thread. I have read most of his treards and comments. Then TradingDude said "that gaps are filled 80 % of the time". I have also read most of his treards and comments I have a great deal of respect for both of these individuals for their contributions to the forum and the willingness to share and help educate those of us that would program if they could. As in all professions there are people that Excel (used this spell as it is the name of my company) and those that get by. I believe I could get by, but never Excel. I will add you to my weekly review of the forum as you seem to have the same commitment to help and share. Thanks to all those mentioned above for your on going contributions. There are many of us that truely appreciate your time and effort.

I tried to verify your post of 8/3 Here's the gapless jtHMA
Word not recognized.
Value1 = jtHMA(RelC, length) + accum;

modified version of the HMA
I had the same trouble with this one.
Don't have a clue why and that will tell you my level of programming.
I watch for the gap play everyday as I would take an 80% win rate anyday.


Reply author:StratMan
Replied on:08/09/2009 09:21:57
Message:

LaserCut,

Welcome to the TSForum and thank you for your kind words. Since trading and programming are a passion of mine, I enjoy helping out when I can and giving back for all the help that others have shared with me.

As for your verify issue:

quote:

tried to verify your post of 8/3 Here's the gapless jtHMA
Word not recognized.
Value1 = jtHMA(RelC, length) + accum;

modified version of the HMA
I had the same trouble with this one.
Don't have a clue why and that will tell you my level of programming.
I watch for the gap play everyday as I would take an 80% win rate anyday.
I just copied-n-pasted JDM's code from 8/3 and 8/4 into v8.6-2525 and both versions verified without any errors.

You may want to try again with a new ELD indicator file as I do not see any apparent problem with the code.

Holler back if you're still having problems.


Reply author:TradingDude
Replied on:08/09/2009 09:43:03
Message:

jtHMA is a user developed function you apparently have not imported. Its in the original HMA thread.

TradingDude



Reply author:TradingDude
Replied on:08/09/2009 09:47:14
Message:

Import atavachron's ELD or any other HMA ELD to add the jtHMA function to your platform.

https://community.tradestation.com/Discussions/Topic.aspx?Result=1&Topic_ID=40589

Tradingdude



Reply author:StratMan
Replied on:08/09/2009 10:05:23
Message:

quote:
Originally posted by TradingDude
jtHMA is a user developed function you apparently have not imported. Its in the original HMA thread.

TradingDude
Thanks for the good catch on my oversight regarding the function, which, once installed, should allow LaserCut to verify JDM's gap-adjusting version.


Reply author:LaserCut
Replied on:08/09/2009 11:11:57
Message:

Yes it did thanks guys.

Reply author:QValue
Replied on:08/12/2009 14:17:32
Message:

JDM, I am using a pivot type of strategy based on 15 minute bars in data2 position. My data1 position is same security on 1 minute bars and is devoted to exits. Do I need to make any special assignments of the Rel-OHLC to data2 for my data2 calculations, or, given that the gap should be the same in both, is it necessary.

Reply author:prostock
Replied on:08/13/2009 09:42:55
Message:

Hi, JDM
I wonder if I trade in the same day but with two different sessions.
Then take HMA for example, can you post the text code for me ?
Thanks.


Reply author:twsn1
Replied on:08/13/2009 20:46:19
Message:

Originally posted by QValue
JDM, I am using a pivot type of strategy based on 15 minute bars in data2 position. My data1 position is same security on 1 minute bars and is devoted to exits. Do I need to make any special assignments of the Rel-OHLC to data2 for my data2 calculations, you don't need SPECIAL assignments but you will need SEPARATE calculations for data2
or, given that the gap should be the same in both, is it necessary. if you identify the gap as close[1] - open then the gap will be the same for data1 as for data2


Reply author:twsn1
Replied on:08/13/2009 21:01:26
Message:

quote:
Originally posted by prostock
Hi, JDM
I wonder if I trade in the same day but with two different sessions.
Then take HMA for example, can you post the text code for me ?
Thanks.


Is this what you need?




Reply author:spxNewbie
Replied on:08/20/2009 11:40:17
Message:

JDM,
I was just finishing an EL indicator when I realized that I would need to ignore the first x minutes of trading because of the distorted trendlines due to the gap. I was thrilled and amazed when I found your gap fix. Stellar work!

One question: when I use the various indicators individually (eg, RSIgapless, MA1gapless, etc) by manually applying them to my chart, everything is hunky dory. But when I try to incorporate them into a single indicator that I am writing in EL, the various plots get mashed into straight lines. I think this is because they all have different axis's. Here is a snippet:

Plot10(trixGapless(Close, 15));
Plot11(rsiGapless(Close, 12));
Plot12(AverageFCgapless(Close, 6));
Plot14(AverageGapless(Close, 8));

Any idea of either what I'm doing wrong, or if there is a setting I am missing (eg, setting the scale for each of these plots to "no axis"?

On a different topic: am I right in assuming that all of the distortion caused by the gap would be gone by the time all of the indicators have enough backData? For example, if my RSI length is 6, and I'm using 5 minutes bars, the gap distortion would be over in 30 minutes (ie, length * barTime)?

Thanks again for your wonderful work on this.


Reply author:JDM
Replied on:08/20/2009 15:14:26
Message:

quote:
Originally posted by flash48
JDM,
I was just finishing an EL indicator when I realized that I would need to ignore the first x minutes of trading because of the distorted trendlines due to the gap. I was thrilled and amazed when I found your gap fix. Stellar work!

One question: when I use the various indicators individually (eg, RSIgapless, MA1gapless, etc) by manually applying them to my chart, everything is hunky dory. But when I try to incorporate them into a single indicator that I am writing in EL, the various plots get mashed into straight lines. I think this is because they all have different axis's. Here is a snippet:

Plot10(trixGapless(Close, 15));
Plot11(rsiGapless(Close, 12));
Plot12(AverageFCgapless(Close, 6));
Plot14(AverageGapless(Close, 8));

Any idea of either what I'm doing wrong, or if there is a setting I am missing (eg, setting the scale for each of these plots to "no axis"?

On a different topic: am I right in assuming that all of the distortion caused by the gap would be gone by the time all of the indicators have enough backData? For example, if my RSI length is 6, and I'm using 5 minutes bars, the gap distortion would be over in 30 minutes (ie, length * barTime)?

Thanks again for your wonderful work on this.


Hi Flash,

I think this is because they all have different axis's.

Yes, it does sound like the "axis" or should I say "scale" of each of the indicators is causing a problem when you combine them into a single indicator. If you add TRIX and RSI together you will only basically see the RSI, because the scale of the RSI goes from -100 to 100 while the scale of the TRIX is closer to -1 to 1 for the ES.

The Moving Averages are on the same scale as the price itself. I might recommend detrending the Moving Averages before combining them with the RSI and the TRIX. You can use a multiplier for each of the resulting indicators to put them on the same scale, more or less. For example using a multiplier of about 100 will put the TRIX (for ES) on a similar scale with the RSI.

am I right in assuming that all of the distortion caused by the gap would be gone by the time all of the indicators have enough backData?

For simple moving averages the distortion disappears when there is enough back data. But on more complicated indicators like the TRIX the distortion never really disappears it just gets smaller and smaller until it all but disappears. I recommend running both the original indicator and the gapless version on top of each other to see for yourself when the influence of the gap seems to vanish.

JDM




Reply author:spxNewbie
Replied on:08/20/2009 16:14:19
Message:

JDM,

Thank you very much for the quick reply. Normalizing the values by multiplying should fix my problem.

And thank you again for providing such a great solution to a nasty problem.

Flash


Reply author:JDM
Replied on:08/21/2009 16:17:03
Message:

quote:
Originally posted by flash48
JDM,

Thank you very much for the quick reply. Normalizing the values by multiplying should fix my problem.

And thank you again for providing such a great solution to a nasty problem.

Flash


Flash,

It's my pleasure.

Good Trading!

JDM


Reply author:TheBullFlag
Replied on:08/21/2009 23:12:50
Message:

Hi JDM,

Could you please add gapless to this indicator? Thank you very much for your help



Reply author:JDM
Replied on:08/25/2009 00:28:31
Message:

quote:
Originally posted by Noam
Hi JDM,

Could you please add gapless to this indicator? Thank you very much for your help


Hi Noam,

check this out - I think it's what you want.

JDM




Reply author:TheBullFlag
Replied on:08/25/2009 09:02:53
Message:

Thank you very much!

Reply author:spxNewbie
Replied on:08/26/2009 12:29:00
Message:

Hi JDM,

I have been trying for several hours, without success, to create a gapless TSI. But I keep getting a result that almost exactly matches the normal TSI. I am trying to plot these in the same subgraph (#) as my price axis, so I am specifying a right axis for the prices, and "no axis" for the tsi indicators. Any idea of what I am doing wrong? I tried the gapless version first without the "accum" added, but it did not seem to make a difference. Am I doing something wrong here? I very much appreciate your time.


Here is the unmodified tsi code:



And here is my attempt at a gapless version.




Reply author:RRonz
Replied on:09/03/2009 14:04:54
Message:

Hi JDM

I'm having trouble getting this moving average based
indicator to plot properly.

Your help is appriciated.

Ron

Attachment:DATA/20090903140407HILOG.ELD 8425 bytes


Reply author:clbradley17
Replied on:02/02/2010 07:06:05
Message:

JDM, Could you please create a gapless Slow Stochastics within a gapless Bollinger Bands plotted in the same code like you did with the gapless RSI + gapless Bollinger Bands on page 2? I trade frequently with that combined indicator, and also the slow stochastics, and it would be very beneficial to have the gapless slow stochastics + gapless BB in the same code to trade with the gapless RSI + BB. Thanks again so much for these indicators, and for help with the SS gapless + BB gapless combined in advance.

Reply author:hmal
Replied on:07/09/2010 13:02:32
Message:

JDM, any way to apply gapless to symbols such as $TICK, $VOLD, etc?

Thanks


Reply author:JDM
Replied on:07/09/2010 13:29:11
Message:

hmal,

It was only designed for price data, not tick or volume data. I would be very hesitant to use it on these.

JDM


Reply author:clbradley17
Replied on:07/10/2010 22:07:08
Message:

If you can find time, can you create the gapless Bollinger Band indicator on a gapless slow stochastics indicator, with the BBs in relation to the slow stochastics and not price? Would like it as an indicator on indicator type of plot for underneath price, of course the slow stochastics will be related to price, but the BBs will only be in relation to and around the slow stochastics, both gapless. On a previous indicator, probably wasn't clear about it myself, but was looking for the same thing with the gapless BB indicator around and only related to the gapless RSI as an indicator on indicator to be viewed underneath, and not overlayed or with the gapless BBs related to price but just the gapless RSI. Here's the previous code for that-can you modify it a little so the gapless BBs aren't just moving with price...only with the gapless RSI? Thanks, JDM



Reply author:jimpeg
Replied on:07/10/2010 23:38:08
Message:

jdm- great work- thanks!

Reply author:clbradley17
Replied on:07/11/2010 04:21:10
Message:

What I'm asking for is a regular BB indicator on gapless indicator, regular BBs that moves just with the gapless slow stochastics in the same code, and similarly another version of the code above with regular BBs that are only relative to and move with the gapless RSI instead of price. Thanks again for all your work, this thread and what you've done is definitely one of the best and most helpful technical anlaysis I've seen on TS in years.

Reply author:hmal
Replied on:07/12/2010 09:40:57
Message:

JDM,

hmmm...was thinking about it and what me and some others were wanting was already here. operator error.

Thanks


Reply author:JDM
Replied on:07/13/2010 00:43:07
Message:

clbradley,

I'll be out of town until the 19th. I should be able to get what you want when I get back.

Regards, JDM


Reply author:clbradley17
Replied on:07/24/2010 13:06:53
Message:

Hope you're back and well JDM. Can you help with the codes?

Reply author:JDM
Replied on:07/25/2010 03:37:30
Message:

quote:
Originally posted by clbradley17
What I'm asking for is a regular BB indicator on gapless indicator, regular BBs that moves just with the gapless slow stochastics in the same code, and similarly another version of the code above with regular BBs that are only relative to and move with the gapless RSI instead of price.


clbradley17,

I believe I understand what you're after. A gapless Slow Stochastic with the overbought and oversold bands replaced with BB upper and lower bands. The same for RSI. If that's right, then here it is:



Slow Stochastic Code:



RSI Code:



ELD made with TS 8.8
Attachment:DATA/20100725033136GL.ELD 13263 bytes

It can be normalized too if you like with the upper and lower bands flat while the Stoch and RSI curves are streched to still cross at the same locations.

JDM


Reply author:clbradley17
Replied on:07/25/2010 09:23:03
Message:

Thanks very much JDM. Did want to keep the overbought and oversold lines and colors for these instead of using the BBs for that, still keeping the BBs moving in relation to the indicator.
For both codes, had to replace the (mean); after WtMean from the last line in the top Vars; section with (third*(high+low+close)); instead from the original GL RSI and GL sto slow codes to get them to verify, not sure if it's because I have TS 8.6 or not.

Maybe because it's a lagging indicator, but although I have both these on my charts and they help a lot, with all the gaps at the open this week, it was the Gapless MACD that bounced the least and mainly kept me in the right direction, would like to do this with BBs around gapless MACD too. Here's what I came up with for that:




Seems like I'm missing something here though, want to keep the MACD, MACDavg, diff and zero line for this, just with BBs around and in relation to the gapless MACD indicators and not price, maybe it's ok to use the BBs as overbought and oversold for this macd one, but would like to see and gauge the regular overB & overS lines and colors for the RSI and Stochastics ones above, at 30/70 and 20/80 respectively, still with the BBs moving in relation to those indicators. Thanks again for all your great work. Just tested the MACD BB code I posted, and it's not recognizing the word "Price" in the // Gapless - end section in the If Price lines.


Reply author:clbradley17
Replied on:07/25/2010 10:33:09
Message:

Added the overbought and oversold lines' plots and colors for the RSI BB and Slo Sto BB indicators above, only needed those 2 plot lines for the stochastics code, had to change it some for the RSI. You can change the indicator and other line colors to whatever you like with "format indicator".

Slow Stochastics code:



RSI code:




Attachment:DATA/20100725105530SP500-7-16-23-GaplessIndicators.PNG 45484 bytes


Reply author:JDM
Replied on:07/25/2010 19:06:41
Message:

quote:
Originally posted by clbradley17
Seems like I'm missing something here though, want to keep the MACD, MACDavg, diff and zero line for this, just with BBs around and in relation to the gapless MACD indicators ...


This should do it:




Reply author:clbradley17
Replied on:07/26/2010 14:07:48
Message:

Thanks so much JDM! I added OverBColor( Red), OverSColor( Cyan); after NumDevsDn( -2), also needed to take out the extra parentheses above and below the Color Criteria section to get that to work, and changed the line colors and the MACDdiff to a histogram. Here's the code:




Attachment:DATA/20100726141351SP500-15Min-7-16-26-GaplessMACDBB.PNG 38470 bytes

Works and looks great...thanks again, JDM.


Reply author:mudbutt
Replied on:09/14/2010 05:04:45
Message:

Correlation_gap Indicator.

I like how the inverse divergence showed up on this polt.

Did I code this correctly?

I was curious if applying the gap code would make a difference.
TS correlation vs correlation_gap sure does look different.
I am using the mbC function, not sure if that's causing it look so different.

Question about date[1] <> date: should that line of code be in there?

tks






Reply author:mudbutt
Replied on:09/14/2010 20:20:02
Message:

msb: that makes sense.

I was thinking of how to weight the independent and dependent variables magnitudes, then apply correlation to the vectors. To many ideas, and only ten fingers!
tks


Reply author:mudbutt
Replied on:09/14/2010 22:26:46
Message:

quote:
Originally posted by msb
You could probably make extra money in a circus side-show. I only have eight fingers, but I do have ten toes!


lol


Reply author:groh1
Replied on:09/21/2010 09:58:44
Message:

Hi JDM, Could I ask for your help to please convert to "gapless" two .ELDs both found on page three of this thread:

https://community.tradestation.com/Discussions/Topic.aspx?Topic_ID=36666


The first is by Trend39….the indicator is called: _Dstoch Trigger and the reason that I am not posting the code here is that I am unclear whether you will need to modify any of the functions on this .ELD in addition to the indicator??? The indicator that I am referring to is: 20070906131524_DSTOCH_TRIGGER.ELD

The second is by KnightsInRodanthe and the .ELD is titled: MultiDstoch.ELD.
Again, I am not posting the code because I am not sure if you will need the functions to make the conversion. The indicator that I am referring to is:
2007090709260MULTIDSTOCH.ELD

Any help you could lend would be much appreciated.


Reply author:JDM
Replied on:09/21/2010 11:42:02
Message:

quote:
Originally posted by Fan_Man2007
Hi JDM, Could I ask for your help to please convert to "gapless" two .ELDs both found on page three of this thread:
https://community.tradestation.com/Discussions/Topic.aspx?Topic_ID=36666
quote:


Hi Fan_Man,

Here they are:
Attachment:DATA/20100921113704_DSTOCH TRIGGERGL.ELD 7379 bytes
Attachment:DATA/20100921113721IMULTIPLEDSTOCHGL.ELD 10029 bytes

The only change to either indicator was in the Dstoch function. I renamed it as _DstochGL (gap-less) and inserted the gapless code.




Good Trading,
JDM


Reply author:hptrade
Replied on:12/02/2010 13:38:16
Message:

JDM, Could ypu please add the gapless for this smooth DMI. Thanks
inputs:
Length( 14 ),
ADXTrend( 25 ),
LinearRegLen( 9 );

variables:
oDMIPlus( 0 ),
oDMIMinus( 0 ),
oDMI( 0 ),
oADX( 0 ),
oADXR( 0 ),
oVolty( 0 ) ;

Value1 = DirMovement( H, L, C, Length, oDMIPlus, oDMIMinus, oDMI, oADX, oADXR,
oVolty ) ;

Plot1( LinearRegValue( oDMIPlus, LinearRegLen, 0 ), "DMI+" ) ;
Plot2( LinearRegValue( oDMIMinus, LinearRegLen, 0 ), "DMI-" ) ;
Plot3( LinearRegValue( oADX, LinearRegLen, 0 ), "ADX" ) ;

{ Alert criteria }
if Plot3 > ADXTrend then
begin
if Plot1 crosses over Plot2 then
Alert( "Bullish alert" )
else if Plot1 crosses under Plot2 then
Alert( "Bearish alert" ) ;
end ;


{ ** Copyright (c) 1991-2003 TradeStation Technologies, Inc. All rights reserved. **
** TradeStation reserves the right to modify or overwrite this analysis technique
with each release. ** }


Reply author:TradingDude
Replied on:12/02/2010 15:08:19
Message:

quote:
Originally posted by hptrade
JDM, Could ypu please add the gapless for this smooth DMI. Thanks
inputs:
Length( 14 ),
ADXTrend( 25 ),
LinearRegLen( 9 );

variables:
oDMIPlus( 0 ),
oDMIMinus( 0 ),
oDMI( 0 ),
oADX( 0 ),
oADXR( 0 ),
oVolty( 0 ) ;

Value1 = DirMovement( H, L, C, Length, oDMIPlus, oDMIMinus, oDMI, oADX, oADXR,
oVolty ) ;

Plot1( LinearRegValue( oDMIPlus, LinearRegLen, 0 ), "DMI+" ) ;
Plot2( LinearRegValue( oDMIMinus, LinearRegLen, 0 ), "DMI-" ) ;
Plot3( LinearRegValue( oADX, LinearRegLen, 0 ), "ADX" ) ;

{ Alert criteria }
if Plot3 > ADXTrend then
begin
if Plot1 crosses over Plot2 then
Alert( "Bullish alert" )
else if Plot1 crosses under Plot2 then
Alert( "Bearish alert" ) ;
end ;


{ ** Copyright (c) 1991-2003 TradeStation Technologies, Inc. All rights reserved. **
** TradeStation reserves the right to modify or overwrite this analysis technique
with each release. ** }


DMI is here posted at: Posted - 06/06/2009 15:09:45

TradingDude



Reply author:JDM
Replied on:12/02/2010 15:28:21
Message:

TD,

Thanks for finding and posting.

JDM


Reply author:hptrade
Replied on:12/02/2010 16:21:11
Message:

TD and JDM, I am currently using the DMI posted on 06/06/2009 which is really superb. I am hoping to get a gapless of DMI smoother version by Javln. Thanks

Reply author:mdl
Replied on:12/07/2010 11:14:36
Message:

to TD or JDM, this threa has been a wonderful addition, and your contributions have been much appreciated. If possible, could you help out with the gapless version of a bull-bear divergence indicator I use.

The code is:

input:avg(20),smooth(5);
var:r1(0),r2(0),bull(0),bear(0);
r1 = iff(c[1]>0, h-l, maxlist(o-c[1],h-l));
r2 = iff(c[1]<0, h-l, maxlist(c[1]-o,h-l));

bull=iff(c=o,
iff(h-c=c-l,
iff(c[1]>o,
maxlist(h-o,c-l),r1),
iff(h-c>c-l,
iff(c[1]maxlist(h-c[1],c-l),
h-o),
r1)),
iff(ciff(c[1]maxlist(h-c[1],c-l),
maxlist(h-o, c-l)),
r1));

bear=iff(c=o,
iff(h-c=c-l,
iff(c[1]maxlist(o-l,h-c),r2),
iff(h-c>c-l,
r2,
iff(c[1]>o,
maxlist(c[1]-l,h-c),
o-l))),
iff(cr2,
iff(c[1]>o,
maxlist(c[1]-l,h-c),
maxlist(o-l, h-c))));

plot1(xaverage(xaverage(bull,avg)-xaverage(bear,avg),smooth),"bbb");



thanks!


Reply author:KingLeonidas
Replied on:04/05/2011 09:56:09
Message:

simple gapless rsi?

Reply author:vpt
Replied on:10/31/2011 13:38:59
Message:

This thread is interesting, could anyone point me in the dirrection of someone who has already converted a Keltner Channel using this method?

Many thanks


Reply author:oxmyx
Replied on:01/27/2012 12:32:08
Message:




Anybody successful applying gapless code to Value Charts?

I tried putting the code into various locations in the function VChart and indicator but am unable to get it to work.

Any good coders that can figure this out?

Thanks!

Indicator:



Function:









Reply author:oxmyx
Replied on:02/01/2012 12:07:12
Message:


Also posted to https://community.tradestation.com/discussions/Topic.aspx?Topic_ID=117351




I tackled it myself.
Here's the updated gapless code for other users.

Indicator:



Function:


Function:





Reply author:paula
Replied on:08/20/2013 07:05:08
Message:

x

Reply author:paula
Replied on:08/20/2013 07:06:37
Message:

quote:
Originally posted by paula
Hi All

Can anyone assist to make the following indicator gapless, please?

regards

Paula


Input:
Price(TypicalPrice),
CMOLen(45),
VIDYALen(20),
UBandPct(.18),
LBandPct(.18),
Speed(2);

Var: PlotVal(0);

PlotVal = VIDYA(Price,CMOLen,VIDYALen, Speed);

If PlotVal > 0 then begin

//Plot1(PlotVal,"VIDYA");
Plot2((1 + UBandPct*.01)*PlotVal,"Upper Band");
Plot3((1 - LBandPct*.01)*PlotVal,"Lower Band");
End;



Input: Price(numericseries), CMOLen(numeric), VIDYALen(numeric),
Speed(numeric);

Var: Cnt(0),SumUp(0), SumDn(0), Diff(0),VIDYAPri(0),AbsCMO(0),Const(0);

SumUp = 0;
SumDn = 0;

For Cnt = 0 to CMOLen-1 Begin
Diff = Price[Cnt] - Price[Cnt+1];
If Diff > 0 then SumUp = SumUp + Diff else SumDn=SumDn-Diff;
End;

AbsCMO = Speed*AbsValue((SumUp-SumDn)/(SumUp+SumDn));
Const = 2/(VIDYALen+1);

VIDYA = iff(Barnumber>VIDYALen,(Price*Const*AbsCMO) +
((1-AbsCMO*Const)*VIDYA[1]),Price);


Reply author:pwald
Replied on:09/10/2013 16:10:14
Message:

Oxmyx, I have taken the liberty to combining all of your adapted code and functions into a ELD whilst adding an alert and fiddling with the colouring of the bars.. Verifies OK and plots well for me - many thanks to you and JDM for an excellent piece of work..
Attachment:DATA/20130910185112VALUE CHART GAPLESS.ELD 16077 bytes


Reply author:AVERA
Replied on:12/26/2013 07:40:33
Message:

ANY ONE HAVE ANY IDEA FOR GAPPLEESS THIS INDICATOR??:

variables:
uExtreme(0),
lExtreme(0);

Value2 = TTI_ATREx_1(40, 14, 200,3, uExtreme, lExtreme) ;
Value1 = uExtreme;
Value3 = lExtreme;

Plot1( Value1, "uExtreme Ex" ) ;
Plot2( Value2, "ATR Ex" ) ;
Plot3( Value3, "lExtreme" ) ;

FUNCTION: