Please help me to complete the script for Pi using tradescript

Hi

Please help me to complete the script for algoZ. I have coded the “buy” alert expression and able to backtest it, but need help in coding the “buy exit” expression. Please find the below code for “buy” alert for your reference.

SET BUYSIG1 = REF(LOW,1) > OPEN = TRUE AND CROSSOVER(LAST,REF(CLOSE,1)) = TRUE

SET BUYSIG2 = OPEN > REF(HIGH,1) = TRUE AND CROSSOVER(LAST,OPEN) = TRUE

SET BUYSIG3 = REF(CLOSE,1) > OPEN = TRUE AND CROSSOVER(LAST,REF(CLOSE,1)) = TRUE

SET BUYSIG4 = REF(CLOSE,1) > OPEN = TRUE AND CROSSOVER(LAST,REF(HIGH,1)) = TRUE

SET BUYSIG5 = REF(CLOSE,1) > OPEN = TRUE AND CROSSOVER(LAST,OPEN) = TRUE

SET BUYSIG6 = REF(CLOSE,1) < OPEN = TRUE AND CROSSOVER(LAST,OPEN) = TRUE

SET BUYSIG7 = REF(CLOSE,1) < OPEN = TRUE AND CROSSOVER(LAST,REF(HIGH,1)) = TRUE

SET BUYSIG8 = REF(CLOSE,1) < OPEN = TRUE AND CROSSOVER(LAST,REF(CLOSE,1)) = TRUE

BUYSIG1 = TRUE OR BUYSIG2 = TRUE OR BUYSIG3 = TRUE OR BUYSIG4 = TRUE OR BUYSIG5 = TRUE OR BUYSIG6 = TRUE OR BUYSIG7 = TRUE OR BUYSIG8 = TRUE

Buy Alert Expression:


(REF (LOW, 1) > OPEN AND CLOSE > REF (CLOSE, 1)) OR (OPEN > REF (HIGH, 1) AND CLOSE > OPEN) OR (REF (CLOSE, 1) > OPEN AND CLOSE > REF (CLOSE, 1)) OR (REF(CLOSE, 1) > OPEN AND CLOSE > REF (HIGH, 1)) OR (REF (CLOSE, 1) > OPEN AND CLOSE > OPEN) OR (REF(CLOSE, 1) < OPEN AND CLOSE > OPEN) OR (REF (CLOSE, 1) < OPEN AND CLOSE > REF (HIGH, 1)) OR (REF (CLOSE, 1) < OPEN AND CLOSE > REF (CLOSE, 1))
2 Likes