#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © gokhanpirnal
#indicator("GP - Long Short Scanner",shorttitle = 'GP - Long Short Scanner',
# Converted by Sam4Cok@Samer800 - 09 / 2023
input srcOpen = open;
input srcHigh = high;
input srcLow = low;
input srcClose = close;
input tsiLongLength = 1;
input tsiShortLength = 1;
input tsiSignalLength = 2;
input rsiLength = 2;
def na = Double.NaN;
#double_smoothopen(srcopen, long, short) =>
script double_smooth {
input srcopen = open;
input long = 1;
input short = 1;
def fist_smoothopen = ExpAverage(srcopen, long);
def sec_smoothopen = ExpAverage(fist_smoothopen, short);
plot out = sec_smoothopen;
}
def priceopen = open;
def pcopen = (priceopen - priceopen[1]);
def double_smoothed_pcopen = double_smooth(pcopen, tsiLongLength, tsiShortLength);
def double_smoothed_abs_pcopen = double_smooth(AbsValue(pcopen), tsiLongLength, tsiShortLength);
def tsi_valueopen = 100 * (double_smoothed_pcopen / double_smoothed_abs_pcopen);
def rsiopen = RSI(Price = srcopen, Length = rsiLength);
def topen = tsi_valueopen + ExpAverage(tsi_valueopen, tsiSignalLength) + rsiopen;
def totalopen = topen;
def pricehigh = high;
def pchigh = (pricehigh - pricehigh[1]);
def double_smoothed_pchigh = double_smooth(pchigh, tsiLongLength, tsiShortLength);
def double_smoothed_abs_pchigh = double_smooth(AbsValue(pchigh), tsiLongLength, tsiShortLength);
def tsi_valuehigh = 100 * (double_smoothed_pchigh / double_smoothed_abs_pchigh);
def rsihigh = RSI(Price = srchigh, Length = rsiLength);
def thigh = tsi_valuehigh + ExpAverage(tsi_valuehigh, tsiSignalLength) + rsihigh;
def totalhigh = thigh;
def pricelow = low;
def pclow = (pricelow - pricelow[1]);
def double_smoothed_pclow = double_smooth(pclow, tsiLongLength, tsiShortLength);
def double_smoothed_abs_pclow = double_smooth(AbsValue(pclow), tsiLongLength, tsiShortLength);
def tsi_valuelow = 100 * (double_smoothed_pclow / double_smoothed_abs_pclow);
def rsilow = RSI(Price = srclow, Length = rsiLength);
def tlow = tsi_valuelow + ExpAverage(tsi_valuelow, tsiSignalLength) + rsilow;
def totallow = tlow;
def priceclose = close;
def pcclose = (priceclose - priceclose[1]);
def double_smoothed_pcclose = double_smooth(pcclose, tsiLongLength, tsiShortLength);
def double_smoothed_abs_pcclose = double_smooth(AbsValue(pcclose), tsiLongLength, tsiShortLength);
def tsi_valueclose = 100 * (double_smoothed_pcclose / double_smoothed_abs_pcclose);
def rsiclose = RSI(Price = srcclose, Length = rsiLength);
def tclose = (tsi_valueclose + ExpAverage(tsi_valueclose, tsiSignalLength) + rsiclose);
def totalclose = tclose;
def minmin = Min(totalopen, Min(totalhigh, Min(totallow, totalclose)));
def min = if isNaN(min[1]) then 0 else
Min(min[1], minmin);
def maxmax = Max(totalopen, Max(totalhigh, Max(totallow, totalclose)));
def max = if isNaN(max[1]) then 0 else
Max(max[1], maxmax);
def mindata = min;
def maxdata = max;
def totalmin=(mindata + totalclose);
def totalmaks=(maxdata + totalclose);
def longsart1=(if totalmin[1]<=(-390) then 1 else 0);
def longsart2=(if mindata[1]==totalclose[1] then 1 else 0);
def longsart3=(if mindata <totalclose then 1 else 0);
def shortsart1=(if totalmaks[1]>=587 then 1 else 0);
def shortsart2=(if maxdata[1]==totalclose[1] then 1 else 0);
def shortsart3=(if maxdata > totalclose then 1 else 0);
def minplot=(longsart1+longsart2+longsart3);
def maksplot=(shortsart1+shortsart2+shortsart3);
def EnterLong=(minplot[0]>2.9);
def EnterShort=(maksplot[0]>2.9);
AddChartBubble(EnterLong, low, "L", Color.GREEN, no);# title='Long Alarm'
AddChartBubble(EnterShort, high, "S", Color.RED);# title='Short Alarm'
# End of CODE