Today, many scientific problems require high computational power and storage space. Cloud computing is a model for easy access to different resources such as storage space with minimal need for service provider interaction. The cloud environment has been used for many benefits, but security and privacy issues are important challenges due to outsourcing. On the other hand, task scheduling is a fundamental issue in distributed systems such as cloud computing. Because there are several tasks to be performed that require different resources while resources are limited. Therefore, cloud tasks must be intelligently scheduled so that system performance and provider profitability are maximized. To solve this challenge, various techniques such as gradient-based algorithms for continuous and single-model problems are common. In cloud computing, due to the large search space and complex nature, these algorithms may not provide a suitable solution. Efficient meta-heuristic techniques can deal with these problems and find near-optimal solutions in a reasonable time. In this paper, a security-based scheduling algorithm using an improved Particle Swarm Optimization algorithm is presented. The improved algorithm uses multi adaptive learning to provide diversity in a population. Therefore, a good balance between exploration and exploitation. The proposed task scheduling algorithm simultaneously considers five parameters (i. e., round trip time, load, energy consumption, cost, and security) to provide load balancing and reduce energy consumption. The proposed algorithm is implemented using the CloudSim simulator and compared with the relevant strategies (i. e., CJS, OTSS, GTSA, and JSSS). The simulation results show that the proposed algorithm, considering the characteristics of tasks and resources, has significant efficiency and effectiveness in the cloud environment, especially at high workloads.