Exit long and short Stoploss square off Enter at a Delay Ehler Fisher Crossover

Want the code for the following so that the strategy can be backtested in pi on below mentioned set of criterias.

  1. How do i define Exit long position when price target is achieved by 5% or may be 10 points after the entry point/buy price

  2. How do i define fixed Stoploss of 5% or may be 10 points.

  3. How do i define a trailing stop loss

  4. How to define, if i want to say that any long/short positions should be squared off at the end of the day/3:35pm

  5. How to define that do not enter any new position after 3:00pm even if appropriate signals are generated by the strategy.

  6. I want to enter LONG only after 1 candle when MACD crossover has already happened and MACD is still > MACD signal line. (Means, suppose it is a 30 min candle and MACD crossover signal is generated at the close of 10:00am candle, then enter at open of 11:00am candle if still MACD > MACD signal.)

  7. Please code Ehler Fisher Transform and Ehler Fisher Transform Trigger Crossover.

1. you can use price alert indicator and define your price.

Buy Script:


Sell Script:


2. The stop loss also you can define same as above.

3. Trailing stop loss can not be defined by tradescript you can use bracket order , for more information follow this link

4. you can not define for square off , as such by tradescript you have to do it manually.

5.That option is not available

6. Buy Script

SET A = MACDSignal(13, 26, 9, SIMPLE)
SET B = MACD(13, 26, 9, SIMPLE)

you have to use the time frame as 30 minute candle as per your condition.

7. Ehler Fisher Transform can not be coded by tradescript,

Specify conditions in brief  so that it can be coded

  1. Please do not mind…but still i am not convinced…if its a algo trading back testing then how would i know that at which point i have a entry signal and really specify that exit long when CLOSE>8445.40, the entry signal is different all the time so should be the exit point.
  2. You created a MACD crossover, thats ok. But where is the delay of one candle that i had asked for?
  3. Buy: Ehler Fisher Transform > Ehler Fisher Transform Trigger
    Sell: Ehler Fisher Transform Trigger > Ehler Fisher Transform