Hi folks!
I am trying to fit this filter into my code, but can not really figure out how to write it in code.
Lets say for example I trade Nasdaq and entry long @ 14216 and it runs to stoploss. Next hour or within 3 days it’s back to 14216 and it takes long again (I want to prevent this) as it is probably in a range (and high chance to run to stoploss again).
If //latest short position lost with entry @ 34 382 Then
//don’t trade short with the interval 0.1% from @34 382 for the next 3 days
endif
if
//latest long position lost with entry @ 34 382 Then
//don’t trade long with the interval 0.1% from @34 382 for the next 3 days
EndIf
Not tested:
ONCE UpperLimit = 0
ONCE LowerLimit = 0
ONCE PerCent = 0.1
IF OnMarket AND Not OnMarket[1] THEN
MyPC = (TradePrice * PerCent / 100)
UpperLimit = TradePrice + MyPC
LowerLimit = TradePrice - MyPC
ENDIF
IF StrategyProfit > StrategyProfit[1] THEN
UpperLimit = 0
LowerLimit = 0
ENDIF
EntryCondition = (((close >= UpperLimit) OR (close <= LowerLimit)) AND (UpperLimit <> LowerLimit)) OR (UpperLimit = LowerLimit)
IF MyLongConditions AND EntryCondition THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF MyShortConditions AND EntryCondition THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
Thank you so much Roberto!
After some thinking what the problem usually is.. The problem often is trendfollowing algos which get in some consonlidation phase. I attached picture to explain it, in the brown box the algo starts long position and in the red box the algo think the trend is short and start short position. But when you zoom out a bit on 1 hour timeframe (this is on DAX) it is pretty simple to see it is in a range.
Does anyone have some ideas how you could prevent lower TF trending algorithms to not in this example enter long in brown zone and short in red zone on 1h timeframe.
All ideas are welcome!
Using MTF (Multiple Time Frames) may help you better detect such periods. There will never be an accurate way to avoid those traps, but for sure higher TFs grant better signals.
If you have never used MTF, you can search that word to be reported many useful links to instructions, blogs, articles and many examples on that subject.
I know MTF will be the perfect fit for this. I know how to use MTF, I just wanted to know if someone had some good ideas in terms of code for not trading in ranges like this.