Market Sentiment Filter Analysis
Forums › ProRealTime English forum › General trading discussions › Market Sentiment Filter Analysis
- This topic has 14 replies, 3 voices, and was last updated 5 years ago by Vonasi.
Tagged: analysis, sentiment filter
-
-
02/26/2019 at 10:41 PM #92405
I just got to thinking about market sentiment filters. Usually we like to add a filter to our strategies that says only trade long if this condition and only trade short if not this condition – for example go only long if above MA200 and only go short if below MA200…. and I got to thinking that wouldn’t it be nice if we could quantify these filters so as to ensure that we are using a good one for the instrument that we are trading. My initial idea is to count green candles when long filter is valid and count red candles when short filter is valid. This way we can give a ‘quality rating’ to our sentiment filter so as to compare various filters. Another thought is to count median price rises and median price drops compared to the last candle. Maybe even several different types of quality ratings could improve the overall rating?
I’d be interested if anybody has any ideas on how best to decide on quality and also maybe a list of common sentiment filters to test it on. My end idea is to create a simple indicator that can be applied to any chart and any time frame and which then decides which is the best sentiment filter to use to improve a strategy.
1 user thanked author for this post.
02/26/2019 at 11:36 PM #92415Here’s a start of a code to show the sort of thing that I was thinking of:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647f1 = close > average[200]f2 = close > weightedaverage[200]f3 = ROC[22] > ROC[22][1]f4 = close > close[300]up1 = close > openup2 = medianprice > medianprice[1]up3 = weightedclose > weightedclose[1]up4 = typicalprice > typicalprice[1]up5 = totalprice > totalprice[1]for a = 1 to 5if a = 1 thenup = up1endifif a = 2 thenup = up2endifif a = 3 thenup = up3endifif a = 4 thenup = up4endifif a = 5 thenup = up5endifif (f1 and up) or (not f1 and not up) thenfilter1 = filter1 + 1endifif (f2 and up) or (not f2 and not up) thenfilter2 = filter2 + 1endifif (f3 and up) or (not f3 and not up) thenfilter3 = filter3 + 1endifif (f4 and up) or (not f4 and not up) thenfilter4 = filter4 + 1endifnextreturn filter1 as "MA", filter2 as "WA", filter3 as "ROC", filter4 as "LookBack"It can be seen that based on five different quality gauges the ROC[22] sentiment filter scores a far higher sentiment filter quality rating than the average filters or the look back filter.
02/26/2019 at 11:43 PM #92418I’m thinking that it might be better to write it as a fake strategy as that way we can optimize a variable so as to see a bigger range of sentiment filters. The other option is another for next loop and some code to identify which filter is the highest scoring of them all. Maybe I am already overcomplicating it!
02/27/2019 at 12:07 AM #92422I realised that there is a flaw in my code as it is recording quality and filter conditions met on the same candle where in reality we need to check filter conditions as being met on the previous candle and then record the quality on the current candle. Here is the modified code so far with some added filters:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768f1 = close > average[200]f2 = close > weightedaverage[200]f3 = ROC[14] > ROC[14][1]f4 = close > close[300]f5 = macd[26,12,9] > macd[26,12,9][1]f6 = stochastic[10,5] > stochastic[10,5][1]f7 = rsi[14] > rsi[14][1]f8 = close > exponentialaverage[200]up1 = close > openup2 = medianprice > medianprice[1]up3 = weightedclose > weightedclose[1]up4 = typicalprice > typicalprice[1]up5 = totalprice > totalprice[1]for a = 1 to 5if a = 1 thenup = up1endifif a = 2 thenup = up2endifif a = 3 thenup = up3endifif a = 4 thenup = up4endifif a = 5 thenup = up5endifif (f1[1] and up) or (not f1[1] and not up) thenfilter1 = filter1 + 1endifif (f2[1] and up) or (not f2[1] and not up) thenfilter2 = filter2 + 1endifif (f3[1] and up) or (not f3[1] and not up) thenfilter3 = filter3 + 1endifif (f4[1] and up) or (not f4[1] and not up) thenfilter4 = filter4 + 1endifif (f5[1] and up) or (not f5[1] and not up) thenfilter5 = filter5 + 1endifif (f6[1] and up) or (not f6[1] and not up) thenfilter6 = filter6 + 1endifif (f7[1] and up) or (not f7[1] and not up) thenfilter7 = filter7 + 1endifif (f8[1] and up) or (not f8[1] and not up) thenfilter8 = filter8 + 1endifnextreturn filter1 as "MA", filter2 as "WA", filter3 as "ROC", filter4 as "LookBack", filter5 as "MACD", filter6 as "Stoch", filter7 as "RSI", filter8 as "EMA"RSI[14] rising or falling is currently showing as the best quality sentiment filter on EURUSD Daily.
02/27/2019 at 7:51 AM #92440Hello Vonasi,
Maybe we can add a Point Pivot filter, so wheter the price is above or below is 1H Pivot?
12345678910111213IF Openhour <> openhour[1] THENmyLastHigh = myHighmyLastLow = myLowmyLastClose = Close[1]myHigh = HighmyLow = Lowmyopen=openELSEmyHigh = Max(myHigh, High)myLow = Min(myLow, Low)ENDIFPP = (myLastHigh + myLastLow + myLastClose) / 302/27/2019 at 9:07 AM #92442At the moment I am trying to stick to daily charts but your code and some other filter ideas that I have had have raised the issue that the way it is coded at the moment only allows for sentiment filters where a condition is either met or not met rather than two slightly different conditions that toggle between bullish and bearish (for example your high and low pivot breaks) – so I may have to rethink the way it is coded.
Another thought that I had was that it might make an interesting strategy idea. Quality ratings for each sentiment filter could be recorded and then each new candle checked to see which conditions it meets and given an overall quality rating for bullish or bearish. The quality rating would need to be normalized by dividing the latest result by the number of candles so far so the chart would be more like this:
02/27/2019 at 9:21 AM #9244502/27/2019 at 9:36 AM #92448That is an interesting new way of looking at it jebus89! Within your strategy you would need to check what filter conditions are met at each entry order and flag them as being met and then check to see if it is a profit or non profit trade at the exit and score each relevant filter accordingly and then reset the flags. With straight market orders it should be do-able and even possible with pending orders if you check that the levels were hit. It is too difficult to do if there are multiple positions but very possible for single positions.
02/27/2019 at 9:42 AM #92450Here is my first slightly messy attempt to give each filter a rating and then check the current candle to see which filters it meets and give it an overall rating. if the line is below zero then it indicates short and the further below the stronger the signal.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131f1 = close > average[200]f2 = close > weightedaverage[200]f3 = ROC[14] > ROC[14][1]f4 = close > close[300]f5 = macd[26,12,9] > macd[26,12,9][1]f6 = stochastic[10,5] > stochastic[10,5][1]f7 = rsi[14] > rsi[14][1]f8 = close > exponentialaverage[200]f9 = weightedaverage[100] > weightedaverage[200]up1 = close > openup2 = medianprice > medianprice[1]up3 = weightedclose > weightedclose[1]up4 = typicalprice > typicalprice[1]up5 = totalprice > totalprice[1]thisbar = 0for a = 1 to 5if a = 1 thenup = up1endifif a = 2 thenup = up2endifif a = 3 thenup = up3endifif a = 4 thenup = up4endifif a = 5 thenup = up5endifif (f1[1] and up) thenfilter1 = filter1 + 1thisbar = thisbar + filter1endifif (not f1[1] and not up) thenfilter1 = filter1 + 1thisbar = thisbar - filter1endifif (f2[1] and up) thenfilter2 = filter2 + 1thisbar = thisbar + filter2endifif (not f2[1] and not up) thenfilter2 = filter2 + 1thisbar = thisbar - filter2endifif (f3[1] and up) thenfilter3 = filter3 + 1thisbar = thisbar + filter3endifif (not f3[1] and not up) thenfilter3 = filter3 + 1thisbar = thisbar - filter3endifif (f4[1] and up) thenfilter4 = filter4 + 1thisbar = thisbar + filter4endifif (not f4[1] and not up) thenfilter4 = filter4 + 1thisbar = thisbar - filter4endifif (f5[1] and up) thenfilter5 = filter5 + 1thisbar = thisbar + filter5endifif (not f5[1] and not up) thenfilter5 = filter5 + 1thisbar = thisbar - filter5endifif (f6[1] and up) thenfilter6 = filter6 + 1thisbar = thisbar + filter6endifif (not f6[1] and not up) thenfilter6 = filter6 + 1thisbar = thisbar - filter6endifif (f7[1] and up) thenfilter7 = filter7 + 1thisbar = thisbar + filter7endifif (not f7[1] and not up) thenfilter7 = filter7 + 1thisbar = thisbar - filter7endifif (f8[1] and up) thenfilter8 = filter8 + 1thisbar = thisbar + filter8endifif (not f8[1] and not up) thenfilter8 = filter8 + 1thisbar = thisbar - filter8endifif (f9[1] and up) thenfilter9 = filter9 + 1thisbar = thisbar + filter9endifif (not f9[1] and not up) thenfilter9 = filter9 + 1thisbar = thisbar - filter9endifnextresult1 = filter1/barindexresult2 = filter2/barindexresult3 = filter3/barindexresult4 = filter4/barindexresult5 = filter5/barindexresult6 = filter6/barindexresult7 = filter7/barindexresult8 = filter8/barindexresult9 = filter9/barindexthisbar = (thisbar/barindex)/9return result1 as "MA", result2 as "WA", result3 as "ROC", result4 as "LookBack", result5 as "MACD", result6 as "Stoch", result7 as "RSI", result8 as "EMA", result9 as "Two WA", thisbar as "This Bar"02/27/2019 at 9:46 AM #9245302/27/2019 at 9:48 AM #9245602/27/2019 at 11:00 AM #92457Sorry I thought it was intraday. But Daily Pivot Point are widely use for trading equity index, so curious on this compares to other indicators.
1234567891011121314// POINT PIVOT JOURNALIERIF dayofweek = 1 THENdayhigh = DHigh(2)daylow = DLow(2)dayclose = DClose(2)ENDIFIF dayofweek >=2 and dayofweek < 6 THENdayhigh = DHigh(1)daylow = DLow(1)dayclose = DClose(1)ENDIFPPDay = (dayhigh + daylow + dayclose) / 302/27/2019 at 12:22 PM #92458stefou102 – How would you set the sentiment filter condition? Today’s pivot is higher or lower than yesterdays pivot? The close is higher or lower than the pivot? I feel it would be a bit choppy as a sentiment filter but we can try something.
Here is the code with the two above filters added and the results with the ‘This Bar’ result hidden.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168filterqty = 11//PPDay CalculationsIF dayofweek = 1 THENdayhigh = DHigh(2)daylow = DLow(2)dayclose = DClose(2)ENDIFIF dayofweek >=2 and dayofweek < 6 THENdayhigh = DHigh(1)daylow = DLow(1)dayclose = DClose(1)ENDIFPPDay = (dayhigh + daylow + dayclose) / 3f1 = close > average[200]f2 = close > weightedaverage[200]f3 = ROC[14] > ROC[14][1]f4 = close > close[300]f5 = macd[12,26,9] > macd[12,26,9][1]f6 = stochastic[10,5] > stochastic[10,5][1]f7 = rsi[14] > rsi[14][1]f8 = close > exponentialaverage[200]f9 = weightedaverage[100] > weightedaverage[200]f10 = ppday > ppday[1]f11 = close > ppdayup1 = close > openup2 = medianprice > medianprice[1]up3 = weightedclose > weightedclose[1]up4 = typicalprice > typicalprice[1]up5 = totalprice > totalprice[1]thisbar = 0for a = 1 to 5if a = 1 thenup = up1endifif a = 2 thenup = up2endifif a = 3 thenup = up3endifif a = 4 thenup = up4endifif a = 5 thenup = up5endifif (f1[1] and up) thenfilter1 = filter1 + 1thisbar = thisbar + filter1endifif (not f1[1] and not up) thenfilter1 = filter1 + 1thisbar = thisbar - filter1endifif (f2[1] and up) thenfilter2 = filter2 + 1thisbar = thisbar + filter2endifif (not f2[1] and not up) thenfilter2 = filter2 + 1thisbar = thisbar - filter2endifif (f3[1] and up) thenfilter3 = filter3 + 1thisbar = thisbar + filter3endifif (not f3[1] and not up) thenfilter3 = filter3 + 1thisbar = thisbar - filter3endifif (f4[1] and up) thenfilter4 = filter4 + 1thisbar = thisbar + filter4endifif (not f4[1] and not up) thenfilter4 = filter4 + 1thisbar = thisbar - filter4endifif (f5[1] and up) thenfilter5 = filter5 + 1thisbar = thisbar + filter5endifif (not f5[1] and not up) thenfilter5 = filter5 + 1thisbar = thisbar - filter5endifif (f6[1] and up) thenfilter6 = filter6 + 1thisbar = thisbar + filter6endifif (not f6[1] and not up) thenfilter6 = filter6 + 1thisbar = thisbar - filter6endifif (f7[1] and up) thenfilter7 = filter7 + 1thisbar = thisbar + filter7endifif (not f7[1] and not up) thenfilter7 = filter7 + 1thisbar = thisbar - filter7endifif (f8[1] and up) thenfilter8 = filter8 + 1thisbar = thisbar + filter8endifif (not f8[1] and not up) thenfilter8 = filter8 + 1thisbar = thisbar - filter8endifif (f9[1] and up) thenfilter9 = filter9 + 1thisbar = thisbar + filter9endifif (not f9[1] and not up) thenfilter9 = filter9 + 1thisbar = thisbar - filter9endifif (f10[1] and up) thenfilter10 = filter10 + 1thisbar = thisbar + filter10endifif (not f10[1] and not up) thenfilter10 = filter10 + 1thisbar = thisbar - filter10endifif (f11[1] and up) thenfilter11 = filter11 + 1thisbar = thisbar + filter11endifif (not f11[1] and not up) thenfilter11 = filter11 + 1thisbar = thisbar - filter11endifnextresult1 = filter1/barindexresult2 = filter2/barindexresult3 = filter3/barindexresult4 = filter4/barindexresult5 = filter5/barindexresult6 = filter6/barindexresult7 = filter7/barindexresult8 = filter8/barindexresult9 = filter9/barindexresult10 = filter10/barindexresult11 = filter11/barindexthisbar = (thisbar/barindex)/filterqtyreturn result1 as "MA", result2 as "WA", result3 as "ROC", result4 as "LookBack", result5 as "MACD", result6 as "Stoch", result7 as "RSI", result8 as "EMA", result9 as "Two WA", result10 as "PPDay-PPDay[1]", result11 as "Close-PPDay", thisbar as "This Bar"It appears that comparing close to PPDay is a pretty good sentiment filter on the EURUSD although this is a bit like saying what is the probability of price going up tomorrow if price closes above the pivot point? Not really a market filter but maybe something that improves our chance of being right tomorrow!
02/27/2019 at 6:19 PM #92479Indeed the simple theory around Pivot Point is if price is above daily pivot point, this is bullish and vice versa. For traders, Pivot Points and their extention S1/S2/S3 R1/R1/R3 give support and resistance level, which in conjunction with more classical resistance/support drawing (previous high/low, bollinger bands, etc), can confirm some strong inflexion price, certainly when the market is not in “one direction” mode.
So if I understand well your work, pivot point and RSI both stand out as quality filter so far?
02/27/2019 at 6:55 PM #92482So if I understand well your work, pivot point and RSI both stand out as quality filter so far?
The whole concept of giving a quality rating to filter conditions is still a work in progress in its early stages. I have only so far tested on one instrument and I have not even really gone through the code with a fine tooth comb to make sure that it is doing what I think it is doing so I would not use any of the results as the basis for deciding on a filter for a strategy just yet!
Unfortunately I am busy at the moment with other non trading related projects and so I am really only giving this a few minutes at a time when I get a chance to.
-
AuthorPosts
Find exclusive trading pro-tools on