Hello,
I would like to build a code which will buy when the price made a pull back of 50% of the current wave.
I would like to set up manually the top and the bottom of the wave when i launch the strategy but if the price continue rising i would need the code to update the new highest and calculate the new level of 50%.
I tried this code which is not working properly:
defparam preloadbars=10000
bottom = 19844
originaltop = 19966
hh = highest[barindex](high)
IF hh > originaltop THEN
top = hh
ENDIF
IF hh < originaltop THEN
top = originaltop
ENDIF
fib50 = ((top - bottom) / 2) + bottom
c1 = low[0] <= fib50
IF c1 AND not onmarket THEN
BUY 1 CONTRACT AT MARKET
ENDIF
I tried to backtest it with the graphonprice function but the barindex doesn’t take in consideration the exact period of time i want to test and rather takes all the previous data which bring back a wrong value.
GRAPHONPRICE fib50
I would be very gratefull if someone could help me on this matter.
Thanks a lot
Christophe