Hi can some one help me code this as you can not use the Donchain channels for trading in proreal time.
I have a youtube link explaining the strat https://www.youtube.com/watch?v=icYe2SS3-4M
But if you dont want to watch it and read her it goes.
You use the 200EMA as a filter from when to buy and sell. Price under only sell price over only buy.
Then you want to buy when the Donchian Channels make a new high with the stop loss below the lower Donchian Channels low.
i would also want a trailstopploss to follow the lower band.
The opposite goes for sell.
Hope some one understands and can help. let me know if something is unclear.
Have a nice day and happy trading:)
There you go (not tested):
Defparam CumulateOrders = false
N = 40
LookBack = 50
UpperDonchian = highest[N](high)
LowerDonchian = lowest[N](low)
Sma200 = average[200,0](close)
L1 = close > Sma200
S1 = close < Sma200
L2 = UpperDonchian < UpperDonchian[1]
S2 = LowerDonchian > LowerDonchian[1]
L3 = UpperDonchian[1] = highest[LookBack](UpperDonchian[1])
S3 = LowerDonchian[1] = lowest[LookBack](LowerDonchian[1])
Lcond = L1 and L2 and L3
Scond = S1 and S2 and S3
If Not OnMarket then
NewSL = 0
Else
If PositionPerf > 0 Then
If LongOnMarket then
NewSL = max(NewSL, LowerDonchian)
Else
NewSL = min(NewSL, UpperDonchian)
Endif
Endif
Endif
If Lcond and Not OnMarket then
Buy 1 contract at Market
Set stop Loss abs(close - LowerDonchian[1])
Set Target pProfit 200
Endif
If Scond and Not OnMarket then
Sellshort 1 contract at Market
Set stop Loss abs(close - UpperDonchian[1])
Set Target pProfit 200
Endif
If OnMarket and NewSL > 0 then
Sell at NewSL Stop
Exitshort at NewSL Stop
Endif