Hello,
I was wondering if someone could help me.
What I want to achieve is a program that looks for two signals over multiple bars.
Yhe idea is that when the ATR on the dow 5 minutechart crosses over the value of 25 and a few bars (not more then 7) later the price crosses under the EMA10 a buy setup is triggered.
If you look at the picture below you see that the trade is triggered also to early.
Hope someone can help me.
Many thanks in advance.
Kind Regards,
Jaldidee
There you go:
DEFPARAM CumulateOrders = FALSE
ONCE MaxBars = 7 //Keep signal alive for a max 7 bars
ONCE Count = 0
MyATR = AverageTrueRange[14](close)
Sma10 = Average[10,0](close)
c1 = MyATR CROSSES OVER 25
c2 = close CROSSES UNDER Sma10
IF c1 = 1 THEN
Count = 1
ELSE
IF c1[1] = 1 THEN
c1 = c1[1]
Count = Count + 1
IF Count > MaxBars THEN
Count = 0
c1 = 0
ENDIF
ENDIF
ENDIF
IF Not OnMarket AND c1 AND c2 THEN
BUY 1 Contract AT Market
c1 = 0
Count = 0
SET TARGET pPROFIT 100
SET STOP pLOSS 50
ENDIF
//graph count
//graph c1
//graph c2
Hello Roberto,
Thank you very much. It works perfectly…
However I have a followup question. Next step is to set an entry, exit and target when both conditions are met.
How would you program that? Because I tried it with the indicator, highest[10] .
I set the entry at highest[10] and i want to ext at higest[10] minus 1* ATR and want to take profit at 2 * ATR.
This works for the entry, but not to set a exit and target, because the program keeps recalculating the value of higest[10] and thus contnually changing the exit and target.
Kind regards,
Jaldidee
There you go:
DEFPARAM CumulateOrders = FALSE
ONCE MaxBars = 7 //Keep signal alive for a max 7 bars
ONCE Count = 0
MyATR = AverageTrueRange[14](close)
Sma10 = Average[10,0](close)
c1 = MyATR CROSSES OVER 25
c2 = close CROSSES UNDER Sma10
IF c1 = 1 THEN
Count = 1
ELSE
IF c1[1] = 1 THEN
c1 = c1[1]
Count = Count + 1
IF Count > MaxBars THEN
Count = 0
c1 = 0
ENDIF
ENDIF
ENDIF
IF c1 AND c2 THEN
Entry = highest[10](high)
SL = Entry - MyATR
TP = Entry + (MyATR * 2)
ENDIF
IF Not OnMarket AND c1 AND c2 THEN
BUY 1 Contract AT Entry STOP
SET TARGET PROFIT TP
SET STOP LOSS SL
c1 = 0
Count = 0
ENDIF
thanked this post