Request for coding

A candle starts at 1 pm and. ends at 1.30 pm Buy when the price goes above high of this candle. Stop at mid of the candle. Take profit at 100% candle height, above the buy price. Similarly, vice versa for sell below low of the candle. Please provide me the code for back testing in pi. Regards, Senthil

if you are looking for 30 min candle time frame , use the below


If it is 11am candle, then code will be
LAST> REF(HIGH,11). ???
Pls also provide codes for the following

  1. stop loss, which is 50% of candle height (ex. High 100, Low 90, then stop loss is (100-(100-90)/2)=95.
  2. Take profit at 100% of candle height ( 100-90+100)=110.
  3. Alternate codes for Take profit using trailing stop with a gap of 7 points.