In this paper a method for optimal selection of analyzing window for generalized S-transform has been proposed. The S-transform is applied to the signal and the Smatrix is computed, firstly. Then, a concentration measure is introduced which can be calculated according to S-matrix. At last, the Particle Swarm Optimization (PSO) algorithm is employed to select an analyzing window which presents the best time-frequency resolution by minimizing the concentration measure. To evaluate the effectiveness of the proposed method, it has been implemented in Matlab environment and has been tested on the two most popular Gaussian and hyperbolic windows. Then, the improved S-transform has been applied to two sample signal cases and time-frequency contours have been plotted, accordingly. Also, the standard non-optimized Stransform has been implemented. The time-frequency resolutions of optimized Gaussian and hyperbolic windows have been compared to the time-frequency resolution presented by standard S-transform. It is found that both optimized hyperbolic as well as Gaussian widows provide a better time-frequency representation in comparison to non-optimal standard window.