Hi,
I wish to code a function that buy when price goes down x % from the top (highest that day), and then up x % from the bottom (lowest that day) during the same day. But I can’t 🙂
So if price goes down 0,5% it should not buy direct, but wait for a 0,1% rise from the bottom that day.
The wait for a rise is just a try to protect from further downs – say price falls 0,5% but then continue to 0,9%.
Can I use DHigh(0)?
If close < DHigh(0) – x then… ?
if close > DLow(0) + x then
buy at market
endif
Endif
I will also probably use a time filter and maybe another price filter to determinate trend, but thats another story 🙂
Thanks!
All the best!
Simon
Hi Simon, you should have a look at this screener: http://www.prorealcode.com/prorealtime-market-screeners/fibonacci-61-8-retracement/
Its code should help you how to determine retracement percentage from recent highest high and lowest low.
Thanks Nicolas! I tried this:
DEFPARAM CumulateOrders=false
if intradaybarindex = 0 then
openbuy=0
endif
Starttime = time >090000 and time <140000
Down = close < DHigh(0)*0.986
//0.995
// optimize mini 0.985 max 0.995 step 0.001
Up = close > DLow(0)*1.005
//1.001
// optimize mini 1.001 max 1.01 step 0.001
If starttime and down then
if up and openbuy=0 then
buy at market
openbuy = openbuy+1
endif
endif
If time >170000 then
sell at market
endif
I wish to run it on 5-min. TF. Probably on DAX.
Dose it make sense?
Is DHigh(0) and DLow(0) calculated from 00:00 on a new day? Can I make it so it is calculated from 09.00 when market opens?
All the best!
Simon
The daily OHLC are always calculated from the very first intraday bar.
Of course you can calculate yourself a customized OHLC from a different start hour.