1. Start if the time is 09:35 AM Indian Standard time "Buy if the 5 days Exponential moving average is crossing above 20 days exponential moving average 2. sell & sell if the 5 days exponential moving average is crossing below 20 days exponential moving average 3. Buy & buy if the 5 days Exponential moving average is crossing above 20 days exponential moving average 4. Square off order if the time is 03:15 PM Indian Standard Time if not met criteria 5 days exponential moving average is crossing below 20 days exponential moving average. (Please note this example may change as per the open position if the position is of selling then square will be of buying and if the previous position if of buying then the square off will be of selling.) For an Example: if the very first order is placed of buy (100 quantity of a particular stock) when 5 days Exponential moving average is crossing above 20 days exponential moving average. then it should sell (200 quantity of the same stock) when 5 days exponential moving average is crossing below 20 days exponential moving average then again it should buy(200 quantity of a particular stock/indices) when 5 days Exponential moving average is crossing above 20 days exponential moving average if now the timing of stock market is on verge of closing then it should square off the trade if not meeting criteria of sell (100 quantity of the same stock) when 5 days exponential moving average is crossing below 20 days exponential moving average. (Please note at the time of square off it should not take the double quantity since we are closing all the open position at End of Day) also it will be great if the days of exponential moving is not limited to 5 days and 20 days. i should get an option of changing the days of exponential moving average as per my need for an example if i want to go for 7 days Exponential moving average against 11 days exponential average then it should just take the candels i mentioned when placing the order or if needed be i just need to change the days in the script so that i can run it accordingly. having said that i need a script wherein it should automatically place buy and sell order everytime the lower timeframe exponential moving average is crossing above or below the higher timeframe exponential moving average. So the first opening & the last closing trade should have single quantity order rest in the middle should have order of double quantity which will close the previous open trade and simultaneouly open the new trade. Please note: the EMA i mentioned in days please consider it as a candle, On 15 mins timeframe it should represent the 5 EMA candle & not day. Please let me know if this make sense.