Announcement

Collapse
No announcement yet.

Backtesting my function f(x) with bars

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Backtesting my function f(x) with bars

    Dear forum members,

    I'm quite new in using esignal and its functionality. I've never created a script with the esignal script language.

    I would be very glad if some members could help in programming the following backtesting strategy (EFS)

    My description:
    I have created a function called f(x) and plotted in chart type = histogram (see attached)

    The script should color the histgram GREEN in a upwards trend and RED in a downwards trend. The colored bars are only useful to see the trend. For my backtesting, the script should include a trading strategy: BUYING if the bars turns to green on closed prize and SELLING when the bars turn to red on closed prize. All stocks are sold or bought at the same time.

    An example:
    1st day: histogram value(HV) = 0.12
    2nd day: HV = 0.13 (TradingStrategy = BUY)
    3rd day: HV = 0.15
    4th day: HV = 0.16
    5th day: HV = 0.16
    6th day: HV = 0.13 ((TradingStrategy = SELL)
    7th day: HV = 0.10
    8th day: HV = 0.05
    9th day: HV = -0.01
    10th day: HV = -0.04
    11th day: HV = -0.04
    12th day: HV = -0.02 (TradingStrategy = BUY)
    etc.

    How I can compare the current bar with the prevous bar and the delta will generate a buying or selling signal. Important: In a upward trend the selling signal will be generated when current bar < previous bar and in a downward trend the buying signal will be generated when current bar > previous bar.

    Thanks a lot for your help to create a backtesting strategy.
    Attached Files
Working...
X