% of body fat
breakdown of ldls and hdls
state of kidney and liver health
ask if taking whey protein is ok, 105g daily, if im working out.
Sunday, March 28, 2010
Wednesday, January 27, 2010
Writing a VBScript
'-------------------------
'Functions
'-------------------------
Function WriteRecordSet(aRecordSet,aFile)
Dim lRecordsetString
Dim lngFieldsIndex
Dim lngIndex
Dim lFieldValue
lRecordsetString = ""
lngFieldsIndex= aRecordSet.RecordCount - 1
For lngIndex = 0 to lngFieldsIndex
if lngIndex = 0 then
lRecordsetString = Cstr(aRecordSet.Fields(lngIndex).Name)
else
lRecordsetString = lRecordsetString & "" & Cstr(aRecordSet.Fields(lngIndex).Name)
end if
Next
aFile.WriteLine(lRecordsetString)
lRecordsetString = ""
aRecordSet.MoveFirst
Do While (Not aRecordSet.EOF)
For lngIndex = 0 to lngFieldsIndex
if (aRecordSet(lngIndex).Value = null) Then
lFieldValue = "DBNull"
else
lFieldValue = Cstr(aRecordSet(lngIndex).Value)
end if
if lngIndex = 0 then
lRecordsetString = lFieldValue
else
lRecordsetString = lRecordsetString & "" & lFieldValue
end if
Next
aFile.WriteLine(lRecordsetString)
aRecordSet.MoveNext
Loop
aRecordSet.MoveFirst
End Function
Function WriteArrayOfArray(aArrayOfArray,aFile)
Dim strArray
Dim lngUBound1
Dim lngUBound2
Dim lngIndex1
Dim lngIndex2
lngUBound1 = UBound(aArrayOfArray, 1)
lngUBound2 = UBound(aArrayOfArray, 2)
For lngIndex1 = 0 To lngUBound1
For lngIndex2 = 0 To lngUBound2
strArray = strArray + "[" & lngIndex1 & "," & lngIndex2 & "] = " & aArrayOfArray(lngIndex1, lngIndex2) & vbcrlf
Next
Next
aFile.WriteLine(strArray)
End Function
'-------------------------
'Start of your VB script
'-------------------------
Dim myFSO
Dim myFile
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set myFile= myFSO.OpenTextFile("PadbVBScript.txt", 8, True)
Dim lPADBObject
set lPADBObject = CreateObject("IWebClientServ16.Profile","GMOBOSCRPAPP01R")
lPADBObject.setSqlServer = "GMOBOSCRPSQLR"
lPADBObject.formatOutput = True
Dim lRecordset
set lRecordset = CreateObject("ADODB.Recordset")
Dim lvRet
Dim lArray
set lRecordset = lPADBObject.getBenchmark(4004, "GMOBOSCRPSQLR")
myFile.WriteLine("<<>>")
WriteRecordSet lRecordset,myFile
myFile.WriteLine()
lvRet = lPADBObject.GetCountryWeights(1022,"8/31/2009","GMOBOSCRPSQLR",15,True)
myFile.WriteLine("<<>>")
WriteArrayOfArray lvRet,myFile
myFile.WriteLine()
lvRet = lPADBObject.GetChar(4002,"8/31/2009","GMOBOSCRPSQLR",,Array(4006),1)
lvRet = lPADBObject.toBaseCurrency(4002,"8/31/2009",lvRet,"GMOBOSCRPSQLR",True)
myFile.WriteLine("<<>>")
WriteArrayOfArray lvRet,myFile
myFile.WriteLine()
myFile.Close
set myFile = nothing
set myFSO = nothing
set lPADBObject = Nothing
VBS Functions
'Functions
'-------------------------
Function WriteRecordSet(aRecordSet,aFile)
Dim lRecordsetString
Dim lngFieldsIndex
Dim lngIndex
Dim lFieldValue
lRecordsetString = ""
lngFieldsIndex= aRecordSet.RecordCount - 1
For lngIndex = 0 to lngFieldsIndex
if lngIndex = 0 then
lRecordsetString = Cstr(aRecordSet.Fields(lngIndex).Name)
else
lRecordsetString = lRecordsetString & "" & Cstr(aRecordSet.Fields(lngIndex).Name)
end if
Next
aFile.WriteLine(lRecordsetString)
lRecordsetString = ""
aRecordSet.MoveFirst
Do While (Not aRecordSet.EOF)
For lngIndex = 0 to lngFieldsIndex
if (aRecordSet(lngIndex).Value = null) Then
lFieldValue = "DBNull"
else
lFieldValue = Cstr(aRecordSet(lngIndex).Value)
end if
if lngIndex = 0 then
lRecordsetString = lFieldValue
else
lRecordsetString = lRecordsetString & "" & lFieldValue
end if
Next
aFile.WriteLine(lRecordsetString)
aRecordSet.MoveNext
Loop
aRecordSet.MoveFirst
End Function
Function WriteArrayOfArray(aArrayOfArray,aFile)
Dim strArray
Dim lngUBound1
Dim lngUBound2
Dim lngIndex1
Dim lngIndex2
lngUBound1 = UBound(aArrayOfArray, 1)
lngUBound2 = UBound(aArrayOfArray, 2)
For lngIndex1 = 0 To lngUBound1
For lngIndex2 = 0 To lngUBound2
strArray = strArray + "[" & lngIndex1 & "," & lngIndex2 & "] = " & aArrayOfArray(lngIndex1, lngIndex2) & vbcrlf
Next
Next
aFile.WriteLine(strArray)
End Function
'-------------------------
'Start of your VB script
'-------------------------
Dim myFSO
Dim myFile
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set myFile= myFSO.OpenTextFile("PadbVBScript.txt", 8, True)
Dim lPADBObject
set lPADBObject = CreateObject("IWebClientServ16.Profile","GMOBOSCRPAPP01R")
lPADBObject.setSqlServer = "GMOBOSCRPSQLR"
lPADBObject.formatOutput = True
Dim lRecordset
set lRecordset = CreateObject("ADODB.Recordset")
Dim lvRet
Dim lArray
set lRecordset = lPADBObject.getBenchmark(4004, "GMOBOSCRPSQLR")
myFile.WriteLine("<<
WriteRecordSet lRecordset,myFile
myFile.WriteLine()
lvRet = lPADBObject.GetCountryWeights(1022,"8/31/2009","GMOBOSCRPSQLR",15,True)
myFile.WriteLine("<<
WriteArrayOfArray lvRet,myFile
myFile.WriteLine()
lvRet = lPADBObject.GetChar(4002,"8/31/2009","GMOBOSCRPSQLR",,Array(4006),1)
lvRet = lPADBObject.toBaseCurrency(4002,"8/31/2009",lvRet,"GMOBOSCRPSQLR",True)
myFile.WriteLine("<<
WriteArrayOfArray lvRet,myFile
myFile.WriteLine()
myFile.Close
set myFile = nothing
set myFSO = nothing
set lPADBObject = Nothing
VBS Functions
Monday, January 25, 2010
Finalize and Dispose
References:
Rules for Finalize and Dispose
Finalize and Dispose are all about freeing unmanaged resources such as files, streams, db connections etc. held by objects. While Dispose can be directly called by users of objects, Finalize is called by GC.
Do not assume Dispose will be called by the users/programmers using your object. You should always free up resources in Finalize as a back-up.
Calls must be propagated correctly through containmnet hierarchy i.e.
1. If object A has a reference to object B which in turn has reference to object C, then you must make sure that A.Dispose() code calls B.Dispose() (and B.Dispose() calls C.Dispose()).
2. A.Dispose() should also call A's base type's Dispose() if there is a base type implementing IDisposable.
When a class implements IDisposable, it is basically announcing it is using scarce resources. SAM: So your own object (whether stand-alone, abstract base or derived) can and should implement IDisposable, if it's holding references to unmanaged resources on its own or it contains objects that hold references to unmanaged resources. There is no reason why you can't implement your own IDisposable on an object that derives from another object that already implements that interface. However, depending on stand-alone, abstract or derived class you are coding, you may or may not have to implement your own IDisposable. Bottom line is, calling Dispose() by users should free up all the resources, containment-wise and object hierarchy-wise.
Close() should be a special case of Dispose(). Some unmanaged resources like streams have a state of either "open" or "closed", so it makes sense to provide a Close() method to the users of your class instead of Dispose(). However, calling Close() should internally call Dispose().
Rules for Finalize and Dispose
Finalize and Dispose are all about freeing unmanaged resources such as files, streams, db connections etc. held by objects. While Dispose can be directly called by users of objects, Finalize is called by GC.
Do not assume Dispose will be called by the users/programmers using your object. You should always free up resources in Finalize as a back-up.
Calls must be propagated correctly through containmnet hierarchy i.e.
1. If object A has a reference to object B which in turn has reference to object C, then you must make sure that A.Dispose() code calls B.Dispose() (and B.Dispose() calls C.Dispose()).
2. A.Dispose() should also call A's base type's Dispose() if there is a base type implementing IDisposable.
When a class implements IDisposable, it is basically announcing it is using scarce resources. SAM: So your own object (whether stand-alone, abstract base or derived) can and should implement IDisposable, if it's holding references to unmanaged resources on its own or it contains objects that hold references to unmanaged resources. There is no reason why you can't implement your own IDisposable on an object that derives from another object that already implements that interface. However, depending on stand-alone, abstract or derived class you are coding, you may or may not have to implement your own IDisposable. Bottom line is, calling Dispose() by users should free up all the resources, containment-wise and object hierarchy-wise.
Close() should be a special case of Dispose(). Some unmanaged resources like streams have a state of either "open" or "closed", so it makes sense to provide a Close() method to the users of your class instead of Dispose(). However, calling Close() should internally call Dispose().
Example
==========
[C#]
using System;
using System.ComponentModel;
// The following example demonstrates how to create
// a resource class that implements the IDisposable interface
// and the IDisposable.Dispose method.
public class DisposeExample
{
// A base class that implements IDisposable.
// By implementing IDisposable, you are announcing that
// instances of this type allocate scarce resources.
public class MyResource: IDisposable
{
// Pointer to an external unmanaged resource.
private IntPtr handle;
// Other managed resource this class uses.
private Component component = new Component();
// Track whether Dispose has been called.
private bool disposed = false;
// The class constructor.
public MyResource(IntPtr handle)
{
this.handle = handle;
}
// Implement IDisposable.
// Do not make this method virtual.
// A derived class should not be able to override this method.
// SAM: Comment on "do not make this virtual". True only if the class you are
// writing is the base class like this example. However, a lot of times, you
// would be writing a class, derived from another class (your own or supplied
// by a software vendor) that DOES make this method virtual and rightfully
// so. Look at ActiveReports software example below.
public void Dispose()
{
Dispose(true);
// This object will be cleaned up by the Dispose method.
// Therefore, you should call GC.SupressFinalize to
// take this object off the finalization queue
// and prevent finalization code for this object
// from executing a second time.
GC.SuppressFinalize(this);
}
// Dispose(bool disposing) executes in two distinct scenarios.
// If disposing equals true, the method has been called directly
// or indirectly by a user's code. Managed and unmanaged resources
// can be disposed.
// If disposing equals false, the method has been called by the
// runtime from inside the finalizer and you should not reference
// other objects. Only unmanaged resources can be disposed.
private void Dispose(bool disposing)
{
// Check to see if Dispose has already been called.
if(!this.disposed)
{
// If disposing equals true, dispose all managed
// and unmanaged resources.
if(disposing)
{
// Dispose managed resources.
component.Dispose();
}
// Call the appropriate methods to clean up
// unmanaged resources here.
// If disposing is false,
// only the following code is executed.
CloseHandle(handle);
handle = IntPtr.Zero;
}
disposed = true;
}
// Use interop to call the method necessary
// to clean up the unmanaged resource.
[System.Runtime.InteropServices.DllImport("Kernel32")]
private extern static Boolean CloseHandle(IntPtr handle);
// Use C# destructor syntax for finalization code.
// This destructor will run only if the Dispose method
// does not get called.
// It gives your base class the opportunity to finalize.
// Do not provide destructors in types derived from this class.
~MyResource()
{
// Do not re-create Dispose clean-up code here.
// Calling Dispose(false) is optimal in terms of
// readability and maintainability.
Dispose(false);
}
}
public static void Main()
{
// Insert code here to create
// and use the MyResource object.
}
}
Active Reports Example
========================
Background info: From a client's standpoint, you call a method on a server
class "ProfileSummaryActiveReport" (which you also create but ultimately derive from
vendor's ActiveReports3 class) to render a report with "using". ActiveReport3 class
provides "virtual Dispose (bool disposing)" method. See how I have implemented my
client and server code to free up unmanaged resources and references to objects with
unmanaged resources. I could have implemented my own IDisposable on server class,
but I did not because I did not have to (since ActiveReport3 provided me the virtual
method to override).
Further, I architected "ProfileSummaryActiveReport" class to be simply a collection
of Activereports-provided SubReports. Each subreport is a ActiveReports-provided
tabular textual controls or it could be another vendor called ChartFX' chart control.
Idea is, when the client calls the method on ProfileSummaryActiveReport object
with "using", the Dispose() that fires should then propagate thru all objects in a
meaningful way i.e. call dispose() on each subreports.
//----------------------------------------------------------------------
Client calling
ProfileSummaryActiveReport lProfileSummaryActiveReport = null;
RenderReportResult lRenderReportResult = null;
using (lProfileSummaryActiveReport = new ProfileSummaryActiveReport(
aLogger,
lActiveReportCount,
lPageDataSet,
aReportParams,
pdfParams,
aProfileSummaryDiagnosticsInfo))
{
lRenderReportResult = lProfileSummaryActiveReport.RenderReport();
}
//----------------------------------------------------------------------
Servers
//Write your own server-based active report (must derive from vendor
//supplied class ActiveReport3) that serves as a container for subreports
public partial class ProfileSummaryActiveReport : ActiveReportBase
{
public ListListOfSubReportWrapper = new List ();
public ListListOfPlaceholderSubReportWrapper = new List ();
private void DisposeSubReports()
{
foreach (SubReportWrapper lSRW in this.ListOfSubReportWrapper)
{
lSRW.ARSubReport.Dispose();
}
foreach (SubReportWrapper lSRW in this.ListOfPlaceholderSubReportWrapper)
{
lSRW.ARSubReport.Dispose();
}
if (this.ReportPageFootnotes != null)
this.ReportPageFootnotes.Clear();
if (this.SubReportForcedHeightInfoList != null)
this.SubReportForcedHeightInfoList.Clear();
foreach (KeyValuePairlKVP in this.mDictionaryProfileSummarySubReport)
{
if (lKVP.Value.SubReportDataSet!=null)
lKVP.Value.SubReportDataSet.Dispose();
}
}
//blah blah
}
partial class ProfileSummaryActiveReport
{
///
/// Clean up any resources being used.
///
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (this.mReadyToDisposeSubReportsIfAny)
{
this.DisposeSubReports();
}
}
base.Dispose(disposing);
}
private DataDynamics.ActiveReports.Detail detail;
//blah blah
}
//----------------------------------------------------------------------
public partial class ActiveReportBase : DataDynamics.ActiveReports.ActiveReport3
{
protected System.Data.DataSet mReportData = null;
public byte[] CombineReportsAsPDFByteArray(DictionaryaDictionaryOfReports)
{
DataDynamics.ActiveReports.ActiveReport3 lActiveReport = new ActiveReport3();
int lPageNumber = 0;
foreach (KeyValuePairkvp in aDictionaryOfReports)
{
lPageNumber++;
using (MemoryStream lMemoryStream = new MemoryStream(kvp.Value))
{
this.Document.Load(lMemoryStream);
foreach (Page lPage in this.Document.Pages)
{
lActiveReport.Document.Pages.Add(lPage);
}
}
}
using (MemoryStream lMemoryStream = new MemoryStream())
{
using (PdfExport lPdfExport = new PdfExport())
{
lPdfExport.Export(lActiveReport.Document, lMemoryStream);
}
lMemoryStream.Flush();
lActiveReport.Dispose();
this.mReadyToDisposeSubReportsIfAny = true;
return lMemoryStream.ToArray();
}
}
//blah blah
}
partial class ActiveReportBase
{
///
/// Clean up any resources being used.
///
protected override void Dispose(bool disposing)
{
if (disposing)
{
}
base.Dispose(disposing);
}
private DataDynamics.ActiveReports.Detail detail;
//blah blah
}
//----------------------------------------------------------------------
public partial class GanttChartFX : ProfileSummarySubReportARBase, IBarBasedChart
{
private ChartFX.WinForms.Chart mChart = null;
private DataDynamics.ActiveReports.CustomControl mCustomControl = null;
//blah
}
partial class GanttChartFX
{
///
/// Clean up any resources being used.
///
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (this.mChart != null)
this.mChart.Dispose();
if (this.mCustomControl != null)
this.mCustomControl.Dispose();
}
base.Dispose(disposing);
}
private DataDynamics.ActiveReports.Detail detail;
// blah
}
//----------------------------------------------------------------------
public abstract partial class ProfileSummarySubReportARBase : DataDynamics.ActiveReports.ActiveReport3, IProfileSummarySubReportRenderer, IPlaceholderSubReportHost
{
// blah
}
partial class ProfileSummarySubReportARBase
{
///
/// Clean up any resources being used.
///
protected override void Dispose(bool disposing)
{
if (disposing)
{
}
base.Dispose(disposing);
}
private DataDynamics.ActiveReports.Detail detail;
// blah
}
Wednesday, January 20, 2010
Performance Counters for Memory Issues
Intro:
G e t t i n g S t a r t e d W i t h t h e P e r f o r m a n c e C o u n t e r s
Intro Perf counters 2005
Microsoft archived intro
Vendor Products:
SciTech .NET Memory Profiler: they also have tutorials
Specifics:
Memory perf info
User-Mode Memory Leak
CLR Inside Out: Investigating Memory Issues
SQL Server Related
G e t t i n g S t a r t e d W i t h t h e P e r f o r m a n c e C o u n t e r s
Intro Perf counters 2005
Microsoft archived intro
Vendor Products:
SciTech .NET Memory Profiler: they also have tutorials
Specifics:
Memory perf info
User-Mode Memory Leak
CLR Inside Out: Investigating Memory Issues
SQL Server Related
Monday, January 11, 2010
Total Recorder Drivers - 3 kinds
Total Recorder Drivers
Sam: When recording from internet radio,
(1) go to TR's recording source and parameters and make sure you choose "software" instead of "sound board" for audio recording source.
(2) go to TR's settings->Driver, choose "Kernel-mode filter driver" and "any playback device" under playback and recording.
Selecting the type of driver to be installed with Total Recorder
Total Recorder has three types of audio drivers:
User-mode virtual device driver. This is the same type of driver that has been supplied since the first version of Total Recorder.
Kernel-mode virtual device driver, which was added in version 7.0.
Kernel-mode filter driver, which was added in version 8.0.
When installing Total Recorder, you can select any combination of Total Recorder drivers to be installed, or you can select not to install a driver. It is recommended you choose one of the following configurations during installation:
Simple configuration.
Install Total Recorder with the kernel-mode filter driver only.
This configuration is suitable in most cases because of its ease-of-use, an absence of undesirable effects due to additional drivers, and the main features of software recording, except for accelerated and silent recording, can be used.
Advanced configuration.
For Windows XP:
Install Total Recorder with the user-mode driver and the kernel-mode filter driver.
For Windows Vista and later:
Install Total Recorder with both the kernel-mode drivers (virtual device driver and filter driver).
This configuration provides the ability to use almost all of the features of software recording. More complex Total Recorder settings may be required especially if several sound devices are used.
Restricted configuration
Install Total Recorder without a driver.
If you install Total Recorder without a driver, you will not be able to record in Software mode. An alternative to Software mode recording is to record in Soundboard mode from a line such as "Stereo Mix", "Wave", "What U hear", or similar. Most sound boards have such a line. Installing Total Recorder without a driver may be necessary if you encounter compatibility problems between the Total Recorder drivers and other software.
If you install Total Recorder with more than one driver, you can select which driver Total Recorder uses.
To install or uninstall a driver, you must reinstall Total Recorder over the installed instance and select the appropriate driver options during installation. All of Total Recorder's settings and registration information are preserved except for any settings that are incompatible with the new driver's configuration.
Comparing Different Types of Total Recorder Drivers
User-mode virtual device driver
Advantages
Sound is captured exactly in the same format that is used by an audio player to pass audio data to a sound board.
Sound can be captured from specific applications.
Accelerated recording is faster and more reliable.
Disadvantages
This type of driver is not fully supported by modern operating systems. For Windows XP, you may find incompatibilities with some applications. For Windows Vista and later operating systems, most applications cannot be recorded with this driver. See information below.
Kernel-mode drivers (virtual device driver and filter driver)
Advantages
These drivers are fully compatible with modern operating systems.
The kernel-mode filter driver does not require any change to your system audio settings.
Disadvantages
Sound is captured after it has been processed (mixed, resampled) by the operating system. This results in the following:
- You cannot restrict recording to a particular application.
- Additional conversions of the format may be performed.
- Volume regulators can affect the sound being captured.
Accelerated recording through the kernel-mode virtual device driver is slower and less reliable. Accelerated recording through the kernel-mode filter driver cannot be done at all.
You may experience other problems. For more information, see below.
Advantages of the kernel-mode filter driver over the kernel-mode virtual device driver
The kernel-mode filter driver does not add a sound device in your system whereas the kernel-mode virtual device driver does. When using the kernel-mode filter driver, no special configuration of system audio devices or devices used by a program to be recorded is required.
The kernel-mode filter driver does not result in problems with USB microphones on Windows XP.
Advantages of kernel-mode virtual device driver over the kernel-mode filter driver
The kernel-mode virtual device driver can record in accelerated mode and in silent mode.
If the kernel-mode virtual device driver is used, usually you can configure your system and sound applications so that only the application’s sounds will be recorded. If the kernel-mode filter driver is used, recording a particular application can be achieved only if there is more than one real sound playback device on your system.
After installing the kernel-mode filter driver, a reboot is always required. After installing the kernel-mode virtual device driver, a reboot is not usually required.
Possible Problems with Total Recorder Drivers
Possible problems with Total Recorder's user-mode driver
- Incompatibility with DirectSound
Problems can occur with an application that uses Direct Sound. If such an application passes a sound stream through the driver, the sound may be garbled. For example, distortions often appear when using most versions of Skype 3.x.
- Incompatibility with a small number of applications
A small number of applications may not start at all, or they may function incorrectly, if the driver is set as a system default device. Examples of such applications include CyberLink software (e.g. PowerDVD, PowerProducer) and Adobe software (e.g. Adobe Premiere, Adobe Encore, etc.).
- Partial compatibility with Windows Vista
See this information regarding compatibility issues between the user-mode driver and Windows Vista.
Possible problems with Total Recorder's kernel-mode driver (virtual device driver or filter driver)
- Unable to record a particular application
The system mixes audio streams being played before it arrives in the kernel-mode driver. Audio streams being played can only be recorded in mixed form. This is similar to recording from a line such as "Stereo Mix". It is not possible to single out a stream belonging to a particular application as it could be made using a user-mode driver. All appropriate recording parameters (i.e. Record only streams opened after the recording has started and Record only this application) are disabled.
- Volume regulator affects the level of recording
The volume level of the Wave line affects the level of sound received by the kernel-mode driver. For quality recordings, it is recommended you set the volume level of the Wave line to the maximum position and do not change this level during the recording. You should use the level of the Master line to regulate the sound volume when recording.
Notes:
Most players' volume regulators are connected to the Wave line. You should set the regulator to the maximum position and do not change it during a recording.
The system volume regulator, which is the regulator that appears when you click on the system tray icon, is associated with the Master line. You can adjust it freely while recording.
Under Windows XP, you can also use the volume regulator in Total Recorder's main window to adjust volume. Beginning with version 7.0, this regulator is associated with the Master line rather than the Wave line. Under Windows Vista, you should use only the system volume regulator.
- Accelerated recording through the kernel-mode filter driver cannot be performed
If Total Recorder is set to use the kernel-mode filter driver then Total Recorder cannot record in accelerated recording mode.
- Additional format conversion is sometimes performed
When a playback program passes a sound stream to the sound board, Windows can transform this sound stream to a format supported by your sound board. Total Recorder's kernel-mode driver receives this transformed stream rather than the original stream. The driver does not know the format of the original stream and Total Recorder can display only the format of the transformed stream.
In very rare cases, this conversion can result in a minor loss of quality, although this loss is normally not audible. Since the majority of recordings are performed in a compressed format, the compression results in more loss in quality (even if it is usually not audible) than the conversion.
Possible problems specific to Total Recorder's kernel-mode virtual device driver
- For some sound boards, a sound stream cannot be played through the board while another stream is played through the kernel-mode driver if the driver is set to use the sound board
This restriction can cause some problems:
If an application plays silence continuously and the application cannot be closed, then switching a system default device may require you to restart your system or to log off and on before your sound program will work properly.
You cannot record a particular sound stream by directing the stream to Total Recorder's kernel-mode driver while directing all other sound streams to the real sound board.
Note that this problem does not occur with most sound boards.
- Incompatibility with USB-microphones under Windows XP
Total Recorder's kernel-mode driver does not work with USB microphones under Windows XP. This can result in problems when recording an Internet telephony program, such as Skype. Such programs can be recorded, however this requires some additional setup. For more information, see Total Recorder Help: Troubleshooting -> After installing Total Recorder with the kernel-mode driver, problems occur using a USB microphone.
Note that this problem does not occur on Windows Vista.
- Problems with accelerated recording
The speed of an accelerated recording can be lower when using the kernel-mode driver compared with the user-mode driver. The recorded sound may be garbled even though no problems appeared when the recording was being made. For more information, see Total Recorder Help: Using Total -> Recorder Recording -> Accelerated Recording.
- Driver's recording-level regulator may function improperly
It is possible that the recording level regulator or the volume for specific playback lines of the driver does not work. This depends on the particular sound board. If you encounter this problem, follow these recommendations:
For Windows 2000/XP: Launch the system mixer, and use the controls of the real sound board rather than the controls of Total Recorder's driver.
For Windows Vista: From the Control Panel, click Sounds (or select Options - System settings in Total Recorder's main menu), select the playback or recording device to be used, click the Properties button, and then go to the Levels tab.
- Under Windows 2000/XP, if you record from Total Recorder's kernel-mode driver device, you should manually select the recording line
Total Recorder's kernel-mode driver has only one recording line, called "Microphone". Recording actually occurs through the active recording line of a real sound board. If you find that a recording uses an incorrect line, you should manually select the proper recording line by using the system mixer.
This problem occurs mostly when recording Internet telephony programs, such as Skype. If you only want to record from a sound board, you should record directly from a real sound device rather than from Total Recorder's driver.
- Under Windows Vista, if you record from Total Recorder's kernel-mode driver device, the recording can use an incorrect line
If you use Total Recorder's kernel-mode driver to record from a recording device, sometimes the recording uses an incorrect line. This problem depends on the real soundboard driver.
This problem occurs mostly when recording Internet telephony programs, such as Skype. If you only want to record from a sound board, you should record directly from a real sound device rather than from Total Recorder's driver.
If this problem occurs, take the following steps:
Stop using the recording device, and terminate the Internet-telephony conversation.
From the Control Panel, click Sounds (or select Options - System settings in Total Recorder's main menu), and then go to the Recording tab.
Select a real device (normally a microphone) that should be used for capturing sound, and click the Set Default button
Select Microphone. Total Recorder kernel mode (WDM) audio driver, and click the Set Default button.
Close the Sounds window.
See also:
Primer on PC Audio
Sam: When recording from internet radio,
(1) go to TR's recording source and parameters and make sure you choose "software" instead of "sound board" for audio recording source.
(2) go to TR's settings->Driver, choose "Kernel-mode filter driver" and "any playback device" under playback and recording.
Selecting the type of driver to be installed with Total Recorder
Total Recorder has three types of audio drivers:
User-mode virtual device driver. This is the same type of driver that has been supplied since the first version of Total Recorder.
Kernel-mode virtual device driver, which was added in version 7.0.
Kernel-mode filter driver, which was added in version 8.0.
When installing Total Recorder, you can select any combination of Total Recorder drivers to be installed, or you can select not to install a driver. It is recommended you choose one of the following configurations during installation:
Simple configuration.
Install Total Recorder with the kernel-mode filter driver only.
This configuration is suitable in most cases because of its ease-of-use, an absence of undesirable effects due to additional drivers, and the main features of software recording, except for accelerated and silent recording, can be used.
Advanced configuration.
For Windows XP:
Install Total Recorder with the user-mode driver and the kernel-mode filter driver.
For Windows Vista and later:
Install Total Recorder with both the kernel-mode drivers (virtual device driver and filter driver).
This configuration provides the ability to use almost all of the features of software recording. More complex Total Recorder settings may be required especially if several sound devices are used.
Restricted configuration
Install Total Recorder without a driver.
If you install Total Recorder without a driver, you will not be able to record in Software mode. An alternative to Software mode recording is to record in Soundboard mode from a line such as "Stereo Mix", "Wave", "What U hear", or similar. Most sound boards have such a line. Installing Total Recorder without a driver may be necessary if you encounter compatibility problems between the Total Recorder drivers and other software.
If you install Total Recorder with more than one driver, you can select which driver Total Recorder uses.
To install or uninstall a driver, you must reinstall Total Recorder over the installed instance and select the appropriate driver options during installation. All of Total Recorder's settings and registration information are preserved except for any settings that are incompatible with the new driver's configuration.
Comparing Different Types of Total Recorder Drivers
User-mode virtual device driver
Advantages
Sound is captured exactly in the same format that is used by an audio player to pass audio data to a sound board.
Sound can be captured from specific applications.
Accelerated recording is faster and more reliable.
Disadvantages
This type of driver is not fully supported by modern operating systems. For Windows XP, you may find incompatibilities with some applications. For Windows Vista and later operating systems, most applications cannot be recorded with this driver. See information below.
Kernel-mode drivers (virtual device driver and filter driver)
Advantages
These drivers are fully compatible with modern operating systems.
The kernel-mode filter driver does not require any change to your system audio settings.
Disadvantages
Sound is captured after it has been processed (mixed, resampled) by the operating system. This results in the following:
- You cannot restrict recording to a particular application.
- Additional conversions of the format may be performed.
- Volume regulators can affect the sound being captured.
Accelerated recording through the kernel-mode virtual device driver is slower and less reliable. Accelerated recording through the kernel-mode filter driver cannot be done at all.
You may experience other problems. For more information, see below.
Advantages of the kernel-mode filter driver over the kernel-mode virtual device driver
The kernel-mode filter driver does not add a sound device in your system whereas the kernel-mode virtual device driver does. When using the kernel-mode filter driver, no special configuration of system audio devices or devices used by a program to be recorded is required.
The kernel-mode filter driver does not result in problems with USB microphones on Windows XP.
Advantages of kernel-mode virtual device driver over the kernel-mode filter driver
The kernel-mode virtual device driver can record in accelerated mode and in silent mode.
If the kernel-mode virtual device driver is used, usually you can configure your system and sound applications so that only the application’s sounds will be recorded. If the kernel-mode filter driver is used, recording a particular application can be achieved only if there is more than one real sound playback device on your system.
After installing the kernel-mode filter driver, a reboot is always required. After installing the kernel-mode virtual device driver, a reboot is not usually required.
Possible Problems with Total Recorder Drivers
Possible problems with Total Recorder's user-mode driver
- Incompatibility with DirectSound
Problems can occur with an application that uses Direct Sound. If such an application passes a sound stream through the driver, the sound may be garbled. For example, distortions often appear when using most versions of Skype 3.x.
- Incompatibility with a small number of applications
A small number of applications may not start at all, or they may function incorrectly, if the driver is set as a system default device. Examples of such applications include CyberLink software (e.g. PowerDVD, PowerProducer) and Adobe software (e.g. Adobe Premiere, Adobe Encore, etc.).
- Partial compatibility with Windows Vista
See this information regarding compatibility issues between the user-mode driver and Windows Vista.
Possible problems with Total Recorder's kernel-mode driver (virtual device driver or filter driver)
- Unable to record a particular application
The system mixes audio streams being played before it arrives in the kernel-mode driver. Audio streams being played can only be recorded in mixed form. This is similar to recording from a line such as "Stereo Mix". It is not possible to single out a stream belonging to a particular application as it could be made using a user-mode driver. All appropriate recording parameters (i.e. Record only streams opened after the recording has started and Record only this application) are disabled.
- Volume regulator affects the level of recording
The volume level of the Wave line affects the level of sound received by the kernel-mode driver. For quality recordings, it is recommended you set the volume level of the Wave line to the maximum position and do not change this level during the recording. You should use the level of the Master line to regulate the sound volume when recording.
Notes:
Most players' volume regulators are connected to the Wave line. You should set the regulator to the maximum position and do not change it during a recording.
The system volume regulator, which is the regulator that appears when you click on the system tray icon, is associated with the Master line. You can adjust it freely while recording.
Under Windows XP, you can also use the volume regulator in Total Recorder's main window to adjust volume. Beginning with version 7.0, this regulator is associated with the Master line rather than the Wave line. Under Windows Vista, you should use only the system volume regulator.
- Accelerated recording through the kernel-mode filter driver cannot be performed
If Total Recorder is set to use the kernel-mode filter driver then Total Recorder cannot record in accelerated recording mode.
- Additional format conversion is sometimes performed
When a playback program passes a sound stream to the sound board, Windows can transform this sound stream to a format supported by your sound board. Total Recorder's kernel-mode driver receives this transformed stream rather than the original stream. The driver does not know the format of the original stream and Total Recorder can display only the format of the transformed stream.
In very rare cases, this conversion can result in a minor loss of quality, although this loss is normally not audible. Since the majority of recordings are performed in a compressed format, the compression results in more loss in quality (even if it is usually not audible) than the conversion.
Possible problems specific to Total Recorder's kernel-mode virtual device driver
- For some sound boards, a sound stream cannot be played through the board while another stream is played through the kernel-mode driver if the driver is set to use the sound board
This restriction can cause some problems:
If an application plays silence continuously and the application cannot be closed, then switching a system default device may require you to restart your system or to log off and on before your sound program will work properly.
You cannot record a particular sound stream by directing the stream to Total Recorder's kernel-mode driver while directing all other sound streams to the real sound board.
Note that this problem does not occur with most sound boards.
- Incompatibility with USB-microphones under Windows XP
Total Recorder's kernel-mode driver does not work with USB microphones under Windows XP. This can result in problems when recording an Internet telephony program, such as Skype. Such programs can be recorded, however this requires some additional setup. For more information, see Total Recorder Help: Troubleshooting -> After installing Total Recorder with the kernel-mode driver, problems occur using a USB microphone.
Note that this problem does not occur on Windows Vista.
- Problems with accelerated recording
The speed of an accelerated recording can be lower when using the kernel-mode driver compared with the user-mode driver. The recorded sound may be garbled even though no problems appeared when the recording was being made. For more information, see Total Recorder Help: Using Total -> Recorder Recording -> Accelerated Recording.
- Driver's recording-level regulator may function improperly
It is possible that the recording level regulator or the volume for specific playback lines of the driver does not work. This depends on the particular sound board. If you encounter this problem, follow these recommendations:
For Windows 2000/XP: Launch the system mixer, and use the controls of the real sound board rather than the controls of Total Recorder's driver.
For Windows Vista: From the Control Panel, click Sounds (or select Options - System settings in Total Recorder's main menu), select the playback or recording device to be used, click the Properties button, and then go to the Levels tab.
- Under Windows 2000/XP, if you record from Total Recorder's kernel-mode driver device, you should manually select the recording line
Total Recorder's kernel-mode driver has only one recording line, called "Microphone". Recording actually occurs through the active recording line of a real sound board. If you find that a recording uses an incorrect line, you should manually select the proper recording line by using the system mixer.
This problem occurs mostly when recording Internet telephony programs, such as Skype. If you only want to record from a sound board, you should record directly from a real sound device rather than from Total Recorder's driver.
- Under Windows Vista, if you record from Total Recorder's kernel-mode driver device, the recording can use an incorrect line
If you use Total Recorder's kernel-mode driver to record from a recording device, sometimes the recording uses an incorrect line. This problem depends on the real soundboard driver.
This problem occurs mostly when recording Internet telephony programs, such as Skype. If you only want to record from a sound board, you should record directly from a real sound device rather than from Total Recorder's driver.
If this problem occurs, take the following steps:
Stop using the recording device, and terminate the Internet-telephony conversation.
From the Control Panel, click Sounds (or select Options - System settings in Total Recorder's main menu), and then go to the Recording tab.
Select a real device (normally a microphone) that should be used for capturing sound, and click the Set Default button
Select Microphone. Total Recorder kernel mode (WDM) audio driver, and click the Set Default button.
Close the Sounds window.
See also:
Primer on PC Audio
Thursday, January 7, 2010
SQL Server UDTs
Msg 2715, Level 16, State 7, Procedure SPregInsertRegressionTop1Report, Line 70
Column, parameter, or variable #1: Cannot find data type DTObjectID.
Above error ocurred on CRPCORE db on my local computer. The UDT DTObjectID does exist in db CRPCORE (under Programmability.Types.User-defined Data Types).
Problem: UDTs must be known to SQL server before they can be used i.e these UDTs must also exist in model and tempdb databases. Im my case, esp tempdb because the SP above internally creates a table (with create TABLE) which, as we all know, gets created in tempdb.
Resolution: import these UDTs to model and tempdb.
Column, parameter, or variable #1: Cannot find data type DTObjectID.
Above error ocurred on CRPCORE db on my local computer. The UDT DTObjectID does exist in db CRPCORE (under Programmability.Types.User-defined Data Types).
Problem: UDTs must be known to SQL server before they can be used i.e these UDTs must also exist in model and tempdb databases. Im my case, esp tempdb because the SP above internally creates a table (with create TABLE) which, as we all know, gets created in tempdb.
Resolution: import these UDTs to model and tempdb.
Monday, January 4, 2010
drop database
-- drop kick any connections to database "foo" and roll back their transactions
ALTER DATABASE foo
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
-- Drop the database "foo"
USE MASTER
GO
DROP DATABASE foo
ALTER DATABASE foo
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
-- Drop the database "foo"
USE MASTER
GO
DROP DATABASE foo
Thursday, December 31, 2009
SCHEMA
SCHEMA
=========
-----------
USER "A"
-----------
--owns--> SCHEMA "S1"
--contains--> SP_1
<--owns-- DB_ROLE "R"
--owns--> SCHEMA "S2"
--contains--> TABLE_1
<--owns-- USER "B"
--owns--> SCHEMA "S3" --contains--> VIEW_1 <--owns-- USER "B", DB_ROLE "R"
-----------
USER "DBO"
-----------
--owns--> SCHEMA "DBO"
----------------
USER "DB_OWNER"
----------------
--owns--> SCHEMA "DB_OWNER"
----------------
DB_ROLE "R"
----------------
--owns--> SCHEMA "S2"
--contains--> TABLE_2
--owns--> SCHEMA "S3"
--contains--> VIEW_2
Schema can only contain certain entities, namely OBJECT (tbls, views, SPs, functions, queues and synonyms are objects that are "ownership-transferable" while other objects like linkedsrvrs, constraints, rules, triggers, credentials, statistics etc. are not), TYPE and XML SCHEMA COLLECTION.
**The only reliable way to find the owner of a object is to query the sys.objects catalog view. The only reliable way to find the owner of a type is to use the TYPEPROPERTY function.
A schema contains database (catalog) objects such as tables, views and SPs. A schema owner may be a DB user, DB role or app role.
DB user has one to many relationship with dbo schemas i.e. a schema can belong to only one user while a user can own many schemas.
"dbo" exists as a default schema. "dbo" also exists as a DB user. By default dbo user owns dbo schema.
"db_owner" is also both schema and user. So are other db_*,INFORMATION_SCHEMA etc. In fact, it is tempting to create the same schema name for every DB user. Is that a good practice?
Beginning with SQL Server 2005, a user can own an OBJECT or TYPE that is contained by a schema owned by another database user.
=========
-----------
USER "A"
-----------
--owns--> SCHEMA "S1"
--contains--> SP_1
<--owns-- DB_ROLE "R"
--owns--> SCHEMA "S2"
--contains--> TABLE_1
<--owns-- USER "B"
--owns--> SCHEMA "S3" --contains--> VIEW_1 <--owns-- USER "B", DB_ROLE "R"
-----------
USER "DBO"
-----------
--owns--> SCHEMA "DBO"
----------------
USER "DB_OWNER"
----------------
--owns--> SCHEMA "DB_OWNER"
----------------
DB_ROLE "R"
----------------
--owns--> SCHEMA "S2"
--contains--> TABLE_2
--owns--> SCHEMA "S3"
--contains--> VIEW_2
Schema can only contain certain entities, namely OBJECT (tbls, views, SPs, functions, queues and synonyms are objects that are "ownership-transferable" while other objects like linkedsrvrs, constraints, rules, triggers, credentials, statistics etc. are not), TYPE and XML SCHEMA COLLECTION.
**The only reliable way to find the owner of a object is to query the sys.objects catalog view. The only reliable way to find the owner of a type is to use the TYPEPROPERTY function.
A schema contains database (catalog) objects such as tables, views and SPs. A schema owner may be a DB user, DB role or app role.
DB user has one to many relationship with dbo schemas i.e. a schema can belong to only one user while a user can own many schemas.
"dbo" exists as a default schema. "dbo" also exists as a DB user. By default dbo user owns dbo schema.
"db_owner" is also both schema and user. So are other db_*,INFORMATION_SCHEMA etc. In fact, it is tempting to create the same schema name for every DB user. Is that a good practice?
Beginning with SQL Server 2005, a user can own an OBJECT or TYPE that is contained by a schema owned by another database user.
Wednesday, December 16, 2009
Recipe: pumpkin soup w/o pumpkin
1 Onion
2 Potatoes
1 cup cream
1 jar of maple pumpkin butter
Satay chopped one white onion with olive oil.
Throw in 2 chopped potatoes.
After being somewhat cooked, blend until smooth.
Pour back to pan, add a cup of cream and a whole jar of MAPLE PUMPKIN butter.
2 Potatoes
1 cup cream
1 jar of maple pumpkin butter
Satay chopped one white onion with olive oil.
Throw in 2 chopped potatoes.
After being somewhat cooked, blend until smooth.
Pour back to pan, add a cup of cream and a whole jar of MAPLE PUMPKIN butter.
Tuesday, November 24, 2009
XML Serializer: How to omit namespace and other redundant info
public static string SerializeType(Type aType, object aObject)
{
XmlSerializerNamespaces lXmlSerializerNamespaces = new XmlSerializerNamespaces();
lXmlSerializerNamespaces.Add("", "");
XmlSerializer lXmlSerializer = new XmlSerializer(aType);
XDocument lXDocument = new XDocument();
using (XmlWriter lXmlWriter = lXDocument.CreateWriter())
{
XmlWriterSettings lXmlWriterSettings = lXmlWriter.Settings;
lXmlWriterSettings.OmitXmlDeclaration = true;
lXmlSerializer.Serialize(lXmlWriter, aObject, lXmlSerializerNamespaces);
lXmlWriter.Close();
}
return lXDocument.ToString();
}
{
XmlSerializerNamespaces lXmlSerializerNamespaces = new XmlSerializerNamespaces();
lXmlSerializerNamespaces.Add("", "");
XmlSerializer lXmlSerializer = new XmlSerializer(aType);
XDocument lXDocument = new XDocument();
using (XmlWriter lXmlWriter = lXDocument.CreateWriter())
{
XmlWriterSettings lXmlWriterSettings = lXmlWriter.Settings;
lXmlWriterSettings.OmitXmlDeclaration = true;
lXmlSerializer.Serialize(lXmlWriter, aObject, lXmlSerializerNamespaces);
lXmlWriter.Close();
}
return lXDocument.ToString();
}
Thursday, October 1, 2009
Write Dataset to XML with WriteSchema
Serializing dataset ignores empty datatables
When you call lDataSet.WriteXml(aXMLFilePath), any data table without rows will be ignored. To include it (because table schema may still be important), use the WriteXml overload that writes to an xmlWriter and enable"WriteSchema".
I use XDocument that can create XmlWriter but I'm sure there are other ways.
XDocument lXDocument = new XDocument();
using (XmlWriter lXmlWriter = lXDocument.CreateWriter())
{
lMasterDataSet.WriteXml(lXmlWriter, XmlWriteMode.WriteSchema);
}
lXDocument.Save(@"c:\temp\PSReportServer_MasterDataSetWithSchema.xml");
Saturday, September 26, 2009
how to enumerate enum?
internal enum ChartRendererTypes{ TabularTextual, GanntChartFX }foreach (ChartRendererTypes suit in Enum.GetValues(typeof(ChartRendererTypes)))
{
}
Thursday, September 24, 2009
Debugger issues
Debugger cannot start if
Protected ReadOnly Property Logger() As ILogger
Get
CreateLogger()
Return mLogger
End Get
End Property
Why? This is not good. First, this property is intended to be get only, not set so VB requires adding ReadOnly key. Fine so far! But CreateLogger() is a function call that ensures mLogger comes out alive i.e. if mLogger is not already instantiated, then the function instantiates it, sets to specific log file etc. But we cannot test that, the VS debugger does not like that function and just simply says the debugger cannot be started! The release version bombs as well and prompts you with that dialog box asking if you want to see the error with a debugger (however, I noticed the dialog had VS2003 debugger!! I'm using VS2008 IDE!!)
Solution: Write "Me.CreateLogger()"
Saturday, September 12, 2009
Samsung 4500W printer info
Support
Things like how to scan using Scan Thru, where to buy a toner etc.
Should be able to see the printer's own website (thru a web service). Just type in its IP address as set up by DHCP router.
Ctrl panel should have Samsung Scan Manager thru which you can quick scan also - may need to set up the IP there though.
Things like how to scan using Scan Thru, where to buy a toner etc.
Should be able to see the printer's own website (thru a web service). Just type in its IP address as set up by DHCP router.
Ctrl panel should have Samsung Scan Manager thru which you can quick scan also - may need to set up the IP there though.
Friday, July 31, 2009
Saturday, July 25, 2009
Tuesday, July 14, 2009
DataSet Related
Copying a datatable
===============
When trying to add a datatable to a dataset and you get an error saying datatable belongs to another dataset, then do this: Set a new copieddatatable = origdatatable.copy(). You should be able to add the new copieddatatable to the dataset.
===============
When trying to add a datatable to a dataset and you get an error saying datatable belongs to another dataset, then do this: Set a new copieddatatable = origdatatable.copy(). You should be able to add the new copieddatatable to the dataset.
Tuesday, July 7, 2009
Saturday, June 20, 2009
Friday, June 12, 2009
Calculate font width with GDI+
http://www.eggheadcafe.com/community/aspnet/2/10911/heres-a-sample.aspx
public Bitmap Render()
{
Graphics g = Graphics.FromImage(_canvas); //painting surface. uses canvas.
Font font = new Font(_font, _fontStyle);
SolidBrush shadowBrush; //for painting text
SolidBrush textBrush;
int nCharsFitted; //this is how we know we have all of the characters on the canvas
int nLinesFilled; //this tells us how many lines the text uses
//antialias fonts.
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
//create new canvas and set the size
Size canvasSize = _canvas.Size;
SizeF canvasSizeF = new SizeF(_canvas.Width, _canvas.Height);
//specify formatting options
StringFormat stringFormat = new StringFormat();
stringFormat.FormatFlags = StringFormatFlags.FitBlackBox & StringFormatFlags.NoClip;
SizeF textSizeF = new SizeF(0,0);
//fit text
while (true)
{
//measure text
textSizeF = g.MeasureString(_zText, font, canvasSizeF, stringFormat, out nCharsFitted, out nLinesFilled );
//see if it fits
if ((canvasSizeF.Height >= textSizeF.Height) &
(canvasSizeF.Width >= textSizeF.Width) &
(nCharsFitted == _zText.Length) &
(nLinesFilled * font.Height <= canvasSizeF.Height)) { //text fits break; } else { //text doesn't fit. lower point size and try again. font = new Font(font.FontFamily, font.SizeInPoints - 1, font.Style); } } //set point for where to start drawing the text PointF textPoint; PointF shadowPoint; switch(_eAlignment) { case Engine.Imaging.Alignment.Center: textPoint = new PointF((canvasSizeF.Width - textSizeF.Width) / 2, 0); break; case Engine.Imaging.Alignment.Right: textPoint = new PointF(canvasSizeF.Width - textSizeF.Width, 0); break; default: textPoint = new PointF(0,0); break; } //apply shadow? if (_nShadowDepth > 0)
{
shadowPoint = new PointF(textPoint.X + _nShadowDepth, + _nShadowDepth);
shadowBrush = new SolidBrush(_shadowColor);
g.DrawString(_zText, font, shadowBrush, new RectangleF(shadowPoint , canvasSizeF), stringFormat);
}
//define brush with color to paint text with
textBrush = new SolidBrush(_textColor);
//apply text
g.DrawString(_zText, font, textBrush, new RectangleF(textPoint , canvasSizeF), stringFormat);
textBrush = null;
shadowBrush = null;
g = null;
stringFormat = null;
return _canvas;
}
Another one
http://social.msdn.microsoft.com/forums/en-US/vblanguage/thread/8b301d31-5b2c-4c6d-b78f-c0867dd0084e
public Bitmap Render()
{
Graphics g = Graphics.FromImage(_canvas); //painting surface. uses canvas.
Font font = new Font(_font, _fontStyle);
SolidBrush shadowBrush; //for painting text
SolidBrush textBrush;
int nCharsFitted; //this is how we know we have all of the characters on the canvas
int nLinesFilled; //this tells us how many lines the text uses
//antialias fonts.
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
//create new canvas and set the size
Size canvasSize = _canvas.Size;
SizeF canvasSizeF = new SizeF(_canvas.Width, _canvas.Height);
//specify formatting options
StringFormat stringFormat = new StringFormat();
stringFormat.FormatFlags = StringFormatFlags.FitBlackBox & StringFormatFlags.NoClip;
SizeF textSizeF = new SizeF(0,0);
//fit text
while (true)
{
//measure text
textSizeF = g.MeasureString(_zText, font, canvasSizeF, stringFormat, out nCharsFitted, out nLinesFilled );
//see if it fits
if ((canvasSizeF.Height >= textSizeF.Height) &
(canvasSizeF.Width >= textSizeF.Width) &
(nCharsFitted == _zText.Length) &
(nLinesFilled * font.Height <= canvasSizeF.Height)) { //text fits break; } else { //text doesn't fit. lower point size and try again. font = new Font(font.FontFamily, font.SizeInPoints - 1, font.Style); } } //set point for where to start drawing the text PointF textPoint; PointF shadowPoint; switch(_eAlignment) { case Engine.Imaging.Alignment.Center: textPoint = new PointF((canvasSizeF.Width - textSizeF.Width) / 2, 0); break; case Engine.Imaging.Alignment.Right: textPoint = new PointF(canvasSizeF.Width - textSizeF.Width, 0); break; default: textPoint = new PointF(0,0); break; } //apply shadow? if (_nShadowDepth > 0)
{
shadowPoint = new PointF(textPoint.X + _nShadowDepth, + _nShadowDepth);
shadowBrush = new SolidBrush(_shadowColor);
g.DrawString(_zText, font, shadowBrush, new RectangleF(shadowPoint , canvasSizeF), stringFormat);
}
//define brush with color to paint text with
textBrush = new SolidBrush(_textColor);
//apply text
g.DrawString(_zText, font, textBrush, new RectangleF(textPoint , canvasSizeF), stringFormat);
textBrush = null;
shadowBrush = null;
g = null;
stringFormat = null;
return _canvas;
}
Another one
http://social.msdn.microsoft.com/forums/en-US/vblanguage/thread/8b301d31-5b2c-4c6d-b78f-c0867dd0084e
Monday, June 1, 2009
Random Health and Food Topics
Spicy food like curry may help fight brain cancer. Also first ever vaccine may be in the works. Here's the story on extratv.
Saturday, May 30, 2009
Down to quantities
References
healthy diet fit body
Per day
to fight hypertension and high blood pressure
fruits and vegetables in general are the best.
increase potassium - 4700 mg : bananas, potatoes (no, you can’t have french fries), canned white beans, yogurt, halibut, tuna, lima beans and winter squash
reduce sodium (most important for reducing hypertension, others are secondary) - 2300 mg (approx 1 tablespoon) : salty snack eaters eat 4X as much while average americans eat 2X as much
magnesium - 500 - 1000 mg: in a well-bal diet.
(increase) calcium - 800 - 1000 mg: average american gets half. Take supplement with 3-400mg.
** Vitamin D **
People have not figured out on D!! Just read this on WebMD and on MSN Health, and you will see that the experts have no freaking clue as to HOW MUCH D we need. Ask my doctor if I need to take D. I was going to order D supplements (since thru diet, getting 2000IU is almost impossible?) but I'm hesitant now. More info needed...
For me, I figure about 2000 IU (dark skinned, not enough sun exposure). Get this thru supplement since D is hard to get from food and since sun is not always available.
The U.S. Recommended Dietary Intake for vitamin D is currently 400 International Units (IU). However, research is suggesting that may not be enough. In fact, a recent study in the American Journal of Clinical Nutrition suggests that doses of 3,800 to 5,000 IU may be needed to maintain optimal blood levels, as the body doesn't absorb all it takes in. The official safe upper-limit (UL) for vitamin D intake is 2,000 IU, although many researchers are now saying this is much too conservative and it should be reset to 10,000 IU. However, scientific organizations are slow to change their recommendations, so it may be a while before the official UL is reset to a higher level.
A minimum of 1,000 IU every day is recommended. Keep in mind if you're overweight or dark-skinned, you are at a high risk for deficiency.
One cup of fortified milk has only 100 IU of vitamin D (we actually get much more vitamin D from the sun than we could ever get from food).
If you expose your face, arms, back, or hands to the sun three times per week for 15 minutes between 11 a.m. and 2 p.m., you'll get a dose of about 3,000 IU of vitamin D. So, before you slap on the sunscreen, give yourself this small amount of sun exposure. Then, you can put on the sunscreen to avoid over-exposure to the sun.
Heart disease prevention
maintain body weight
exercise
low saturated and trans fat
high omega3 fatty acid
keep LDL below 100, HDL over 40
be happy
Whey protein
.7 * body wt of about 150 = 105 gm of whey (too much??)
still sounds too much. taking 20g scoop 4 times already sounds enough.
space it out daily so liver/kidney is not overworked
isolate form is better but more expensive, mix of isolate and concentrate (higher % of isolate though) gives you biggest bang for buck
What to eat before during after excercise?
after exercise, only 10-20g of protein says this article!!
healthy diet fit body
Per day
to fight hypertension and high blood pressure
fruits and vegetables in general are the best.
increase potassium - 4700 mg : bananas, potatoes (no, you can’t have french fries), canned white beans, yogurt, halibut, tuna, lima beans and winter squash
reduce sodium (most important for reducing hypertension, others are secondary) - 2300 mg (approx 1 tablespoon) : salty snack eaters eat 4X as much while average americans eat 2X as much
magnesium - 500 - 1000 mg: in a well-bal diet.
(increase) calcium - 800 - 1000 mg: average american gets half. Take supplement with 3-400mg.
** Vitamin D **
People have not figured out on D!! Just read this on WebMD and on MSN Health, and you will see that the experts have no freaking clue as to HOW MUCH D we need. Ask my doctor if I need to take D. I was going to order D supplements (since thru diet, getting 2000IU is almost impossible?) but I'm hesitant now. More info needed...
For me, I figure about 2000 IU (dark skinned, not enough sun exposure). Get this thru supplement since D is hard to get from food and since sun is not always available.
The U.S. Recommended Dietary Intake for vitamin D is currently 400 International Units (IU). However, research is suggesting that may not be enough. In fact, a recent study in the American Journal of Clinical Nutrition suggests that doses of 3,800 to 5,000 IU may be needed to maintain optimal blood levels, as the body doesn't absorb all it takes in. The official safe upper-limit (UL) for vitamin D intake is 2,000 IU, although many researchers are now saying this is much too conservative and it should be reset to 10,000 IU. However, scientific organizations are slow to change their recommendations, so it may be a while before the official UL is reset to a higher level.
A minimum of 1,000 IU every day is recommended. Keep in mind if you're overweight or dark-skinned, you are at a high risk for deficiency.
One cup of fortified milk has only 100 IU of vitamin D (we actually get much more vitamin D from the sun than we could ever get from food).
If you expose your face, arms, back, or hands to the sun three times per week for 15 minutes between 11 a.m. and 2 p.m., you'll get a dose of about 3,000 IU of vitamin D. So, before you slap on the sunscreen, give yourself this small amount of sun exposure. Then, you can put on the sunscreen to avoid over-exposure to the sun.
Heart disease prevention
maintain body weight
exercise
low saturated and trans fat
high omega3 fatty acid
keep LDL below 100, HDL over 40
be happy
Whey protein
.7 * body wt of about 150 = 105 gm of whey (too much??)
still sounds too much. taking 20g scoop 4 times already sounds enough.
space it out daily so liver/kidney is not overworked
isolate form is better but more expensive, mix of isolate and concentrate (higher % of isolate though) gives you biggest bang for buck
What to eat before during after excercise?
after exercise, only 10-20g of protein says this article!!
Saturday, May 23, 2009
abs workout
best abs workout - most with no tools
best abs workout take 2
long arm weighted crunch - with light dumbells on each hand and lying flat with knees bent
youtube at home crunch
youtube ** good review
best abs workout take 2
long arm weighted crunch - with light dumbells on each hand and lying flat with knees bent
youtube at home crunch
youtube ** good review
What's in a breakfast?
Why breakfast is important?
Cereals are just "better than nothing". If u must, look for whole grain, add >5g of daily fiber, <25% sugar calories.
Vitamin D, Fish Oil, Vitamin E etc.
Cereals are just "better than nothing". If u must, look for whole grain, add >5g of daily fiber, <25% sugar calories.
Vitamin D, Fish Oil, Vitamin E etc.
after workout supplement
WebMD Protein Shakes
10 Diet Myths - after workout, get 8 grams of protein (small carton of low fat choco milk). no need to get 4 scoops of whey.
For body building, get something with more protein(>50%), less carb.
Best way to get protein is always through diet, but this is difficult to do right after workout. whey is the best source of supplemental protein (better than milk, egg or soy) RIGHT AFTER WORKOUT (in body for short time). casein protein is for meal replacement or before going to bed (in body for long time).
Low carb dutch chocolate
10 Diet Myths - after workout, get 8 grams of protein (small carton of low fat choco milk). no need to get 4 scoops of whey.
For body building, get something with more protein(>50%), less carb.
Best way to get protein is always through diet, but this is difficult to do right after workout. whey is the best source of supplemental protein (better than milk, egg or soy) RIGHT AFTER WORKOUT (in body for short time). casein protein is for meal replacement or before going to bed (in body for long time).
Low carb dutch chocolate
Thursday, May 21, 2009
Mutivitamins

My summary:
What you are looking for in a multivitamin is various vitamins and minerals. Minerals are bulky so that's why you are prompted to take a few pills a day. Chances are 1 pill a day probably cannot give you 100% of daily value as far as minerals are concerned but it is certainly possible to get 100% of all vitamins in a pill. But that's ok since I think we should get minerals via other means on a daily basis.
- No iron
- Calcium: 1000 mg (DV), get ALL from food, if over 51, 1200mg, if over 75, 1500mg, men shouldn't take a calcium supplement; Andrew Weil, founder of the Arizona Center for Integrative Medicine at the University of Arizona, says it increases the risk of prostate cancer.
- Carotenoids desired: beta carotene, alpha carotene, gamma carotene, lycopene, lutein, beta-cryptoxanthin, zeaxanthin or astaxanthin.
- vitamin A: sources are usually retinol (aka "performed vitamin A" or acetate or palmitate) and beta carotene. Def go with latter. Excess retinol (acetate, palmitate) is said to cause reduction in bone density and fracture and harm liver health. Take no more than 5000 IU and 100% from beta carotene is the best. No vit A for smokers! Also, 50% from supplement and 50% from food is the best.
- vitamin B6: 2(DV)-50 mg (for heart disease)
- vitamin B12: 6 mcg(DV) but if over 50, 25-100 mcg (for heart disease and nerve damage)
- vitamin C: 200-500 mg (heart and age related diseases)
- vitamin D: 400 IU or if north of boston 600IU in winter/fall
- vitamin E: 400 IU (30IU is DV), make sure type is d-alpha-tocopherol (rather than "dl") or tocotrienols
- vitamin D: 2000 IU
- folic acid: 400(DV)-800 mcg (heart)
- chromium: 200 mcg (120 mcg DV) (prevent diabetes)
- Magnesium: 400mg(DV), get from supplement and food like beans and artichokes (bones and heart)
- yeast based selenium: 200 mcg if man (prevent cancer), less than 70 mcg if woman.
- I think, due to potential side effects and risks, it is best to know what you lack the most and focus on supplementing only those. To that end, nothing beats the real sources like fruits and vegetables etc. Look at the vitamins picture.
WebMD Multivitamins FOR MEN
References:
What to look for?
What to look for, take 2?
Bad for you? Get everything from diet, except vitamin D which you can get from supplement!
Should I? For athletes and body builders, need to replace vitamins and minerals fast, so may make sense.
On and on and on.... My conclusion: take something to replenish vitamins and minerals right after workout in juice form . Otherwise, just take D on a daily basis. Rest, get from diet.
What to drink right after workout?
here is one
another one
So, maybe drink my regular NATURAL fruit juice in the morning and after workout, but mixed with supplements? YEAH
How to choose best multivitamin?
If you must, look for those with:
No iron
3,000 to 5000 International Units of vitamin A, with at least 20% of it as beta-carotene
A lot of vitamin D
USP insignia
Good Reviews
One a day Men's Healt Formula - no iron, not sure about USP, $10 per 100 tablets
Centrum Silver Ignore 50+ sign
Fish oil supplements
Some Info on Fish Oil Supplements
WebMD Good for High Blood Pressure
WebMD Omega 3 strategy
After-taste can be eliminated by storing capsules in the freezer and taking them frozen.
Flax seed oil is not as good as fish oil (fish oil has both EPA and DHA, flax seed oil doesn't).
Good ONE-A-DAY ones with IFOS 5 star ratings
Make sure you go to IFOS to ensure 5 star ratings. The stuff you buy has to be of a certain batch with certain expiry date (older batches from the same company may be of poorer quality).
The following products are by batch number/expiry date
EPA/DHA are in mg/1000mg
Critical Omega from Renew Life
Batch 082917/09.11
IFOS 5 star findings: EPA/DHA 439/230
60 capsules
http://www.renewlife.com/
vitacost $26
(website says avail in WholeFoods and Triple Harvest Co-op near 02141 zip)
Ordered from vitacost - 2 units, they charge $5 for S&H
Kirkland Signature Fish Oil
Not on IFOS but high Amazon ratings ($25 for 180 gels!!! sounds too good to be true?), also sold by Costco
GNC Triple Strength Fish Oil
EPA/DHA 647/253
60 gels, $15 for goldcard holders
Other good ones I ditched for various reasons
Barleans - not on IFOS, good review but suggested use is 2-6 per day!!!
See Yourself Well Omega 3 - IFOS, but 3 per day (also known as another site Nuratec), 300 capsules $100
Zone Labs OmegaRx - IFOS but 4 per day, from zone site, 120 capsules for 30 day is $40 with autoship or $50 without
PharmaOmega - again more than 1 per day
WebMD Good for High Blood Pressure
WebMD Omega 3 strategy
After-taste can be eliminated by storing capsules in the freezer and taking them frozen.
Flax seed oil is not as good as fish oil (fish oil has both EPA and DHA, flax seed oil doesn't).
Good ONE-A-DAY ones with IFOS 5 star ratings
Make sure you go to IFOS to ensure 5 star ratings. The stuff you buy has to be of a certain batch with certain expiry date (older batches from the same company may be of poorer quality).
The following products are by batch number/expiry date
EPA/DHA are in mg/1000mg
Critical Omega from Renew Life
Batch 082917/09.11
IFOS 5 star findings: EPA/DHA 439/230
60 capsules
http://www.renewlife.com/
vitacost $26
(website says avail in WholeFoods and Triple Harvest Co-op near 02141 zip)
Ordered from vitacost - 2 units, they charge $5 for S&H
Kirkland Signature Fish Oil
Not on IFOS but high Amazon ratings ($25 for 180 gels!!! sounds too good to be true?), also sold by Costco
GNC Triple Strength Fish Oil
EPA/DHA 647/253
60 gels, $15 for goldcard holders
Other good ones I ditched for various reasons
Barleans - not on IFOS, good review but suggested use is 2-6 per day!!!
See Yourself Well Omega 3 - IFOS, but 3 per day (also known as another site Nuratec), 300 capsules $100
Zone Labs OmegaRx - IFOS but 4 per day, from zone site, 120 capsules for 30 day is $40 with autoship or $50 without
PharmaOmega - again more than 1 per day
Thursday, May 14, 2009
C# keywords I
ref and out
===========
Use ref if the type instance already exists before entering the function. Use out otherwise. Therefore, ref is in and out.
===========
Use ref if the type instance already exists before entering the function. Use out otherwise. Therefore, ref is in and out.
Wednesday, May 13, 2009
Sunday, May 10, 2009
MSG
Monosodium glutamate, or MSG, earned its reputation in Asian takeout kitchens across America, but almost all fast-food restaurants use the flavor enhancer to some extent. Interestingly, MSG has no distinct taste itself. Instead, it amplifies other flavors, especially in foods with chicken or beef flavoring, through processes that scientists don't fully understand.
http://recipes.howstuffworks.com/processing-facts-channel.htm
http://recipes.howstuffworks.com/processing-facts-channel.htm
HFCS
http://recipes.howstuffworks.com/high-fructose-corn-syrup2.htm
Unlike glucose, which is metabolized a number of ways by your body, fructose is only metabolized by your liver. When the liver receives more fructose than it can handle, the excess sugars are turned into fats in the form of triglycerides, which are harmful to your arteries and your heart.
The biggest problem is that HFCS is being added to food items that don't normally have sugar and that you wouldn't even describe as sweet -- crackers, for instance. So, not only are we chugging down lots of sugars with our sodas, but your PBJ sandwich could have HFCS in each of its three ingredients. Meal after meal, day after day, all of this extra sugar adds up, and that, and not necessarily the qualities of HFCS itself, is likely one reason why rates for obesity and diabetes have climbed since the introduction of HFCS. (Other factors are in play as well, such as decreased activity and exercise levels and increased fat consumption.)
So what can we do? Well, for starters, do everything you're already supposed to do. Get regular exercise, watch your fat intake and get regular medical checkups. Next, it wouldn't hurt to mimic the practices of those strange (and rare) individuals in grocery-store aisles who read the labels of the food they are purchasing. Once you get in this habit, you will likely be shocked to learn just how much of your regular grocery purchases contain high-fructose corn syrup. If nearly all of your food contains concentrated sugars, it stands to reason that you'll be eating too many sugars. And if you want to go crazy, eat some fruits and veggies. You'll get all the glucose you need (not much), and these healthier alternatives will take the place of the less healthy foods now flooding our markets and grocery stores.
Unlike glucose, which is metabolized a number of ways by your body, fructose is only metabolized by your liver. When the liver receives more fructose than it can handle, the excess sugars are turned into fats in the form of triglycerides, which are harmful to your arteries and your heart.
The biggest problem is that HFCS is being added to food items that don't normally have sugar and that you wouldn't even describe as sweet -- crackers, for instance. So, not only are we chugging down lots of sugars with our sodas, but your PBJ sandwich could have HFCS in each of its three ingredients. Meal after meal, day after day, all of this extra sugar adds up, and that, and not necessarily the qualities of HFCS itself, is likely one reason why rates for obesity and diabetes have climbed since the introduction of HFCS. (Other factors are in play as well, such as decreased activity and exercise levels and increased fat consumption.)
So what can we do? Well, for starters, do everything you're already supposed to do. Get regular exercise, watch your fat intake and get regular medical checkups. Next, it wouldn't hurt to mimic the practices of those strange (and rare) individuals in grocery-store aisles who read the labels of the food they are purchasing. Once you get in this habit, you will likely be shocked to learn just how much of your regular grocery purchases contain high-fructose corn syrup. If nearly all of your food contains concentrated sugars, it stands to reason that you'll be eating too many sugars. And if you want to go crazy, eat some fruits and veggies. You'll get all the glucose you need (not much), and these healthier alternatives will take the place of the less healthy foods now flooding our markets and grocery stores.
Tuesday, May 5, 2009
Monday, April 20, 2009
ETF
Consider an ETF as a company stock that invests in certain things - like in S&P500 index, shorting of S&P100, fixed income of anything like emerging markets, gold, even in something as specific as homeland security. In essence, they can invest in anything and can work with either up or down market.
If you are investing more than $5000, ETFs are better than mutual funds due to cost savings. However, there are usually transaction fees (every time you buy more shares or sell shares). Find brokerage firm or a bank that charges low fee (based on your total investment with them) or NO FEE.
Tips
Find the right brokerage/bank with very low or no fee if you maintain balance.
Invest your retirement money in ETFs.
Resources
ETF Browser from Yahoo
Filter by "bear market" to see short and ultra-short ETFs
Brian T Mikes - Dynamic Wealth Report
Weekly Top 10 ETF Rankings from Trader Planet
ETFs 60 seconds guide from Fool
ETFGuide.com
ETF Investing Guide from Seeking Alpha
If you are investing more than $5000, ETFs are better than mutual funds due to cost savings. However, there are usually transaction fees (every time you buy more shares or sell shares). Find brokerage firm or a bank that charges low fee (based on your total investment with them) or NO FEE.
Tips
Find the right brokerage/bank with very low or no fee if you maintain balance.
Invest your retirement money in ETFs.
Resources
ETF Browser from Yahoo
Filter by "bear market" to see short and ultra-short ETFs
Brian T Mikes - Dynamic Wealth Report
Weekly Top 10 ETF Rankings from Trader Planet
ETFs 60 seconds guide from Fool
ETFGuide.com
ETF Investing Guide from Seeking Alpha
VIX
http://marketsci.wordpress.com/2008/09/22/test-of-condor%E2%80%99s-vix-based-trading-strategy/
http://trading-stock-market.blogspot.com/2008/03/vix.html
http://www.tradingmarkets.com/.site/stocks/commentary/editorial/-68023.cfm
http://vixandmore.blogspot.com/2007/07/tradingmarkets-5-vix-rule.html
http://seekingalpha.com/article/105643-trading-strategy-vix-spread-and-the-stock-market
*** http://www.smallcapnetwork.com/scb/how-i-use-the-vix-to-trade-stocks/2274/
http://wallstreetblips.dailyradar.com/story/trading_strategy_the_vix_spread_and_the_stock_market/
http://www.ibankcoin.com/woodshedderblog/index.php/2008/09/15/stretched-vix-strategy-signals-buy-the-spy/
http://trading-stock-market.blogspot.com/2008/03/vix.html
http://www.tradingmarkets.com/.site/stocks/commentary/editorial/-68023.cfm
http://vixandmore.blogspot.com/2007/07/tradingmarkets-5-vix-rule.html
http://seekingalpha.com/article/105643-trading-strategy-vix-spread-and-the-stock-market
*** http://www.smallcapnetwork.com/scb/how-i-use-the-vix-to-trade-stocks/2274/
http://wallstreetblips.dailyradar.com/story/trading_strategy_the_vix_spread_and_the_stock_market/
http://www.ibankcoin.com/woodshedderblog/index.php/2008/09/15/stretched-vix-strategy-signals-buy-the-spy/
Saturday, April 18, 2009
Nightlife promoting business
All About Party Promoter Business
Night Club Promotions
What is a Nightlife Promoter?
Tips on Becoming a Nightclub Promoter
4 Easy Steps to Start Your Party Promoting Business
Question to ALL Boston Promoters & Nightlife Folks
New Ordinance Threatens Live Music in Winston-Salem
Club texting
imagine a site like going.com offering printing!
NIGHTLIFE PRINTING & PROMOTION
catering to promoters' needs using mobile solution
Kalin Moon used to have blogs but now she's launching this new site. Blogs are informative with good ideas. her blogs are here.
How to serve n provide info to club promoters?
Night Club Promotions
What is a Nightlife Promoter?
Tips on Becoming a Nightclub Promoter
4 Easy Steps to Start Your Party Promoting Business
Question to ALL Boston Promoters & Nightlife Folks
New Ordinance Threatens Live Music in Winston-Salem
Club texting
imagine a site like going.com offering printing!
NIGHTLIFE PRINTING & PROMOTION
catering to promoters' needs using mobile solution
Kalin Moon used to have blogs but now she's launching this new site. Blogs are informative with good ideas. her blogs are here.
How to serve n provide info to club promoters?
Thursday, April 16, 2009
My Investment-related Links
Sector Options
http://www.nasdaqtrader.com/Micro.aspx?id=phlxsectorindexoptions
http://www.optionsmentoring.com/stockoptions/Trading_a_Sector_Option_103.shtml
Market Sector Indices (may or may not have options)
http://quotes.nasdaq.com/aspx/sectorindices.aspx
Options on ETFs and HOLDRS
http://www.cboe.com/Products/optionsOnETFs.aspx
iShares ETFs
http://us.ishares.com/home.htm?c=JAC01&gclid=CMSZivqA9pkCFeRM5Qodsl2tSA
The Options Insider
http://www.theoptionsinsider.com/unusualactivity/?id=1739
Learn Options tips - http://www.theoptionsinsider.com/tradingtechnology/
Learn options from OptionPlanet (associated with TOS)
http://www.optionplanet.com/assembled/list.html
Learning about stocks, options, forex (Learning Markets)
Premarket (8 - 9:30) and afterhours (4 - 6:30) (simple course)
Only stocks can be traded, but no options or any derivatives?
http://www.nasdaqtrader.com/Micro.aspx?id=phlxsectorindexoptions
http://www.optionsmentoring.com/stockoptions/Trading_a_Sector_Option_103.shtml
Market Sector Indices (may or may not have options)
http://quotes.nasdaq.com/aspx/sectorindices.aspx
Options on ETFs and HOLDRS
http://www.cboe.com/Products/optionsOnETFs.aspx
iShares ETFs
http://us.ishares.com/home.htm?c=JAC01&gclid=CMSZivqA9pkCFeRM5Qodsl2tSA
The Options Insider
http://www.theoptionsinsider.com/unusualactivity/?id=1739
Learn Options tips - http://www.theoptionsinsider.com/tradingtechnology/
Learn options from OptionPlanet (associated with TOS)
http://www.optionplanet.com/assembled/list.html
Learning about stocks, options, forex (Learning Markets)
Premarket (8 - 9:30) and afterhours (4 - 6:30) (simple course)
Only stocks can be traded, but no options or any derivatives?
Interesting statistical finds on market
Earnings Announcements
http://www.cqa.org/uploads/papers/1287938062443d2a80c3515.ppt#298,22,Abnormal
There are abnormal order flows around announcement dates but most of these are by small traders (<$5000 per trade?).
Small buys go way up on announcement days. Institutions buy BEFORE announcement days, expecting buying pressure (to partially arbitrage). These buying pressures are from small investors. Buying pressures mean prices go up.
There is a BIG earnings announcement premium (observed by: earnings announcements correlated with higher volumes and higher volumes lead to higher premiums)
Sam: is reverse true of selling pressure? No doubt!
http://www.cqa.org/uploads/papers/1287938062443d2a80c3515.ppt#298,22,Abnormal
There are abnormal order flows around announcement dates but most of these are by small traders (<$5000 per trade?).
Small buys go way up on announcement days. Institutions buy BEFORE announcement days, expecting buying pressure (to partially arbitrage). These buying pressures are from small investors. Buying pressures mean prices go up.
There is a BIG earnings announcement premium (observed by: earnings announcements correlated with higher volumes and higher volumes lead to higher premiums)
Sam: is reverse true of selling pressure? No doubt!
Tuesday, April 14, 2009
TOS Commission Rates
https://www.thinkorswim.com/tos/displayFaq.tos
What are thinkorswim's commission rates?
For Stock orders, you have the choice of 'Per Share Commission' at $.015 per share ($5.00 minimum) OR 'Flat Fee Trading' at $9.95 per trade (market or limit orders; 5,000 shares maximum). For Option orders, you pay the lesser of $2.95 per contract OR $1.50 per contract plus $9.95 (only one $9.95 charge for unlimited spread legs). For Futures orders, you pay $3.50 per mini contract (inclusive of exchange fees).
Commissions on option spreads
If the trade was entered as a spread, there is only one $10 ticket charge regardless of the number of legs associated with that spread, or $2.95 per contract if that's less.
What are thinkorswim's commission rates?
For Stock orders, you have the choice of 'Per Share Commission' at $.015 per share ($5.00 minimum) OR 'Flat Fee Trading' at $9.95 per trade (market or limit orders; 5,000 shares maximum). For Option orders, you pay the lesser of $2.95 per contract OR $1.50 per contract plus $9.95 (only one $9.95 charge for unlimited spread legs). For Futures orders, you pay $3.50 per mini contract (inclusive of exchange fees).
Commissions on option spreads
If the trade was entered as a spread, there is only one $10 ticket charge regardless of the number of legs associated with that spread, or $2.95 per contract if that's less.
TOS Margin Requirements on EQUITIES and EQUITY OPTIONS, Margin Schedule
https://www.thinkorswim.com/tos/displayFaq.tos
What is a pattern day trader?
Effective September 28th, 2001 the NYSE and NASD imposed a $25,000 minimum equity requirement for 'pattern day traders.' Consistent with the new margin rules, if a thinkorswim customer's margin account falls under $25,000 and the customer has opened and closed positions on the same day four times within five days, the customer will not be allowed to open new positions until the $25,000 requirement is restored.
Additionally, for a designated 'pattern day trader' account, the customer is allowed on any day to open new positions up to a total of the account's Day Trading Buying Power (defined as four times account equity less maintenance margin requirements). The rule requires orders exceeding Day Trading Buying Power to be rejected.
Margin Requirements
What are your margin requirements for equities and equity options?
Please see our margin requirements in the MARGIN SCHEDULE in the RATES section. Generally speaking, our margin requirements for equities and equity options conform to NASD requirements.
How do I calculate the margin on a short call or short put?
To learn how to calculate the margin requirement of a short call or short put, see our margin schedule.
Margin Schedule
What is a pattern day trader?
Effective September 28th, 2001 the NYSE and NASD imposed a $25,000 minimum equity requirement for 'pattern day traders.' Consistent with the new margin rules, if a thinkorswim customer's margin account falls under $25,000 and the customer has opened and closed positions on the same day four times within five days, the customer will not be allowed to open new positions until the $25,000 requirement is restored.
Additionally, for a designated 'pattern day trader' account, the customer is allowed on any day to open new positions up to a total of the account's Day Trading Buying Power (defined as four times account equity less maintenance margin requirements). The rule requires orders exceeding Day Trading Buying Power to be rejected.
Margin Requirements
What are your margin requirements for equities and equity options?
Please see our margin requirements in the MARGIN SCHEDULE in the RATES section. Generally speaking, our margin requirements for equities and equity options conform to NASD requirements.
How do I calculate the margin on a short call or short put?
To learn how to calculate the margin requirement of a short call or short put, see our margin schedule.
Margin Schedule
Options: Exercise and Assignment
https://www.thinkorswim.com/tos/displayFaq.tos?categoryKey=TRADING
How do I exercise an option contract prior to expiration?
If you trade options, it's imperative that you understand the basics of exercise and assignment. You don't need to know all the theoretical details, but you must be prepared for it, especially if you're short options where you don't control the exercise feature. Learn more in the "Exercise and Assignment, Early or Otherwise" section of the Option School section of our website. Remember that clients are required to submit an electronic exercise advice by 3:20 pm CST.
How do I know that I have been assigned on a short option?
If you are short any options that are in the money you should check your account daily to see if you have been assigned. In the case of early assignment (assignment prior to expiration) we will make every attempt to reach you prior to the opening of the market on the day we receive the exercise notice on your behalf, but you still need to maintain the habit of checking your account personally.
At expiration, any equity option that is .01 of a point or more in the money will be automatically assigned. In addition, in the money cash-settled options are exercised on the holder's behalf. There is too much volume on expiration to contact each person individually, so you need to check your accounts on the TOS system on Monday morning after expiration to see where you stand. In any case, our clearing firm will send you a confirmation showing your purchase or sale of stock on an exercise.
Please explain automatic exercise at expiration.
Equity options that are in-the-money by .01 of a point or more by the close of trading on the Friday before expiration are automatically exercised. Clients who wish to exercise options that are in-the-money by less than .01 of a point must notify us electronically via the exercise page by 3:20 pm CST.
How do I exercise an option contract prior to expiration?
If you trade options, it's imperative that you understand the basics of exercise and assignment. You don't need to know all the theoretical details, but you must be prepared for it, especially if you're short options where you don't control the exercise feature. Learn more in the "Exercise and Assignment, Early or Otherwise" section of the Option School section of our website. Remember that clients are required to submit an electronic exercise advice by 3:20 pm CST.
How do I know that I have been assigned on a short option?
If you are short any options that are in the money you should check your account daily to see if you have been assigned. In the case of early assignment (assignment prior to expiration) we will make every attempt to reach you prior to the opening of the market on the day we receive the exercise notice on your behalf, but you still need to maintain the habit of checking your account personally.
At expiration, any equity option that is .01 of a point or more in the money will be automatically assigned. In addition, in the money cash-settled options are exercised on the holder's behalf. There is too much volume on expiration to contact each person individually, so you need to check your accounts on the TOS system on Monday morning after expiration to see where you stand. In any case, our clearing firm will send you a confirmation showing your purchase or sale of stock on an exercise.
Please explain automatic exercise at expiration.
Equity options that are in-the-money by .01 of a point or more by the close of trading on the Friday before expiration are automatically exercised. Clients who wish to exercise options that are in-the-money by less than .01 of a point must notify us electronically via the exercise page by 3:20 pm CST.
TOS Order Types
https://www.thinkorswim.com/tos/displayFaq.tos?categoryKey=TRADING
***
https://www.thinkorswim.com/tos/displayPage.tos?webpage=servicesOrderTypes
What types of orders does thinkorswim accept?
For all listed products, the thinkorswim software accepts
market
limit
stop
MOC - Market On Close
LOC - Limit On Close
trailing stop (read disclaimer below)
stop limit
conditional
OCO - One Cancels Other (read disclaimer below)
For option spreads, the thinkorswim software accepts
limit
conditional
OCO (read disclaimer below)
market
Through our trade desk, we accept ANY order type imaginable.
All orders, except for option spread orders, are executed electronically. Option spreads are executed via open outcry because none of the five option exchanges currently support electronic spread execution. All trade executions and confirmations will be delivered electronically back to the trading application.
Order Type Explained
LIMIT - default order type for all single option, spread and stock orders. The limit price for buy orders is placed below the current market price. The limit price for sell orders is placed above the current market price. Limit orders will be filled at the limit price or better, but are not guaranteed a fill.
MARKET (also known as "not held") - order used to guarantee an execution, but not guarantee a price or time of execution. The risk of market orders is that you have no control over what the execution price is. We strongly suggest you avoid using them with options, especially option spreads.
STOP (also known as "stop loss") - order used to open or close a position by buying if the market rises or selling if the market falls. The stop price for buy orders is placed above the current market price. The stop price for sell orders is placed below the current market price. A stop order turns into a market order when the stop is triggered, so the final execution price or time of a stop order is not guaranteed. The same risks of market orders apply to stop orders.
In addition to the Standard STOP order which is sent to the exchange, we have created 3 new STOP order types. The "Mark" stop order will be triggered once the Mark or value of the asset reaches or surpasses your stop price. The "Bid" stop order will be triggered once the bid of an asset rises to your stop price or surpasses it (this can be used for a Buy Stop order). The "Ask" stop order will be triggered if the ask price falls to your stop price or surpasses it (this can be used for a Sell Stop order).
STOP LIMIT - order used to open or close a position by buying if the market rises or selling if the market falls, but that turns into a limit order when the stop price is triggered. Stop limit orders have a stop price and a limit price. When the stop price is triggered, the limit order is activated. The stop price for buy orders is placed above the current market price. The stop price for sell orders is placed below the current market price. The stop price does not need to be the same as the limit price. Just as with a limit order, the stop limit order will be filled at the limit price or better, but may not be filled at all.
[Combining Stop and TrailingStop is a good strategy]
TRAILING STOP - stop order that continually adjusts the stop price based on changes in the market price. A trailing stop to sell raises the stop price as the market price increases, but does not lower the stop price when the market price decreases. A trailing stop to buy lowers the stop price as the market price decreases, but does not increase the stop price as the market price increases. In both cases, the stop "trails" the market price. When the stop price is reached, the order becomes a market order. The same risk of market orders applies to trailing stops.
[Combining StopLimit and TrailingStopLimit is a good strategy]
TRAILING STOPLIMIT - this order type works the same way as the trailing stop, only instead of a market order being sent to the exchange, a limit order will be sent to the exchange. With this order, you will be able to stipulate the worst price you are willing to accept for a fill. There is no guarantee that you will be filled, though, as the price may gap through your limit price.
MOC (Market on Close) - order that buys or sells at the market price at the close of trading. You must submit the order by 2:40 pm CT. The same risk of market orders applies to MOC orders.
LOC (Limit on Close) - order that buys or sells at a limit price at the close of trading. You must submit the order by 2:40 pm CT. The order can be filled at the limit price or better, but is not guaranteed a fill.
How do OCO orders work?
OCO orders (one cancels other) are orders that work simultaneously and cause a cancel to be sent when one of them fills. OCO Disclaimer: There is no guarantee that the cancel can be sent in time to prevent the second order from filling, leaving you with executions on both orders. It is especially important not to place an OCO order where both component orders are close to the market.
[Combining Stop (StopLimit) and TrailingStop (TrailingStopLimit) is a good strategy]
Trailing stop disclaimer:
thinkorswim does not recommend trailing stop orders, as there is no guarantee that your order will be filled at or near the designated stop price, which is especially dangerous in rapidly rising or falling markets. In addition, trailing stop orders will accentuate volatility in rough markets.
A trailing stop allows you to specify a limit on the maximum possible loss, without setting a limit on the maximum possible gain. A trailing stop SELL (BUY) order is an order where the stop price is set at some fixed amount away from the asset's bid (ask). If the market price rises (falls), the stop loss price also rises (falls) by this fixed amount. If the stock price falls (rises), the stop price remains the same. When the market moves against the position by the set amount, the stop order is triggered, and is submitted as a market order.
For example, XYZ shows a price of 50.00. A customer puts in a trailing stop order to sell at $1.00 below the current bid. A stop order is entered into the system for $49.00. When the bid price rises to $52.00, the stop order price rises to $51.00. When the bid price drops to $51.50, the stop order price remains at $51.00. When the ask price drops to $51.00, the stop order is triggered and submitted as a market order.
NOTE: The market order resulting from a triggered trailing stop order is not guaranteed to execute at any specific price. A trailing stop sell order becomes a market order when the last traded price is less than or equal to the stop price or if the ask price is less than or equal to the stop price (which is determined by the highest bid price after the tralstop is entered.) Trailing stop sell orders for Nasdaq stocks and US equity options are only triggered after two ask prices are less than or equal to the stop price.
A trailing stop buy order becomes a market order when the last traded price is greater than or equal to the stop price (which is set at a specified differential above the lowest offer). Trailing stop buy orders for Nasdaq stocks and US equity options are only triggered after two bid prices are greater than or equal to the stop price. For US equities markets, stop orders will only be elected by prices posted during normal NYSE trading hours.
***
https://www.thinkorswim.com/tos/displayPage.tos?webpage=servicesOrderTypes
What types of orders does thinkorswim accept?
For all listed products, the thinkorswim software accepts
market
limit
stop
MOC - Market On Close
LOC - Limit On Close
trailing stop (read disclaimer below)
stop limit
conditional
OCO - One Cancels Other (read disclaimer below)
For option spreads, the thinkorswim software accepts
limit
conditional
OCO (read disclaimer below)
market
Through our trade desk, we accept ANY order type imaginable.
All orders, except for option spread orders, are executed electronically. Option spreads are executed via open outcry because none of the five option exchanges currently support electronic spread execution. All trade executions and confirmations will be delivered electronically back to the trading application.
Order Type Explained
LIMIT - default order type for all single option, spread and stock orders. The limit price for buy orders is placed below the current market price. The limit price for sell orders is placed above the current market price. Limit orders will be filled at the limit price or better, but are not guaranteed a fill.
MARKET (also known as "not held") - order used to guarantee an execution, but not guarantee a price or time of execution. The risk of market orders is that you have no control over what the execution price is. We strongly suggest you avoid using them with options, especially option spreads.
STOP (also known as "stop loss") - order used to open or close a position by buying if the market rises or selling if the market falls. The stop price for buy orders is placed above the current market price. The stop price for sell orders is placed below the current market price. A stop order turns into a market order when the stop is triggered, so the final execution price or time of a stop order is not guaranteed. The same risks of market orders apply to stop orders.
In addition to the Standard STOP order which is sent to the exchange, we have created 3 new STOP order types. The "Mark" stop order will be triggered once the Mark or value of the asset reaches or surpasses your stop price. The "Bid" stop order will be triggered once the bid of an asset rises to your stop price or surpasses it (this can be used for a Buy Stop order). The "Ask" stop order will be triggered if the ask price falls to your stop price or surpasses it (this can be used for a Sell Stop order).
STOP LIMIT - order used to open or close a position by buying if the market rises or selling if the market falls, but that turns into a limit order when the stop price is triggered. Stop limit orders have a stop price and a limit price. When the stop price is triggered, the limit order is activated. The stop price for buy orders is placed above the current market price. The stop price for sell orders is placed below the current market price. The stop price does not need to be the same as the limit price. Just as with a limit order, the stop limit order will be filled at the limit price or better, but may not be filled at all.
[Combining Stop and TrailingStop is a good strategy]
TRAILING STOP - stop order that continually adjusts the stop price based on changes in the market price. A trailing stop to sell raises the stop price as the market price increases, but does not lower the stop price when the market price decreases. A trailing stop to buy lowers the stop price as the market price decreases, but does not increase the stop price as the market price increases. In both cases, the stop "trails" the market price. When the stop price is reached, the order becomes a market order. The same risk of market orders applies to trailing stops.
[Combining StopLimit and TrailingStopLimit is a good strategy]
TRAILING STOPLIMIT - this order type works the same way as the trailing stop, only instead of a market order being sent to the exchange, a limit order will be sent to the exchange. With this order, you will be able to stipulate the worst price you are willing to accept for a fill. There is no guarantee that you will be filled, though, as the price may gap through your limit price.
MOC (Market on Close) - order that buys or sells at the market price at the close of trading. You must submit the order by 2:40 pm CT. The same risk of market orders applies to MOC orders.
LOC (Limit on Close) - order that buys or sells at a limit price at the close of trading. You must submit the order by 2:40 pm CT. The order can be filled at the limit price or better, but is not guaranteed a fill.
How do OCO orders work?
OCO orders (one cancels other) are orders that work simultaneously and cause a cancel to be sent when one of them fills. OCO Disclaimer: There is no guarantee that the cancel can be sent in time to prevent the second order from filling, leaving you with executions on both orders. It is especially important not to place an OCO order where both component orders are close to the market.
[Combining Stop (StopLimit) and TrailingStop (TrailingStopLimit) is a good strategy]
Trailing stop disclaimer:
thinkorswim does not recommend trailing stop orders, as there is no guarantee that your order will be filled at or near the designated stop price, which is especially dangerous in rapidly rising or falling markets. In addition, trailing stop orders will accentuate volatility in rough markets.
A trailing stop allows you to specify a limit on the maximum possible loss, without setting a limit on the maximum possible gain. A trailing stop SELL (BUY) order is an order where the stop price is set at some fixed amount away from the asset's bid (ask). If the market price rises (falls), the stop loss price also rises (falls) by this fixed amount. If the stock price falls (rises), the stop price remains the same. When the market moves against the position by the set amount, the stop order is triggered, and is submitted as a market order.
For example, XYZ shows a price of 50.00. A customer puts in a trailing stop order to sell at $1.00 below the current bid. A stop order is entered into the system for $49.00. When the bid price rises to $52.00, the stop order price rises to $51.00. When the bid price drops to $51.50, the stop order price remains at $51.00. When the ask price drops to $51.00, the stop order is triggered and submitted as a market order.
NOTE: The market order resulting from a triggered trailing stop order is not guaranteed to execute at any specific price. A trailing stop sell order becomes a market order when the last traded price is less than or equal to the stop price or if the ask price is less than or equal to the stop price (which is determined by the highest bid price after the tralstop is entered.) Trailing stop sell orders for Nasdaq stocks and US equity options are only triggered after two ask prices are less than or equal to the stop price.
A trailing stop buy order becomes a market order when the last traded price is greater than or equal to the stop price (which is set at a specified differential above the lowest offer). Trailing stop buy orders for Nasdaq stocks and US equity options are only triggered after two bid prices are greater than or equal to the stop price. For US equities markets, stop orders will only be elected by prices posted during normal NYSE trading hours.
Thursday, April 9, 2009
My Trading Strategies
My Trading Strategies
combine stop with a trailing stop
http://www.investopedia.com/articles/trading/08/trailing-stop-loss.asp
One of the best ways to maximize the benefits of a trailing stop and a traditional stop loss is to combine them. Yes, you can use both, but it is important to note that initially the trailing stop should be deeper than your regular stop loss. An example of this concept is to have a stop loss set at 2% and the trailing stop at 2.5% so that you are able to trail a stock's price movements without getting stopped early in the game and allowing for some price fluctuation as the stock finds support and momentum. Be sure to cancel your original stop loss when the trailing stop surpasses it.
My Market Info Strategies
trade earnings announcements:
ST price movement depends not on the actual value of the earnings but on expected/actual difference, actual vs sector benchmark, price momentum, support n resistance on chart.
EPS can be GAAP or non-GAAP and most companies announce both. Make sure when you compare estimate vs. actual, you are using either GAAP or non-GAAP on both (TOS software seems to go for non GAAP while Bloomberg does GAAP)
earnings calendar from bloomberg
What is the best source of real-time financial market news as it happens? Check out these and compare: tradethenews, eSignal's RealTimeTraders Pro Newswire
Spread between nasdaq and DOW/S&P
There seems to be a consistent spread between dow and nasdaq indices although they are correlated. How to take advantage of this spread? profit when (1) nasdaq>dow (2) nasdaq<dow or (3) as long as there is the spread.
Strategies
before mkt open, look for companies that made earnings announcements after last close.
a. place a limit BUY order on option with a large LIMIT if you think the underlyer is hot (is there a better one, maybe traillimit or trailstop on BUY?). Can do before the mkt opens.
b. after the BUY goes thru, immediately place a trailingstop (or combine it with a stop).
professional traders sometimes sell shares just before earnings announcements (they made money already and don't want to be exposed to volatility caused after earnings announcement) which can cause momentary price drop. can we take advantage of this?
many companies announce earnings and other financial data during off market hours so there could be a good opportunity to trade during premarket 8-9:30 or after hours 4-6:30. however, only stocks are allowed. what's a strategy here whereby you take advantage of earnings news and buy/sell stocks, at the same time enter options orders to kick in when mkt opens?
many websites and trading apps (like TOS) show earning calendars but how to search on the blue chip companies only? you may have to do this manually i.e. create a list of blue chip companies with announcement dates. know that companies are not required to honor their announcement dates. right after the announcement, i think you can make money by taking an appropriate position (call or put) and putting in another trailstop immediately.
pre-market and after hours trading
look at TOS Times and Sales under "gadgets" to see what prices stocks are trading on various ecns after hours or before mkt open. may be able to assess buy/sell pressures from this info and create appropriate trades right when mkt opens. sam: my idea is that only the pros trade in off hours and mkt open usually follows the price movement in the off hours.
NASDAQ-100 Pre-Market Heatmap
adopt contrarian techniques
http://biz.yahoo.com/etfguide/090417/241_id.html?.&.pf=retirement
My Options Strategies
small but sure intra-day profit on OEX
Look at where the market is going. When you detect a turnaround, quickly take that position and buy (call or put, depending on what direction the turnaround is occurring). Wait to see if your hunch was right.
(A) If Y, do 2 things. (1) set an alert for floor (so that u might wanna sell and mimimize loss) and (2) set an alert for ceiling (so that u can go back and comfortably make a trailstop order). Alternatively, without the alert, you can create an actual stop loss order for (1). Alert(1) gives you the last-minute choice to hold off on selling if you think your position is going to turn around, but don't wait too long. If it is not turning around, your hunch was not right so make another trade outlined in (B).
(B) If N (you hunch was not right), do 2 things. (1) create another order in the direction the market is moving against your original hunch i.e. buy call or put, opposite to your first order. [Don't be so concerned about this second trade because it is almost impossible to lose money on both trades since they are opposite and you will be close to break-even at the worst.] (2) Monitor both of your positions. You are relatively safe. Your piority now should be to minimize loss and to even make some profit but that may not occur intra-day, especially if the market is only moving sideways. So at this point, when you have 2 opposite positions, you want to extend your closing out to another day ot two, whenever the market moves drastically (and they have been generally speaking, especially when it opens). The only caveat is that, if you are only 1 or 2 days away from expiration, the time value decays much faster so the market has to move that much more drastically to break even with 2 positions over 2/3 days. When one trade moves enough that, if you were to close out BOTH positions you would break even, (1) close out the trade that is of a lower value (the one currently moving against market) and (2) immediately create a stop loss or trail stop on the other.
Hopefully you will make profit with (A). If not, at worst, you will break even with (A) and (B). Example, I bot OEX 395 may call (month away from exp) at $14.2 sometime after 10AM when the market was turning around from negative open to when it was just hitting the positive side. I then set a floor alert at BID=$13.9 (looking back this should have been $13.4 to confidently assert the market was moving against me but oh well i lucked out here) and ceiling alert at BID=$15.2. I then got the ceiling alert (whoa lucky me!) after a few minutes (asserting my hunch of turnaround was right) at which point I created a trailstop at -.30 (meaning MKT-.30 most probably with TOS since they don't give you the option to specify MKT-.30, BID-.30 or ASK-.30) when BID=$15.2 and ASK=$15.60 or something (ignore the LAST which was still at $14.2). This tells me MKT was somewhere between $15.2 - $15.6. Anyways the trailstop got triggered and the position was sold at $15.50.
I was comfortable enough to shell out $1300 to $1600 for this one contract and to make about $100-$150 profit like this. I do think this strategy is relatively safe. I should aim to make $500 intra-day profit by either (1) shelling out $5000-$6000 i.e buy 5 contracts or (2) run this strategy multiple times a day (especially when you can afford to watch market turn around on a big piece of news).
I also think this strategy is better than trading a spread because with spread, you are essentially trading both (A) and (B) simultaneously while saving on commission. With this strategy, on the upside, you could potentially make a lot more gain with (A) without (B), while on the downside, you pay an extra commission to take the same position as the spread. I think that extra commission, being the cost of this strategy over the spread strategy, is well worth it.
when to place the 1st (A) trade? (1) right at mkt open - if the previous close was really up or down, then assume mkt open is turning around (2) after mkt open - give 15 mins or so whenever mkt begins to take a turn (may or may not happen though) (3) near the mkt close - if the mkt is moderately higher/lower to much higher/lower, assume the next morning's open will turn around so make the trade at/near mkt close in the opposite direction (4) when a piece of news during mkt seems to break the market trend - usually happens fast, make the trade right away.
On DJX (1/100 of DJIA)
Applies to any any index option: wait until u see a trend (not at the bell or before, give some time to settle). jump in and set a stop. hopefully stop won't trigger. assuming so, create a new TS order with a fairly wide gap (where if stop does trigger on this order, be prapared for a small loss. on the upside, the wide gap shields u from small hiccups and hopefully puts you in a profitable path). then replace the TS with a new one as time goes by, locking in some profit. ** if ur at almost the end of day, n u find that makrket is moving against u, don't make the trail stop kick in yet i.e. make the gap even wider if u can (as long as u can take that extra loss in the worst case scenario). the idea is that, hopefully stop does not trigger and the order remains active at the next open. that's when u may see market swinging back in ur favor (on average, if mkt goes up big on a day, next day it sheds some and vice-versa) or at the worst case, u will lose that extra money u r ok with loosing.
combine stop with a trailing stop
http://www.investopedia.com/articles/trading/08/trailing-stop-loss.asp
One of the best ways to maximize the benefits of a trailing stop and a traditional stop loss is to combine them. Yes, you can use both, but it is important to note that initially the trailing stop should be deeper than your regular stop loss. An example of this concept is to have a stop loss set at 2% and the trailing stop at 2.5% so that you are able to trail a stock's price movements without getting stopped early in the game and allowing for some price fluctuation as the stock finds support and momentum. Be sure to cancel your original stop loss when the trailing stop surpasses it.
make use of margin
how?
My Market Info Strategies
trade earnings announcements:
ST price movement depends not on the actual value of the earnings but on expected/actual difference, actual vs sector benchmark, price momentum, support n resistance on chart.
EPS can be GAAP or non-GAAP and most companies announce both. Make sure when you compare estimate vs. actual, you are using either GAAP or non-GAAP on both (TOS software seems to go for non GAAP while Bloomberg does GAAP)
earnings calendar from bloomberg
What is the best source of real-time financial market news as it happens? Check out these and compare: tradethenews, eSignal's RealTimeTraders Pro Newswire
Spread between nasdaq and DOW/S&P
There seems to be a consistent spread between dow and nasdaq indices although they are correlated. How to take advantage of this spread? profit when (1) nasdaq>dow (2) nasdaq<dow or (3) as long as there is the spread.
Strategies
before mkt open, look for companies that made earnings announcements after last close.
a. place a limit BUY order on option with a large LIMIT if you think the underlyer is hot (is there a better one, maybe traillimit or trailstop on BUY?). Can do before the mkt opens.
b. after the BUY goes thru, immediately place a trailingstop (or combine it with a stop).
professional traders sometimes sell shares just before earnings announcements (they made money already and don't want to be exposed to volatility caused after earnings announcement) which can cause momentary price drop. can we take advantage of this?
many companies announce earnings and other financial data during off market hours so there could be a good opportunity to trade during premarket 8-9:30 or after hours 4-6:30. however, only stocks are allowed. what's a strategy here whereby you take advantage of earnings news and buy/sell stocks, at the same time enter options orders to kick in when mkt opens?
many websites and trading apps (like TOS) show earning calendars but how to search on the blue chip companies only? you may have to do this manually i.e. create a list of blue chip companies with announcement dates. know that companies are not required to honor their announcement dates. right after the announcement, i think you can make money by taking an appropriate position (call or put) and putting in another trailstop immediately.
pre-market and after hours trading
look at TOS Times and Sales under "gadgets" to see what prices stocks are trading on various ecns after hours or before mkt open. may be able to assess buy/sell pressures from this info and create appropriate trades right when mkt opens. sam: my idea is that only the pros trade in off hours and mkt open usually follows the price movement in the off hours.
NASDAQ-100 Pre-Market Heatmap
adopt contrarian techniques
http://biz.yahoo.com/etfguide/090417/241_id.html?.&.pf=retirement
My Options Strategies
small but sure intra-day profit on OEX
Look at where the market is going. When you detect a turnaround, quickly take that position and buy (call or put, depending on what direction the turnaround is occurring). Wait to see if your hunch was right.
(A) If Y, do 2 things. (1) set an alert for floor (so that u might wanna sell and mimimize loss) and (2) set an alert for ceiling (so that u can go back and comfortably make a trailstop order). Alternatively, without the alert, you can create an actual stop loss order for (1). Alert(1) gives you the last-minute choice to hold off on selling if you think your position is going to turn around, but don't wait too long. If it is not turning around, your hunch was not right so make another trade outlined in (B).
(B) If N (you hunch was not right), do 2 things. (1) create another order in the direction the market is moving against your original hunch i.e. buy call or put, opposite to your first order. [Don't be so concerned about this second trade because it is almost impossible to lose money on both trades since they are opposite and you will be close to break-even at the worst.] (2) Monitor both of your positions. You are relatively safe. Your piority now should be to minimize loss and to even make some profit but that may not occur intra-day, especially if the market is only moving sideways. So at this point, when you have 2 opposite positions, you want to extend your closing out to another day ot two, whenever the market moves drastically (and they have been generally speaking, especially when it opens). The only caveat is that, if you are only 1 or 2 days away from expiration, the time value decays much faster so the market has to move that much more drastically to break even with 2 positions over 2/3 days. When one trade moves enough that, if you were to close out BOTH positions you would break even, (1) close out the trade that is of a lower value (the one currently moving against market) and (2) immediately create a stop loss or trail stop on the other.
Hopefully you will make profit with (A). If not, at worst, you will break even with (A) and (B). Example, I bot OEX 395 may call (month away from exp) at $14.2 sometime after 10AM when the market was turning around from negative open to when it was just hitting the positive side. I then set a floor alert at BID=$13.9 (looking back this should have been $13.4 to confidently assert the market was moving against me but oh well i lucked out here) and ceiling alert at BID=$15.2. I then got the ceiling alert (whoa lucky me!) after a few minutes (asserting my hunch of turnaround was right) at which point I created a trailstop at -.30 (meaning MKT-.30 most probably with TOS since they don't give you the option to specify MKT-.30, BID-.30 or ASK-.30) when BID=$15.2 and ASK=$15.60 or something (ignore the LAST which was still at $14.2). This tells me MKT was somewhere between $15.2 - $15.6. Anyways the trailstop got triggered and the position was sold at $15.50.
I was comfortable enough to shell out $1300 to $1600 for this one contract and to make about $100-$150 profit like this. I do think this strategy is relatively safe. I should aim to make $500 intra-day profit by either (1) shelling out $5000-$6000 i.e buy 5 contracts or (2) run this strategy multiple times a day (especially when you can afford to watch market turn around on a big piece of news).
I also think this strategy is better than trading a spread because with spread, you are essentially trading both (A) and (B) simultaneously while saving on commission. With this strategy, on the upside, you could potentially make a lot more gain with (A) without (B), while on the downside, you pay an extra commission to take the same position as the spread. I think that extra commission, being the cost of this strategy over the spread strategy, is well worth it.
when to place the 1st (A) trade? (1) right at mkt open - if the previous close was really up or down, then assume mkt open is turning around (2) after mkt open - give 15 mins or so whenever mkt begins to take a turn (may or may not happen though) (3) near the mkt close - if the mkt is moderately higher/lower to much higher/lower, assume the next morning's open will turn around so make the trade at/near mkt close in the opposite direction (4) when a piece of news during mkt seems to break the market trend - usually happens fast, make the trade right away.
On DJX (1/100 of DJIA)
Applies to any any index option: wait until u see a trend (not at the bell or before, give some time to settle). jump in and set a stop. hopefully stop won't trigger. assuming so, create a new TS order with a fairly wide gap (where if stop does trigger on this order, be prapared for a small loss. on the upside, the wide gap shields u from small hiccups and hopefully puts you in a profitable path). then replace the TS with a new one as time goes by, locking in some profit. ** if ur at almost the end of day, n u find that makrket is moving against u, don't make the trail stop kick in yet i.e. make the gap even wider if u can (as long as u can take that extra loss in the worst case scenario). the idea is that, hopefully stop does not trigger and the order remains active at the next open. that's when u may see market swinging back in ur favor (on average, if mkt goes up big on a day, next day it sheds some and vice-versa) or at the worst case, u will lose that extra money u r ok with loosing.
Subscribe to:
Posts (Atom)