Way to tell if market is bull or bear?
Forums › ProRealTime English forum › ProOrder support › Way to tell if market is bull or bear?
- This topic has 8 replies, 4 voices, and was last updated 4 years ago by
robertogozzi.
-
-
06/18/2021 at 12:02 PM #171984
I have an algo that performs well in certain markets – let say for example bear markets.
Is there a function or code with PRT that will help me assess which trend we are currently in? clearly I assume this is a wide open question (how long is the trend etc). But in general, id like to say
If bear market then execute code
elseif
wait 🙂
any ideas?
thanks!
06/18/2021 at 12:21 PM #171985The most classic way is to compare the price against Sma200, but you may prefer different periods.
Another way is to compare the current price agains that of N periods ago.
The best way is trying to spot some Higher Highs and Higher Lows or some Lower Lows and Lower Highs.
Furthers methods can be coded.
06/18/2021 at 12:44 PM #171986Thanks Robert, much appreciated.
its the higher, high – lower, lows code that im really interested in. Was hoping that you or someone else had already done the legwork on this? Something perhaps that could be optimised to to try and find a “sweet spot”, while trying to avoid overfitting of course!
thanks!
06/18/2021 at 1:29 PM #17199106/18/2021 at 3:48 PM #172002I have this code to spot the last 3 HH’s and 3 LL’s, but the main issues with this code are:
- validity of the definituion of HH and LL, I used to scan by a new HH o LL within the last N candles and consider it valid only if there is a reversal pattern (two differently coloured candles)
- lag, after three HH’s and LL’s the trend might be close to reversal
I would try another solution, ROCnRoll Indicator as suggested by GraHal or Sma200 or a combination of other indicators.
The choice of the TF may also affect the decision.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960DEFPARAM DrawOnLastBarOnly = TRUE//DEFPARAM CalculateOnLastBars = 1000////ONCE LB = 5 //5 LookBack periodsLB = max(1,min(999,LB))//ONCE HH1 = 0 //previous Higher HighONCE HHbar1 = 0ONCE HH2 = 0 //previous Higher HighONCE HHbar2 = 0ONCE HH3 = 0 //current Higher HighONCE HHbar3 = 0//ONCE LL1 = 0 //previous Lower LowONCE LLbar1 = 0ONCE LL2 = 0 //previous Lower LowONCE LLbar2 = 0ONCE LL3 = 0 //current Lower LowONCE LLbar3 = 0//ONCE MyTrend = 0Bullish = close > openBearish = close < open//IF summation[2](high = highest[LB](high)) AND Bullish[1] AND Bearish THENHH1 = HH2HHbar1 = HHbar2HH2 = HH3HHbar2 = HHbar3HH3 = max(high,high[1])HHbar3 = BarIndexELSIF summation[2](low = lowest[LB](low)) AND Bearish[1] AND Bullish THENLL1 = LL2LLbar1 = LLbar2LL2 = LL3LLbar2 = LLbar3LL3 = min(low,low[1])LLbar3 = BarIndexENDIF////MyTrend = 0IF ((HH1 < HH2) AND (HH2 < HH3)) AND ((LL1 < LL2) AND (LL2 < LL3)) THENMyTrend = 1ELSIF ((HH1 < HH2) AND (HH2 < HH3)) AND ((LL1 > LL2) OR (LL2 > LL3) OR (LL1 > LL3)) THENMyTrend = 0ELSIF ((LL1 > LL2) AND (LL2 > LL3)) AND ((HH1 > HH2) AND (HH2 > HH3)) THENMyTrend = -1ELSIF ((LL1 > LL2) AND (LL2 > LL3)) AND ((HH1 < HH2) OR (HH2 < HH3) OR (HH1 < HH3)) THENMyTrend = 0ENDIF//DrawText("HH1",HHbar1,HH1 * 1.001)DrawText("HH2",HHbar2,HH2 * 1.001)DrawText("HH3",HHbar3,HH3 * 1.001)//DrawText("LL1",LLbar1,LL1 * 0.999)DrawText("LL2",LLbar2,LL2 * 0.999)DrawText("LL3",LLbar3,LL3 * 0.999)//RETURN MyTrend AS "Trend",0 AS "0"1 user thanked author for this post.
06/18/2021 at 4:57 PM #17200806/18/2021 at 5:24 PM #172010Link to Roberto HH & LL code added as Log 289 here …
1 user thanked author for this post.
06/18/2021 at 9:02 PM #17201506/18/2021 at 11:14 PM #172019I don’t want to tell Lower Lows from Higher Lows (and the other way round), as when I detect 3 LL’s or 3 HH’s I check if they are in the correct order, otherwise I’ll ignore them
-
AuthorPosts
Find exclusive trading pro-tools on