This is regarding TMA Slope indicator by Nicolas!!
TMA Slope
just wondering if it is possible to make this indicator to a screener…
When ”Buy Only” — once we get the first green histogram to ”buy only” get a signal on the screener eg; 1
When ”Sell Only” — once we get the first red histogram ”Sell only” get a signal on the screener eg; -1
I tried to do this but failed miserably.. is it possible?
Thank you in advance.
Period = 20
edblHigh1 = 0.04
edblLow1 = -0.04
atrPeriod = 100
atr = AverageTrueRange[atrPeriod](close)
dblTma = TriangularAverage[eintPeriod](close)
if barindex>eintPeriod then
dblPrev = dblTma[1]
gadblSlope = ( dblTma - dblPrev ) / atr
if ( gadblSlope[0] > edblHigh1 ) then
if(gadblSlope[0] < gadblSlope[1]) then
gadblUp1 = gadblSlope[0]
gadblUp2 = 0
gadblDn1 = 0
gadblDn2 = 0
gadblMid1 = 0
gadblMid2 = 0
else
gadblUp1 = 0
gadblDn1 = 0
gadblDn2 = 0
gadblUp2 = gadblSlope[0]
gadblMid1 = 0
gadblMid2 = 0
endif
elsif ( gadblSlope[0] < edblLow1 ) then
if(gadblSlope[0] < gadblSlope[1]) then
gadblUp2 = 0
gadblDn1 = 0
gadblUp1 = 0
gadblDn2 = gadblSlope[0]
gadblMid1 = 0
gadblMid2 = 0
else
gadblUp2 = 0
gadblUp1 = 0
gadblDn2 = 0
gadblDn1 = gadblSlope[0]
gadblMid1 = 0
gadblMid2 = 0
endif
else
if(gadblSlope[0] < gadblSlope[1]) then
gadblMid2 = gadblSlope[0]
gadblMid1 = 0
gadblUp1 = 0
gadblUp2 = 0
gadblDn1 = 0
gadblDn2 = 0
else
gadblMid1 = gadblSlope[0]
gadblMid2 = 0
gadblUp1 = 0
gadblUp2 = 0
gadblDn1 = 0
gadblDn2 = 0
endif
endif
endif
if gadblSlope>0 then
offset = edblLow1
else
offset = edblHigh1
endif
Result = 0
IF gadblSlope>edblHigh1 THEN //Buy Only
Result = 1
ELSIF gadblSlope<edblLow1 THEN //Sell Only
Result = -1
ENDIF
SCREENER[result] (result AS "Slope")
Screeners don’t like much -1, try replacing it with 2 at line 74.
Thanks for your response.
I tried replacing it with 2.. but I get loads of other Syntax errors:
I think I’ve not done this right!! 🙁
I cannot check syntax errors on my mobile.
No Problem…@robertogozzi
please if you could have a look at this would be amazing!!!!!
Line 1 should read eintPeriod.
Remove lines 65-69, since Offset was only required to plot on the chart.
Variables having their names starting with gadbl are not used, so they could probably be removed, but I am not sure about that since I did not test the code thoroughly so I suggest that you add this dummy line just before the last line, instead of removing them:
IF gadblup1 OR gadblup2 OR gadbldn1 OR gadbldn2 OR gadblmid1 OR gadblmid2 THEN
ENDIF
remember to use 2 instead of -1.
Hi robertogozzi
Thanks to your help I kinda managed to get this without any errors 🙂 The problem now is it shows all Buy only and Sell only!!
Is it Possible to change this,
When ”Buy Only” — it only reads first 5 green candles only
When ”Sell Only” — it only reads first 5 Red candles only
eintPeriod = 20
edblHigh1 = 0.04
edblLow1 = -0.04
atrPeriod = 100
atr = AverageTrueRange[atrPeriod](close)
dblTma = TriangularAverage[eintPeriod](close)
if barindex>eintPeriod then
dblPrev = dblTma[1]
gadblSlope = ( dblTma - dblPrev ) / atr
if ( gadblSlope[0] > edblHigh1 ) then
if(gadblSlope[0] < gadblSlope[1]) then
gadblUp1 = gadblSlope[0]
gadblUp2 = 0
gadblDn1 = 0
gadblDn2 = 0
gadblMid1 = 0
gadblMid2 = 0
else
gadblUp1 = 0
gadblDn1 = 0
gadblDn2 = 0
gadblUp2 = gadblSlope[0]
gadblMid1 = 0
gadblMid2 = 0
endif
elsif ( gadblSlope[0] < edblLow1 ) then
if(gadblSlope[0] < gadblSlope[1]) then
gadblUp2 = 0
gadblDn1 = 0
gadblUp1 = 0
gadblDn2 = gadblSlope[0]
gadblMid1 = 0
gadblMid2 = 0
endif
else
gadblUp2 = 0
gadblUp1 = 0
gadblDn2 = 0
gadblDn1 = gadblSlope[0]
gadblMid1 = 0
gadblMid2 = 0
endif
else
if(gadblSlope[0] < gadblSlope[1]) then
gadblMid2 = gadblSlope[0]
gadblMid1 = 0
gadblUp1 = 0
gadblUp2 = 0
gadblDn1 = 0
gadblDn2 = 0
else
gadblMid1 = gadblSlope[0]
gadblMid2 = 0
gadblUp1 = 0
gadblUp2 = 0
gadblDn1 = 0
gadblDn2 = 0
endif
endif
IF gadblup1 OR gadblup2 OR gadbldn1 OR gadbldn2 OR gadblmid1 OR gadblmid2 THEN
ENDIF
Result = 0
IF gadblSlope>edblHigh1 THEN //Buy Only
Result = 1
ELSIF gadblSlope<edblLow1 THEN //Sell Only
Result = 2
ENDIF
SCREENER[result] (result AS "Slope")
This is probably due to the high number of items returned (max. 50 allowed on demo account, 100 on real account). You can read how many have been displayed aot of XXXX at the bottom of the screener window.
I may suggest that you duplicate it and run both of them one to search BUY only with lines 67-71 replaced by:
IF gadblSlope>edblHigh1 THEN //Buy Only
Result = 1
ENDIF
and the SELL only one with:
IF gadblSlope<edblLow1 THEN //Sell Only
Result = 2
ENDIF
Hi @roberto
It still reads all of it in the list..
Is there a way to read-only past 5 histograms when BUY ONLY or SELL ONLY means it will show up the new signals.. within 5 histograms?
eintPeriod = 20
edblHigh1 = 0.03
edblLow1 = -0.03
atrPeriod = 100
atr = AverageTrueRange[atrPeriod](close)
dblTma = TriangularAverage[eintPeriod](close)
if barindex>eintPeriod then
dblPrev = dblTma[1]
gadblSlope = ( dblTma - dblPrev ) / atr
if ( gadblSlope[0] > edblHigh1 ) then
if(gadblSlope[0] < gadblSlope[1]) then
gadblUp1 = gadblSlope[0]
gadblUp2 = 0
gadblDn1 = 0
gadblDn2 = 0
gadblMid1 = 0
gadblMid2 = 0
else
gadblUp1 = 0
gadblDn1 = 0
gadblDn2 = 0
gadblUp2 = gadblSlope[0]
gadblMid1 = 0
gadblMid2 = 0
endif
elsif ( gadblSlope[0] < edblLow1 ) then
if(gadblSlope[0] < gadblSlope[1]) then
gadblUp2 = 0
gadblDn1 = 0
gadblUp1 = 0
gadblDn2 = gadblSlope[0]
gadblMid1 = 0
gadblMid2 = 0
endif
else
gadblUp2 = 0
gadblUp1 = 0
gadblDn2 = 0
gadblDn1 = gadblSlope[0]
gadblMid1 = 0
gadblMid2 = 0
endif
else
if(gadblSlope[0] < gadblSlope[1]) then
gadblMid2 = gadblSlope[0]
gadblMid1 = 0
gadblUp1 = 0
gadblUp2 = 0
gadblDn1 = 0
gadblDn2 = 0
else
gadblMid1 = gadblSlope[0]
gadblMid2 = 0
gadblUp1 = 0
gadblUp2 = 0
gadblDn1 = 0
gadblDn2 = 0
endif
endif
IF gadblup1 OR gadblup2 OR gadbldn1 OR gadbldn2 OR gadblmid1 OR gadblmid2 THEN
ENDIF
Result = 0
IF gadblSlope>edblHigh1 THEN //Buy Only
Result = 1
ENDIF
IF gadblSlope<edblLow1 THEN //Sell Only
Result = 2
ENDIF
SCREENER[result] (result AS "Slope")
Line 67 and 71 should read, respectively:
if summation[5](gadblSlope>edblHigh1) then //line 67
if summation[5](gadblSlope<edblLow1) then //line 71
robertogozzi i think it works!! thank you very much for help as always!!