Arbitrage coding

I need help for coding strategy for arbitrage
psudocode for this is -

case 1
when NSE cmp>BSE cmp

entry
if(% difference should be> 0.5%)
then short sell at NSE
and buy at BSE

exit
if(% difference should be<0.2%)
then sell at BSE
and buy at NSE

case 2
when NSE cmp<BSE cmp
entry
if(% difference should be> 0.5%)
then short sell at BSE
and buy at NSE

exit
if(% difference should be<0.2%)
then sell at NSE
and buy at BSE

There are 2 things,

  1. You should not get into arbitrage based on CMP. You should look at Bid/Offer prices in respective market.
  2. For any liquid stocks, it is very hard to find price difference of 0.5% (especially if you are trading intraday). I did a detailed analysis on this some days ago.