pdrhParticipant
Average
I have an indicator which I copied from the Forums which generates a long entry signal
a=MACD[12,26,9](close)
if (a crosses under 0) then
basso=low
barrabasso=barindex
endif
if a<0 then
if low<basso then
basso=low
barrabasso=barindex
endif
endif
if a crosses over 0 then
DRAWARROWUP(barrabasso, basso-1)coloured(255,255,255)
endif
return
So I thought I could use this in an Algo as below
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
a=MACD[12,26,9](close)
if (a crosses under 0) then
basso=low
barrabasso=barindex
endif
if a<0 then
if low<basso then
basso=low
barrabasso=barindex
endif
endif
LNG=a crosses over 0
if LNG and not longonmarket then
buy 3 contracts at market
endif
set Stop Ploss SL
set target pprofit TP
graph LNG
The algo generates an entry signal which is later than the indicator signal even though the code for the 2 is the same .
Help please
An obvious reason would be that the Indicator generates “in bar” an Entry arrow (works at Tick level), which is not valid any more at the transition to the next bar with the longer timeframe (like 1 hour).
Could that be the situation at hand ?
JSParticipant
Senior
The indicator is “repainting”…
When drawing the “DrawArrowUP”, the indicator uses a bar index (barrabasso) and a value (basso) that do not come from the “MACD crosses under” but from the “Low” values…
This is where it goes wrong, the “Arrow” doesn’t use the values of the “Crosses Under” but of the “Low” value…
If Low<basso then
basso=low
barrabasso=barindex
EndIf
If you don’t use this piece of code, you will get the same signals…
pdrhParticipant
Average
Yes it is repainting. Takes my 88 year old brain a while to see these things sometimes.!