Need Help with Pi Strategy

Strategy

Subsequent Two Green candles for Long & Two Red candles for Short.

Rule:

1). The Second candle of the same color should not touch 50% of the previous candle.
2). When the condition (1) & strategy are met , buy or sell signal at the high/low of the second candle.

Target/Exit : 

In case of Buy : 50% from the 1st candle Low and 2nd Candle High (Low-High/2) from the Buy price
In case of Sell : 50% from the 1st candle High and 2nd Candle Low (High-Low/2) from the Sell price

Stop Loss

In case of Buy: Target price difference less from the High price
In case of Sell: Target price difference plus from the Low Price

Try the below expression

Buy Code

REF(CLOSE,2)>REF(CLOSE,3) AND REF(CLOSE,1)>REF(CLOSE,2)AND

SET A= (HIGH+LOW)/2
REF(LOW,1)>REF(A,2)AND
LAST=REF(HIGH,1)

Sell Code

REF(CLOSE,2)<REF(CLOSE,3) AND REF(CLOSE,1)<REF(CLOSE,2)AND

SET A= (HIGH+LOW)/2
REF(HIGH,1)<REF(A,2)AND
LAST=REF(LOW,1)

You can’t code target and stop loss of the above mentioned strategy with Teade script.

Okay. If it is not possible to code target and SL, atleast we can code to generate a buy/sell call based on the strategy and rule so that we can it would be easy to check target and SL after initiating the call.
So, can you code for buy/sell leaving Target and SL.