Monday, April 6, 2020

Trading for a living - 3 screens and My 3 Fatal Mistakes

Trading for a living - 3 screens


1) Identify trend

2) tactical decision to enter trade
when weekly trend is UP, wait for pullback on intermediate to enter and VICEVERSA

Tools:Oscillators like RSI,STOCH


3) Enter with Stops

Dont risk more than 2% on any trade.



3 fatal mistakes

 

1) Not using stops

2) put on trades that are too large for the account size. Not falling 2% rule. You must know the maximum level of risk

3) Over trading. Getting carried away

Trading for a living - Power and Inertia - Your censor!

Power and Intertia provides censorship

They tell whether to go or no-go.

Falling/Rising EMA - Inertia

MACD histogram - Power

EMA +       MACD +             Means   BUY/go long ||   Absoluletly   DON'T SHORT

EMA -       MACD -             Means   Short ||   Absoluletly   DON'T go Long

EMA +      MACD -             can long/short

EMA -      MACD +             can long/short

Trading for a living - Dont gamble

Before you enter a trade, write down three numbers
1) entry
2) target
3) stop

Without this, it is gambling.

Set profit targets on Intermediate + 1 chart and stops  on your Intermediate chart.


If day trading, use 25 min chart as intermediate for target and 5 minute chart for stops.


One of the popular stop techniques is to use ATR


Trading for a living - What indicators to look in a trade

Decide where to trade - Daily, long or intra-day.

The period you chose to trade is the intermediate period. Once you decide the period, don't open it as a first analysis screen. This is important. Because your first analysis always throws a bias.

Go one level down and open the chart. If intermediate is daily, open Weekly. If intraday,open daily.

If daily, check the Weekly(1 above) chart to get the trend
  (1) first step to identify the trend.You can rely on 200 EMA to get long term and 50 EMA to slightly shorter. If the price is above, it is bullish and if below , it is bearish

 (2) next, go to daily to decide when to enter. The goal is always to get a good price. MACD histogram is good tool. Ideal is when below zero and rising.

(3) go to intraday, check the oscillators. Stochastic and RSI are popular.

Always wait for a pullback when entering bullish.

Other indicators on daily, could be ADX when it is rising from 20 range.

DONT check RSI , stochastic for long term analysis. These are primarily oscillator indicators.







tidbit: Long is usually 5 times duration than intermediate. If intermediate is daily, then long is weekly. If intermediate is 5 mins, then long is 25 mins.

Trading for a living

Dont risk more than 2% for any trade

Opening and Closing Price
Opening Price reflect the amateur's interest. Professionals use that and build their trade for the day.
Opening prices most often occur near the high or lows of the daily bar
Amateurs are active during the morning and early in the week while Professionals are most active at the closing.
Dont risk more than 2% for any trade
Opening Price reflect the amateur's interest. Professionals use that and build their trade for the day.
Opening prices most often occur near the high or lows of the daily bar
Amateurs are active during the morning and early in the week while Professionals are most active at the closing.
Closing price  are for the professionals. Professional set the price.
Trend Following indicators

Closing price  are for the professionals. Professional set the price.
Trend Following indicators
MACD is trend following. Trend following indicators are lagging indicators
Other trend following indicator : On Balance Volume, Accumulation/Distribution

Oscillators:
Help identifying turning points. Stochastic is a popular oscillator.RSI is another, Williams %R. Oscillators are leading indicators that turn ahead of price movement.

If Indicators signals are not clear. Leave them and move to another.

EMA - 22 EMA is one of the best because there are usually 22 trading days in a month.

MACD
1) calculate 12 day EMA of closing prices
2) calculate 26 day EMA of closing prices
3) Substract 26 day EMA from the 12 day EMA and draw a line.This is MACD fasline
4) Calculate 9 day EMA of the fastline and plot the result as a dashed line.This is the slow signal line.
MACD: When the fast moving EMA on MACD crosses the Slow moving EMA and goes up, it means the bulls are dominating and it is good to go long. When the Slow moving EMA on MACD crosses the fast moving EMA and goes up, it means bears are dominating.

MACD Histogram - Difference between MACD line and Signal line. Histogram gives an early signal before the crossover like a squeeze.


ADX - Directional indicator
1. Trade only from the long side when the positive Directional line is above the
negative one. Trade only from the short side when the negative Directional line
is above the positive one. The best time to trade is when the ADX is rising, 
showing that the dominant group is getting stronger.
2. When ADX declines, it shows that the market is becoming less directional. There
are likely to be many whipsaws. When ADX points down, it is better not to use
a trend-following method.
3. When ADX falls below both Directional lines, it identifies a flat, sleepy mar-
ket. Do not use a trend-following system but get ready to trade, because major
trends emerge from such lulls.

Accumulation/Distribution is more finely calibrated than OBV because it credits
bulls or bears with only a fraction of each day’s volume, proportionate to the degree
of their win for the day.

Wednesday, July 2, 2008

To Calculate size of table

By default, DB2 uses the following values for primary space allocation of DB2–managed data sets:
1 cylinder (720 KB) for non-LOB table spaces
10 cylinders for LOB table spaces
1 cylinder for indexes

How to calculate the size of Index:
I had been using Approach 1 across various DB2 UDB projects , other alternates are listed below Approach 1 ------------ Index Space Size = (average index key size + 8) * no of rows * 2 Approach 2 ------------ Index size estimation : Avg Sum of column widths * Expected no of rows
Approach 3 ------------- Use Control center

I've planned to use the following steps to determine the DMS tablespace size. Pls correct me if I'm wrong else pls give your ack.
Think Scenario:For a single table I've deceided to use a seperate tablespaces for Index & Data. hence
Table Size = Avg Byte count per Row * No. of rows
Avg Byte count per Row is derived using this query after runing the runstats against that table.
SELECT sum(AVGCOLLEN) FROM SYSCAT.COLUMNS where tabname='TestTable'

Hence in my case the mathematics involved is as follows..
Table Size = Avg Byte count per Row * No. of rows= 262 * 132800000
= 34793600000 bytes= 32.40406513214 GB

Can you please let me know whether this inference is correct ? Any suggestions highly appreciated.

DB2 Space ManagementObjects are stored in data files which are logically grouped in tablespaces. If you choose Database Managed Tablespace(DMS), then when the size you allocated to associated data files is over, you have to increase by desired amount. If it is System Managed Tablespace(SMS), then DB2 every time data files space is over, additional extents are allocated. This repeated allocation & OS checks lead to less performance.
The smallest unit of database storage is page whose sizes are like 4K, 8K, 16K, 32K etc. A number of these are contained in an OS block.
In windows when the drive closes & in UNIX the max folder/file size is exceeded, functioning stops till you clear some space.
In RAM, buffer pools exist having buffer size which should be same as page size of tablespace to which this bufferpool is assigned.
Only table & index need space for data else for all objects only definition is stored for which very less space is required.
Table, index & temporary tablespace sizes are calculated as follows:
Table size = ((Average row size * number of rows) + 8) * 1.5
Index Size = ((Average key size * number of rows) + 8) * 2
Temporary tablespace size = ((Average key size * number of rows) + 8) * 3.2
The unit will be bytes.Average row/key size for table/index can be got by right click on given table/index and choosing estimate size option.
The other way is total the bytes of all columns keeping 75% of varchar columns.
For temporary tablespace, group function columns like max, avg etc., group by and order by have to be considered since sorting is involved.
Apply the formula for each such set. 1.5, 2 & 3.2 are buffer multipliers.
Along with size, growth also needs to be estimated initially on project basis & later based on actual results.
To store objects & data which will be read only one can use SMS. But for growing database i.e. tablespaces i.e. datafiles i.e. bufferpools i.e. buffers, one has to select a DMS tablespace with optimum size balancing between maintainence & performance.
ReplicationYes, DB2 supports both synchronous & asynchronous and uni & bi-directional replication.
Synchronous means both source & target will be continuously in sync where as asynchronous implies periodaically.
Uni means one is source & the other target.
Bi means both are source & both are target.

SQL CompliantDB2 obeys/follows ANSI SQL 99 standards.User ManagementWhat ghp7000 said is true about this. DB2 can have only OS users & no database users. Hence number of users allowed by OS can become a limit. And off course the resources that are allocated to a OS user like part of RAM can decided the upper limit for their count. You can check Appendix G i.e. SQL limits in SQL Reference for the OS & DB2 type & version obtainable as a PDF from IBM DB2 site.
For estimating index and tablespace size in db2 i used the formula ------------------------------------------------------------------------------
1) Average Row Size: The average row size is the sum of the average column sizes
2) For each user table in the database, the number of 4 KB pages can be estimated by calculating: ROUND DOWN(4020/(average row size + 10)) = records_per_page
3) Then use records_per_page with: (number_of_records/records_per_page) * 1.1 = number_of_pagesThe factor of "1.1" is for overhead
4)For each index, the space needed can be estimated as: (average index key size + 9) * number of rows * 2

Tuesday, July 1, 2008

DSNUPROC - Invocation of DB2 utility by using the supplied JCL procedure

First of all,
What is a utility versus other popular terms such as “tool” and “solution.”
A utility is a single purpose batch program for moving and/or verifying database pages; examples include LOAD, UNLOAD, REORG, CHECK, COPY, and RECOVER.
A database tool is a multi-functioned program designed to simplify database monitoring, management, and/or administration tasks.
A solution is a synergistic group of tools and utilities designed to work together to address a customer’s business issue.

DSNUPROC is a JCL Supplied procedure to invoke DB2 Online Utilities.
This procedure uses the parameters that you supply to build an appropriate EXEC statement that executes an online utility.To execute the DSNUPROC procedure, write and submit a JCL data set .In your JCL, the EXEC statement executes the DSNUPROC procedure

At a minimum you will need utilities:
to backup your data
to recover and restore your backups
to reorganize inefficient database objects
to collect database object statistics
to manipulate statistics in the DB2 Catalog
to load and unload data
to check for data integrity problems

Currently IBM only offers one choice to its customers: buy all of the DB2 utilities or none of them. So, DB2 shops have to decide whether they will buy and run IBM’s utilities, or use a competing set of utilities. The ISVs offer more flexibility, though. For example, you could buy your REORG and UNLOAD from BMC, your CHECK and COPY from Computer Associates, your LOAD from CDB, etc. It is not an all-or-nothing proposition. But you will need to make sure you have the entire suite of utility functionality covered.

Sample DSNUPROC :

//STEP1 EXEC DSNUPROC,UID='SMPLUNLD',UTPROC='',SYSTEM='DB8A'
//STEPLIB DD DSN=DB8A.DSN810.SDSNLOAD,DISP=SHR
//SYSREC DD DSN=TSOBZMA.#TS#.UNLOAD,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(2,1))
//SYSPUNCH DD DSN=TSOBZMA.LDCARD(#TS#),DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
UNLOAD TABLESPACE #SCHEMA#.#TS#
DELIMITED CHARDEL '#' COLDEL ';' DECPT '!'
FROM TABLE TSOTZMA.FRAUDACCTSUM
/*


Sample listing of supplied JCL procedure DSNUPROC
//DSNUPROC PROC LIB='DSN!!0.SDSNLOAD',
// SYSTEM=DSN,
// SIZE=0K,UID='',UTPROC=''
//********************************************************************
//* PROCEDURE-NAME DSNUPROC
//* *
//* DESCRIPTIVE-NAME: UTILITY PROCEDURE *
//* *
//* FUNCTION: THIS PROCEDURE INVOKES THE ADMF UTILITIES IN THE *
//* BATCH ENVIRONMENT *
//* *
//* PROCEDURE-OWNER: UTILITY COMPONENT *
//* *
//* COMPONENT-INVOKED: ADMF UTILITIES (ENTRY POINT DSNUTILB). *
//* *
//* ENVIRONMENT: BATCH *
//* *
//* INPUT: *
//* PARAMETERS: *
//* LIB = THE DATA SET NAME OF THE DB2 PROGRAM LIBRARY. *
//* THE DEFAULT LIBRARY NAME IS PREFIX.SDSNLOAD, *
//* WITH PREFIX SET DURING INSTALLATION. *
//* SIZE = THE REGION SIZE OF THE UTILITIES EXECUTION AREA.*
//* THE DEFAULT REGION SIZE IS 2048K. *
//* SYSTEM = THE SUBSYSTEM NAME USED TO IDENTIFY THIS JOB *
//* TO DB2. THE DEFAULT IS "DSN". *
//* UID = THE IDENTIFIER WHICH WILL DEFINE THIS UTILITY *
//* JOB TO DB2. IF THE PARAMETER IS DEFAULTED OR *
//* SET TO A NULL STRING, THE UTILITY FUNCTION WILL *
//* USE ITS DEFAULT, USERID.JOBNAME. EACH UTILITY *
//* WHICH HAS STARTED AND IS NOT YET TERMINATED *
//* (MAY NOT BE RUNNING) MUST HAVE A UNIQUE UID. *
//* UTPROC = AN OPTIONAL INDICATOR USED TO DETERMINE WHETHER *
//* THE USER WISHES TO INITIALLY START THE REQUESTED*
//* UTILITY OR TO RESTART A PREVIOUS EXECUTION OF *
//* THE UTILITY. IF OMITTED, THE UTILITY WILL *
//* BE INITIALLY STARTED. OTHERWISE, THE UTILITY *
//* WILL BE RESTARTED BY ENTERING THE FOLLOWING *
//* VALUES: *
//* RESTART(PHASE) = RESTART THE UTILITY AT THE *
//* BEGINNING OF THE PHASE EXECUTED *
//* LAST. *
//* RESTART = RESTART THE UTILITY AT THE LAST *
//* OR CURRENT COMMIT POINT. *
//* *
//* OUTPUT: NONE. *
//* *
//* EXTERNAL-REFERENCES: NONE. *
//* *
//* CHANGE-ACTIVITY: *
//* *
//**********************************************************************
//DSNUPROC EXEC PGM=DSNUTILB,REGION=&SIZE,
// PARM='&SYSTEM,&UID,&UTPROC' //STEPLIB DD DSN=&LIB,DISP=SHR
//**********************************************************************
//* *
//* THE FOLLOWING DEFINE THE UTILITIES' PRINT DATA SETS *
//* *
//**********************************************************************
//* //SYSPRINT DD SYSOUT=*
//UTPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//*DSNUPROC PEND REMOVE * FOR USE AS INSTREAM PROCEDURE