This indicator can help you find out what condition or set of conditions might give you an edge in any market. It can check through all of history and record what price did after any condition or any set of conditions occurred.
This indicator only works on PRTv11 onwards.
You set ‘projection’ to how many bars after an event you want to analyse.
You can change line 10 in the code to be any condition or set of conditions that you wish to analyse. So for example it could be something like any of the following:
The options are endless.
The indicator returns three lines drawn ‘projection’ bars into the future from the close of the last candle on the chart.
The blue line is our datum and is a line calculated from what happened after every bar on the chart. If this line curves upwards then we are trading a market that has a long tendency. If it curves down then it has a short tendency. If it is fairly level then the market might be considered to be more of a mean reversal market.
The green line shows what happened on average after a candle which met our condition/s occurred. If it is above the blue line then that is an edge. If it is below then it is a condition that gives a disadvantage.
The red line shows what happened on average after a candle which did not meet our condition/s occurred. If it is above the blue line then there is an edge to trading candles that do not meet our condition/s. If it is below then not meeting our condition gives a disadvantage.
The lines are labelled. The first number is the sample size or quantity of candles that either met our condition/s or did not meet our condition/s and for the datum line it is the total number of candles tested to get our datum.
The second number is the difference between the end of the projection line and the start of it. You can set a spread amount and this is then deducted off this result so you can see if the edge is big enough over ‘projection’ bars to actually overcome the spread.
The third number on the datum line is the percentage gain or loss compared to the start of the datum line. For the green condition met and red condition not met lines it is the difference of percentage to the datum line.
I advise downloading and importing to get full functionality.
//Edge Finder and Condition Tester
//PRTv11
//By Vonasi
//20200413
//projections = 100
//spread = 0
//Change this line to whatever condition or set of conditions you want to test
condition = stochastic[10,3] > stochastic[10,3][1] and close > average[10] and low > low[1]
if barindex > projection then
if condition[projection] then
condcount = condcount + 1
for a = 1 to projection
$cond[a] = $cond[a] + ((close[projection-a] - close[projection])/close[projection])
$condcount[a] = $condcount[a]+1
$condavg[a] = $cond[a]/$condcount[a]
next
endif
if not condition[projection] then
notcondcount = notcondcount + 1
for a = 1 to projection
$notcond[a] = $notcond[a] + ((close[projection-a] - close[projection])/close[projection])
$notcondcount[a] = $notcondcount[a]+1
$notcondavg[a] = $notcond[a]/$notcondcount[a]
next
endif
for a = 1 to projection
datumcount = datumcount + 1
$datum[a] = $datum[a] + ((close[projection-a] - close[projection])/close[projection])
$datumcount[a] = $datumcount[a]+1
$datumavg[a] = $datum[a]/$datumcount[a]
next
endif
if islastbarupdate then
lasty = close
lasty2 = close
lasty3 = close
for a = 1 to projection
drawsegment(barindex+a-1,lasty,barindex+a,lasty+(close*$condavg[a]))coloured(0,128,0)
drawsegment(barindex+a-1,lasty2,barindex+a,lasty2+(close*$notcondavg[a]))coloured(128,0,0)
drawsegment(barindex+a-1,lasty3,barindex+a,lasty3+(close*$datumavg[a]))coloured(0,0,255)
lasty = lasty+(close*$condavg[a])
lasty2 = lasty2+(close*$notcondavg[a])
lasty3 = lasty3+(close*$datumavg[a])
next
condresult = lasty-close-spread
notcondresult = lasty2-close-spread
datumresult = lasty3-close-spread
condperc = round((condresult/close)*100,1)
notcondperc = round((notcondresult/close)*100,1)
datumperc = round((datumresult/close)*100,1)
condperc = condperc-datumperc
notcondperc = notcondperc-datumperc
drawtext(" Condition [#condcount#] [#condresult#] [#condperc#%]",barindex+a+30,lasty,sansserif,bold,10)
drawtext("Not Condition [#notcondcount#] [#notcondresult#] [#notcondperc#%]",barindex+a+30,lasty2,sansserif,bold,10)
drawtext(" Datum [#datumcount#] [#datumresult#] [#datumperc#%]",barindex+a+30,lasty3,sansserif,bold,10)
endif
return