Profit taking in percentage

How to book profit of 50% of stock after the 2% of last buy/short price and stoploss at 1%

@sudhansu - See How to ask a good question.

Suppose i bought 1000 quantity of stock at price 100 (when certain condition met for buy signal). I want to sell 500 quantity (50% of the original quantity of stock bought) of stock when the price will reach 102 price level and the remaining 500 quantity of stock will be sold of when certain condition will met for sell order. But the entire stock will be sold off when the price will dropped down to 99 price level i.e. a stop loss order. Please guide me how to write code for this?

hello @sudhansu
The code you asking for this system, is already exist in the Amibroker User's Guide.

Example 4: partial exit (scaling out) on profit target stops

Example of code that exits 50% on first profit target, 50% on next profit target and everything at trailing stop: