Hello Nicolas,
Before to test this strategy I’d like to understand what “xClose” is standing for..
Can you explain?
Thank you one more time…!
For information here’s what my code looks like:
DEFPARAM CumulateOrders = false
// Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
DEFPARAM FLATBEFORE = 080000
// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
DEFPARAM FLATAFTER = 173000
//Heikin-Ashi
xClose = (Open+High+Low+Close)/4
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
endif
Green = xClose>xOpen
Period=30 // 48 34
inner = 2*weightedaverage[ round( Period/2 ) ](xclose)-weightedaverage[Period](xclose)
MMHULL=weightedaverage[ round( sqrt(Period) ) ]( inner )
macross = xclose crosses over MMHULL
if green[1] and macross and green then
buy at market
endif
set target pprofit 7// EN 1 MIN 9 7
set stop ploss 31 // EN 1 MIN 11 31
What I don’t get is the clos and why it keeps opening position 1 bar “too late”, is there a way to make it one bar before for the entry?
xClose is the variable that hold the HeikinAshi candlestick Close value.
Positions are not opened too late: code is read at Close, positions are opened at next bar Open.
Ok so waht is the xOpen standing for? The previous candle opening?
xOpen is the variable for the Heikin Ashi Open value.
HeikinAshi candlesticks are smoothing the price, that’s why they give different values than the real price and therefore need to be calculated.
I get it but why calculate xClose and not xOpen then?
To be precise, the only point I don’t get is this calculation:
xOpen = (xOpen[1] + xClose[1])/2
What is it calculating?
Green = xClose>xOpen
harange = abs(xclose-xopen)
“Green” is a condition showing when the current candle is above the previous candle
“harange” is calculating the abs value of an evolution
So when you write:
harange>harange[1]
It returns “Green” but on previous candles right?
I get it but why calculate xClose and not xOpen then?
To be calculated xOpen need at least 1 xClose, that’s why we wait 2 barindex before its calculation:
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
endif
“Green” is a condition showing when the current candle is above the previous candle
No. Green is a boolean condition to test if xClose is superior to xOpen (a green Heikin Ashi candle), if it is true, green=1.
I strongly recommend you to watch the training videos for programming, the first course is free 😉
harange>harange[1] is testing if the current range is superior to its previous one, like the way you want in your initial request. Number in brackets is an offset in the past.