ProRealCode - Trading & Coding with ProRealTime™
Can this be of help ? TRSMA – TREMA – TRWMA
will you not get gaps (could be big at times?) at most market open where the price IG have been quoting (while ‘official’ markets closed) has changed from official market close? Will these gaps affect your Indicators and / or Reject your Trading Systems?Hi – well its far past coffee time in this part of the world > past dinner time here. But yes definitely would get gaps, and i would like them personally (For official markets open) – it would only help and not hinder/reject indicators. Gapping itself (if big eg. 2% up at offical HK market open, from yesterdays close) would make most of the indicators (and various moving averages etc..) all suggest a strong price movement and a Bullish market to open Long on that conditions for day-trading. This would be how normal markets occur – when you watch any business news on TV they almost always say something like “the market is up 1% today” to suggest the conditions? Instead on a 24hr chart the market for example the market could also be up 2% from yesterday but indicators saying the markets is “bearish conditions” cos of the bigger price movements that come from USA Indices (US market movement) the night prior to Asia markets opening the next morning. The example i shared the screenshot from HK market it did gap up (although small of about 0.5%) from yesterdays close, so if anything would be to go for a LONG position if Technical Indicators calculated ONLY on trading hours, other indicators like the moving average went up too to also suggest a Bullish market. But however “Movements”/ Trend strength indicators (from the ETF/ only trade hour) like ADX showed the market was weak, so no trade, which appears correct looking at market. BUT when go over to on a 24hr chart with its pseudo price movements then my indicators on that example instead showed a ‘Downward’ trend because the price went up lots during the US markets hours (cos HK closed it just followed US Indices movements) and as such technical indicators calculating from that ‘incorrectly think’ the markets going down at open but its not it’s up (gapped up 0.5%). It also incorrectly thinks it’s “Strong” because compared to “0” trade volumes and “0” movements that occurred when no global markets were open in the prior 4-odd hours the trend is strong (relative). In hindsight on one example to illustrate the issue i am facing. I would assume also that the academic’s, qaunt’s or investment bankers that studied the various technical indicators they created would of done so on normal markets conditions without ’24hr charting extensions’ that IG does ?
// Because 24hrs charts contain data from when the specific instrument or equity isnt trading on markets, and are just using charting extension or using other markets data instead, and is possible source of error in computation of indicators compared to 'real data' from market time. This is using the bars of when the market, and its pre/post (aka equities futures) markets are open for a more accurate ADX, and Directional movements computations using only bars within the set time-frame.
// Time Range ADX
Periods = 14
//**-- Adjusted for the USA market --**
//Pre and Post Market Hours
FuturesStartTime = 090000
FuturesEndTime = 163000
//Only regular markets hours:
StartTime = 093000 // Pre Market Open
EndTime = 160000 // Post Market Clos
// Calculate the +DM and the -DM
// IF opentime[1] >= FuturesStartTime AND opentime <= FuturesEndTime THEN
IF opentime[1] >= StartTime AND opentime <= EndTime THEN
plusDM = max(high-high[1], 0)
minusDM = max(low[1]-low, 0)
IF plusDM > minusDM THEN
minusDM = 0
ENDIF
IF plusDM < minusDM THEN
plusDM = 0
ENDIF
IF plusDM = minusDM THEN
plusDM = 0
minusDM = 0
ENDIF
endif
// Compute the directional indicators
// Set intial values to 0
plusDI = 0
minusDI = 0
i = 0
// start counting ABS of plusDI and minusDI for [j] during trade times
FOR j = 0 TO 3000
// IF opentime[j] >= FuturesStartTime AND opentime[j] <= FuturesEndTime THEN
IF opentime[j] >= StartTime AND opentime[j] <= EndTime THEN
i = i + 1
plusDI = plusDI + plusDM[j]
minusDI = minusDI + minusDM[j]
IF i = Periods THEN
BREAK
ENDIF
ENDIF
NEXT
// IF opentime >= FuturesStartTime[1] AND opentime <= FuturesEndTime THEN
IF opentime >= StartTime[1] AND opentime <= EndTime THEN
// Compute the DI's using the periods during the trade hours from earlier
TTTR=max(abs(high-close),max(abs(low-close),range))
TTATR=average[periods](TTTR)
endif
plusDI = 100*(plusDI / Periods)/TTATR
minusDI = 100*(minusDI / Periods)/TTATR
DirectionalIndex = plusDI-minusDI
// Compute the ADX's using the periods during the trade hours from earlier
IF opentime >= StartTime[1] AND opentime <= EndTime THEN
TTADX=100*average[periods](abs(plusDI - minusDI)/(plusDI + minusDI))
TTADXR=(TTADX+TTADX[14])/2
endif
//ENDIF
if time>=StartTime and time<=EndTime then
backgroundcolor(10,255,10, 30)
endif
if time>FuturesStartTime and time<=FuturesEndTime then
backgroundcolor(250,244,42,50)
endif
// Graph this data:
Return plusDI as "DI+", minusDI as"DI-", DirectionalIndex style (histogram) as "DI", TTADX as "ADX", TTADXR as "ADXR", 23, 0
without ’24hr charting extensions’ that IG does
Have you tried using separate data display settings for each Instrument you Trade … see attached at red arrowhead?separate data display settings for each Instrument you TradeThanks, that actually would be a lot easier then re-coding every single indicator. BUT will come with an extra cost of 0.5% fee’s when using the US Indices instrument in your example ( aka USD-based chart), instead of ‘CFDA’ instrument choice (Australian/AUD based CFDs) : “CFDs traded in a currency other than your account’s base currency incurs a currency conversion charge of 0.5%” . – IG Australia But changing to a USA-denominated Futures Chart does indeed make the technical indicators look more accurate, with both my coded above and the in-built look more similar now (image-1 attached). Although they are still different at some points, unsure why this difference is there if the functions are calculating correctly thus giving the same values ¯\_(ツ)_/¯.
‘CFDA’ instrument choice (Australian/AUD based CFDs) :Adjusting times isn’t possible for the CFDA’s instrument neither, because for some odd reason CFDA’s Local market time-zone on PRT is UTC +1:00 (London time) > which in itself is just useless (and creates a big problem) as Australian AEST is 9 hours ahead of London time. So even if i could adjust it, i cant because most of the Asian pre-markets start before the 00:00 (UTC +1:00). Doing this way i could, changing the display/market data to start from 00:00 London time, could probably be the best option?
Have you tried and what, you get a message saying
Periods = 100
YesterdayObvClose = 0
//Only regular markets hours:
StartTime = 093000
EndTime = 160000
//If want to use bars from Futures Markets also:
FuturesStartTime = 040000
FuturesEndTime = 200000
TradeTimes = ( time => StartTime AND time <= EndTime )
// The functions that compute On-Balance Volume Value
IF opentime >= StartTime AND opentime <= EndTime THEN
//IF opentime >= FuturesStartTime AND opentime <= FuturesEndTime THEN
IF close > close[1] then
OBVol = OBVol[1] + Volume[1]
elsif close < close[1] then
ObVol = ObVol[1] - Volume[1]
elsif close = close[1] then
OBVol = ObVol[1]
endif
endif
// Start the counting for the average of the OBV from within trade time bars, for the oscillator
i = 0
TTSMA = 0
FOR j = 0 TO 3000
IF opentime >= StartTime[j] AND opentime <= EndTime[j] THEN
//IF opentime >= FuturesStartTime[j] AND opentime <= FuturesEndTime[j] THEN
i = i + 1
TTSMA = TTSMA + OBVol[j]
IF i = Periods THEN
BREAK
ENDIF
ENDIF
NEXT
IF opentime >= StartTime AND opentime <= EndTime THEN
TTSMA = (TTSMA / Periods)
endif
//Out of trade times need to keep the OBV value from Close time until the next days Start Time
OBVClose = 0
OBVClosen = (17.5)*4 //17.5 hrs from close to next day open, Bars Back for a 15min chart
OBVClosei = 1
If opentime >= EndTime OR opentime <= Starttime THEN
WHILE OBVClosei < OBVClosen DO
IF opentime[OBVClosei] = EndTime THEN
OBVol = OBVol[OBVClosei] // Save the CLOSE value for OBV
TTSMA = TTSMA[OBVClosei] // Save the Close value of SMA of OBV
BREAK
ENDIF
OBVClosei = OBVClosei + 1 // Keep counting
WEND
endif
// OBV Oscillator options:
Diff = OBVol - TTSMA
//Perc = Diff/TTSMA*100
RETURN Diff STYLE(histogram,2) AS "OBV Oscillation", 0
// Time Range ADX - set for HK market:
Periods = 14
StartTime = 093000
EndTime = 160000
//For markets with lunch breaks
LunchStartTime = 120000
LunchEndTime = 130000
plusDM = max(high-high[1], 0)
minusDM = max(low[1]-low, 0)
IF plusDM > minusDM THEN
minusDM = 0
ENDIF
IF plusDM < minusDM THEN
plusDM = 0
ENDIF
IF plusDM = minusDM THEN
plusDM = 0
minusDM = 0
ENDIF
TTTR=max(abs(high-close),max(abs(low-close),range))
// Compute the directional indicators
// Set intial values to 0
plusDI = 0
minusDI = 0
i = 0
TTATR = 0
// start counting plusDI and minusDI for [j] during trade times
FOR j = 0 TO 3000
// Uncomment the time option used:
// IF opentime[j] >= StartTime AND opentime[j]<=EndTime THEN
// IF opentime >= FuturesStartTime[j] AND opentime <= FuturesEndTime[j] THEN
IF opentime[j] >= StartTime AND opentime[j] <= LunchStartTime OR opentime[j]>=LunchEndTime and opentime[j]<=EndTime THEN
plusDI = plusDI + plusDM[j]
minusDI = minusDI + minusDM[j]
TTATR= TTATR + TTTR[j]
i = i + 1
IF i = Periods THEN
BREAK
ENDIF
ENDIF
NEXT
// Compute the DI's using the periods during the trade hours from earlier
TTATR=TTATR/Periods
plusDI = 100*(plusDI / Periods)/TTATR
minusDI = 100*(minusDI / Periods)/TTATR
DirectionalIndex = plusDI-minusDI
TTADX = 0
i2 = 0
// Compute the ADX's using the periods during the trade hours from earlier
FOR j2 = 0 TO 3000
// Uncomment the time option used:
// IF opentime >= FuturesStartTime[j] AND opentime <= FuturesEndTime[j] THEN
//IF opentime[j2] >= StartTime AND opentime[j2]<=EndTime THEN
IF opentime[j] >= StartTime AND opentime[j] <= LunchStartTime OR opentime[j]>=LunchEndTime and opentime[j]<=EndTime THEN
TTADX = TTADX + (abs(plusDI - minusDI)/(plusDI + minusDI))[j2]
i2 = i2 + 1
IF i2 = Periods THEN
BREAK
ENDIF
ENDIF
NEXT
TTADX=100*(TTADX/Periods)
i3 = 0
TTADXR = 0
FOR j3 = 0 TO 3000
// Uncomment the time option used:
// IF opentime >= FuturesStartTime[j] AND opentime <= FuturesEndTime[j] THEN
// IF opentime[j2] >= StartTime AND opentime[j2]<=EndTime THEN
IF opentime[j] >= StartTime AND opentime[j] <= LunchStartTime OR opentime[j]>=LunchEndTime and opentime[j]<=EndTime THEN
TTADXR = TTADXR + TTADX[j3]
i3 = i3 + 1
IF i3 = Periods THEN
BREAK
ENDIF
ENDIF
NEXT
TTADXR=TTADXR/Periods
// Graph this data:
if opentime>=StartTime AND opentime<=EndTime then
backgroundcolor(10,255,10, 30)
endif
// To Compare to PRT Inbuilts:
// PRTADX = ADX[14]
// PRTDIPLUS = DIPLUS [14]
// PRTDIMINUS = DIMINUS[14]
Return plusDI as "DI+", minusDI as"DI-", DirectionalIndex style (histogram) as "DI", TTADX as "ADX", TTADXR as "ADXR", 23 as "23"
Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.
Indicators use 24hrs and NOT just Trade Hrs Bars > how fix these wrong signals ?
This topic contains 27 replies,
has 4 voices, and was last updated by SkippyTrader
4 years, 2 months ago.
| Forum: | ProBuilder: Indicators & Custom Tools |
| Language: | English |
| Started: | 08/04/2022 |
| Status: | Active |
| Attachments: | 21 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.