How to code average gain point of three latest bull candle and average loss Point of three bear candle

 
please help me to code code average gain point of three latest bull candle and average loss Point of three latest bear candle
 
Help you with what? You haven't stated a problem. Show us your attempt and state the nature of your problem.
Reason: