0% found this document useful (0 votes)
35 views15 pages

New Text Document

Uploaded by

zomezero56
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views15 pages

New Text Document

Uploaded by

zomezero56
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 15

}

input_group {
"Filter | Fast MA",
colorFastMaline = input { default = rgba(4, 252, 38, 0.80), type = input.color
},
widthFastMaline = input { default = 1, type = input.line_width },
showFastMAFilter = input { default = false, type = input.plot_visibility },
}

input_group {
"Filter | Medium MA",
colorMediumMaline = input { default = rgba(252, 4, 34, 0.80), type =
input.color },
widthMediumMaline = input { default = 1, type = input.line_width },
showMediumMAFilter = input { default = false, type = input.plot_visibility },
}

input_group {
"Filter | Slow MA",
colorSlowMaline = input { default = rgba(156, 155, 155, 0.80), type =
input.color },
widthSlowMaline = input { default = 1, type = input.line_width },
showSlowMAFilter = input { default = false, type = input.plot_visibility },
}

-- Returns MA input selection variant, default to SMA if blank or typo


local function variant(type, src, len)
v1 = sma(src, len) -- SMA
v2 = ema(src, len) -- EMA
v3 = wma(src, len) -- WMA
v4 = vwma(src, len) -- VWMA
231 v5 = smma(src, len) -- SMMA
232 v6 = dema(src, len) -- DEMA
233 v7 = tema(src, len) -- TEMA
234 v8 = hma(src, len) -- HMA
235 v9 = ssma(src, len) -- Super Smoother (SSMA)
236 v10 = zema(src, len) -- Zero Lag (ZEMA)
237 v11 = tma(src, len) -- Triangular MA (TMA)

238 if type == "EMA" then return v2


239 elseif type == "WMA" then return v3
240 elseif type == "VWMA" then return v4
241 elseif type == "SMMA" then return v5
242 elseif type == "DEMA" then return v6
243 elseif type == "TEMA" then return v7
244 elseif type == "HMA" then return v8
245 elseif type == "SSMA" then return v9
246 elseif type == "ZEMA" then return v10
247 elseif type == "TMA" then return v11
248 else return v1 end -- SMA
249 end

250 -- SERIES VARIABLES --


251 local upperDC = highest(high, lengthDC)
252 local lowerDC = lowest(low, lengthDC)
253 local middleDC = (upperDC + lowerDC) / 2

254 -- SuperTrend
255 local atr = rma(tr, SPd)
256 local h = hl2 - (SFactor * atr)
257 local l = hl2 + (SFactor * atr)

258 local atr_ts = iff(close[1] > nz(atr_ts[1], 0) and close[1] > nz(atr_ts[1], 0),
259 max(nz(atr_ts[1], 0), h - atr),
260 iff(close[1] < nz(atr_ts[1], 0) and close[1] < nz(atr_ts[1], 0),
261 min(nz(atr_ts[1], 0), l + atr),
262 atr_ts[1])
263 )

264 local pos = iff(close[1] > nz(atr_ts[1], 0) and close[1] > nz(atr_ts[1], 0), 1,
265 iff(close[1] < nz(atr_ts[1], 0) and close[1] < nz(atr_ts[1], 0), -1,
nz(pos[1], 0)))
266
267 local STrend = pos
268 local Tsl = atr_ts

269 -- Entry
270 local entries = {
271 { name = "Candle X SMA5", func = CandleXSMA5 },
272 { name = "Candle X DC", func = CandleXDC },
273 { name = "Candle X SuperTrend", func = CandleXSuperTrend },
274 { name = "SMA3 X DC", func = SMA3XDC },
275 { name = "SMA3 X SuperTrend", func = SMA3XSuperTrend },
276 { name = "RRRGG/GGRR", func = RRRGG },
277 { name = "Engulfing", func = Engulfing },
278 { name = "Hammer/Shooting", func = HammerShooting },
279 { name = "Candle X out BB", func = CandleXOutBB },
280 { name = "Fractal", func = Fractal },
281 { name = "Big Pips", func = BigPips },
282 { name = "Rejection BB", func = RejectionBB },
283 { name = "MACD Cross", func = MACDCross }
284 }

285 -- For Developer


286 local function CandleXSMA5(UpDn)
287 if UpDn == "UP" then
288 local order = close > ma_slowE and open < ma_slowE and abs(open -
close) > body_ratio * abs(high - low)
289 return order, ma_slowE
290 elseif UpDn == "DN" then
291 local order = close < ma_slowE and open > ma_slowE and abs(open -
close) > body_ratio * abs(high - low)
292 return order, ma_slowE
293 end
294 end

295 local function SMA3XDC(UpDn)


296 if UpDn == "UP" then
297 local order = ma_fastE > ma_dcf[1] and ma_fastE < ma_dcf[1]
298 return order, value
299 elseif UpDn == "DN" then
300 local order = ma_fastE < ma_dcf[1] and ma_fastE > ma_dcf[1]
301 return order, value
302 end
303 end

304 local function SMA3XSuperTrend(UpDn)


305 if UpDn == "UP" then
306 local order = ma_fastE > ma_tsl and ma_fastE < ma_tsl
307 return order, value
308 elseif UpDn == "DN" then
309 local order = ma_fastE < ma_tsl and ma_fastE > ma_tsl
310 return order, value
311 end
312 end

313 local function createFilterFunction(UpDn)


314 local filterUp = close > get_value(Tsl[1]) and STrend > 0
315 local filterDn = close < get_value(Tsl[1]) and STrend < 0
316 local valueUpf = Tsl
317 local valueDnf = Tsl

318 if UpDn == "UP" then


319 return filterUp, valueUpf
320 elseif UpDn == "DN" then
321 return filterDn, valueDnf
322 end
323 end

324 local function adxtrend(UpDn)


325 local filterUp = pdi > mdi and adx > 15
326 local filterDn = pdi < mdi and adx > 15
327 local valueUpf = close
328 local valueDnf = close

329 if UpDn == "UP" then


330 return filterUp, valueUpf
331 elseif UpDn == "DN" then
332 return filterDn, valueDnf
333 end
334 end

335 local function psartrend(UpDn)


336 local filterUp = close > psarx
337 local filterDn = close < psarx
338 local valueUpf = close
339 local valueDnf = close

340 if UpDn == "UP" then


341 return filterUp, valueUpf
342 elseif UpDn == "DN" then
343 return filterDn, valueDnf
344 end
345 end

346 -- Filter Indicators


347 local filterIndicators = {
348 supertrend, -- 1
349 ma3trend, -- 2
350 dctrend, -- 3
351 rsitrend, -- 4
352 stotrend, -- 5
353 adxtrend, -- 6
354 psartrend, -- 7
355 macdtrend, -- 8
356 bullbeartrend, -- 9
357 }

358 local arrayFiltBuy, arrayFiltSell, arrayFiltvalueBuy, arrayFiltvalueSell = {},


{}, {}, {}

359 local function createFilterAndValue(indicator)


360 local filtUP, valfiltUP = indicator("UP")
361 local filtDN, valfiltDN = indicator("DN")
362 return filtUP, filtDN, valfiltUP, valfiltDN
363 end

364 for k = 1, #filterIndicators, 1 do


365 local filterUP, filterDN, valuefilterUP, valuefilterDN =
createFilterAndValue(filterIndicators[k])
366 table.insert(arrayFiltBuy, filterUP)
367 table.insert(arrayFiltSell, filterDN)
368 table.insert(arrayFiltvalueBuy, valuefilterUP)
369 table.insert(arrayFiltvalueSell, valuefilterDN)
370 end

371 -- Calculation of Indicators


372 -- Your calculation logic for indicators goes here

373 -- Plotting the Indicators


374 -- Your plotting logic goes here

375 -- Additional functions and logic


376 -- Include any additional functions or logic you need

377 -- Example: MACD Calculation


378 local function macd(src, shortLen, longLen, signalLen)
379 local macdLine = ema(src, shortLen) - ema(src, longLen)
380 local signalLine = ema(macdLine, signalLen)
381 local hist = macdLine - signalLine
382 return macdLine, signalLine, hist
383 end

384 -- Example: Plot MACD


385 local macdLine, signalLine, hist = macd(close, 12, 26, 9)
386 plot(macdLine, color = color.blue, title = "MACD Line")
387 plot(signalLine, color = color.red, title = "Signal Line")
388 plot(hist, color = color.green, style = plot.style_histogram, title = "MACD
Histogram")

389 -- Logic for Buy and Sell Signals


390 -- Include the logic for generating buy and sell signals

391 -- Example: Buy Signal


392 local buySignal = close > ma_fastE and close < ma_slowE
393 if buySignal then
394 -- Execute buy logic
395 end

396 -- Example: Sell Signal


397 local sellSignal = close < ma_fastE and close > ma_slowE
398 if sellSignal then
399 -- Execute sell logic
400 end
401 -- End of Script
402 -- Any cleanup or finalization code

403 return {
404 -- Your return values if needed
405 }
406 -- Additional Calculations and Logic
407 -- Add any specific calculations or logic required for your indicators

408 -- Example: RSI Calculation


409 local function rsi(src, length)
410 local gain = max(change(src), 0)
411 local loss = -min(change(src), 0)
412 local avgGain = rma(gain, length)
413 local avgLoss = rma(loss, length)
414 local rs = avgGain / avgLoss
415 return 100 - (100 / (1 + rs))
416 end

417 -- Example: Plot RSI


418 local rsiValue = rsi(close, 14)
419 plot(rsiValue, color = color.purple, title = "RSI")

420 -- Additional Indicator Logic


421 -- Add logic for any additional indicators you are using

422 -- Example: Stochastic Calculation


423 local function stochastic(high, low, close, length)
424 local highestHigh = highest(high, length)
425 local lowestLow = lowest(low, length)
426 local k = 100 * (close - lowestLow) / (highestHigh - lowestLow)
427 local d = sma(k, 3)
428 return k, d
429 end

430 -- Example: Plot Stochastic


431 local k, d = stochastic(high, low, close, 14)
432 plot(k, color = color.orange, title = "Stochastic %K")
433 plot(d, color = color.red, title = "Stochastic %D")

434 -- Logic for Complex Conditions


435 -- Add any complex conditions for your script

436 -- Example: Complex Buy Condition


437 local complexBuyCondition = buySignal and rsiValue < 30 and k > d
438 if complexBuyCondition then
439 -- Execute complex buy logic
440 end

441 -- Example: Complex Sell Condition


442 local complexSellCondition = sellSignal and rsiValue > 70 and k < d
443 if complexSellCondition then
444 -- Execute complex sell logic
445 end

446 -- Indicator Combinations


447 -- Combine multiple indicators to create robust trading signals

448 -- Example: Combined Buy Signal


449 local combinedBuySignal = buySignal and (rsiValue < 30 or k > d)
450 if combinedBuySignal then
451 -- Execute combined buy logic
452 end

453 -- Example: Combined Sell Signal


454 local combinedSellSignal = sellSignal and (rsiValue > 70 or k < d)
455 if combinedSellSignal then
456 -- Execute combined sell logic
457 end

458 -- Visualization of Entry and Exit Points


459 -- Add markers for entry and exit points

460 -- Example: Plot Buy Signal


461 if combinedBuySignal then
462 plotshape(combinedBuySignal, title = "Buy Signal", location =
location.belowbar, color = color.green, style = shape.labelup, text = "BUY")
463 end

464 -- Example: Plot Sell Signal


465 if combinedSellSignal then
466 plotshape(combinedSellSignal, title = "Sell Signal", location =
location.abovebar, color = color.red, style = shape.labeldown, text = "SELL")
467 end

468 -- Advanced Functions and Utilities


469 -- Add any advanced functions or utility functions here

470 -- Example: Moving Average Convergence Divergence (MACD) Calculation


471 local function macdAdvanced(src, shortLen, longLen, signalLen)
472 local macdLine = ema(src, shortLen) - ema(src, longLen)
473 local signalLine = ema(macdLine, signalLen)
474 local hist = macdLine - signalLine
475 return macdLine, signalLine, hist
476 end

477 -- Example: Plot Advanced MACD


478 local macdLineAdv, signalLineAdv, histAdv = macdAdvanced(close, 12, 26, 9)
479 plot(macdLineAdv, color = color.blue, title = "MACD Line Advanced")
480 plot(signalLineAdv, color = color.red, title = "Signal Line Advanced")
481 plot(histAdv, color = color.green, style = plot.style_histogram, title = "MACD
Histogram Advanced")

482 -- Signal Generation Logic


483 -- Add logic for generating signals based on combined indicators

484 -- Example: Generate Buy Signal


485 local function generateBuySignal()
486 return close > ma_fastE and rsiValue < 30 and k > d
487 end

488 -- Example: Generate Sell Signal


489 local function generateSellSignal()
490 return close < ma_fastE and rsiValue > 70 and k < d
491 end

492 -- Execute Buy and Sell Logic


493 if generateBuySignal() then
494 -- Execute buy logic
495 end

496 if generateSellSignal() then


497 -- Execute sell logic
498 end

499 -- Additional Utility Functions


500 -- Add any additional utility functions here

501 -- Example: Calculate Average True Range (ATR)


502 local function atr(src, length)
503 local tr = max(high - low, abs(high - close[1]), abs(low - close[1]))
504 return rma(tr, length)
505 end

506 -- Example: Plot ATR


507 local atrValue = atr(close, 14)
508 plot(atrValue, color = color.yellow, title = "ATR")

509 -- Final Script Section


510 -- Add any final logic or cleanup code here

511 -- Return Values (if any)


512 return {
513 combinedBuySignal = combinedBuySignal,
514 combinedSellSignal = combinedSellSignal,
515 rsiValue = rsiValue,
516 k = k,
517 d = d,
518 macdLine = macdLine,
519 signalLine = signalLine,
520 hist = hist,
521 }

522 -- Indicator and Filter Functions (continued)


523 local function ma3trend(UpDn)
524 local ma3 = sma(close, 3)
525 local filterUp = close > ma3
526 local filterDn = close < ma3
527 local valueUpf = close
528 local valueDnf = close

529 if UpDn == "UP" then


530 return filterUp, valueUpf
531 elseif UpDn == "DN" then
532 return filterDn, valueDnf
533 end
534 end

535 local function dctrend(UpDn)


536 local dcUpper = highest(high, lengthDC)
537 local dcLower = lowest(low, lengthDC)
538 local middleDC = (dcUpper + dcLower) / 2
539 local filterUp = close > middleDC
540 local filterDn = close < middleDC
541 local valueUpf = middleDC
542 local valueDnf = middleDC
543 if UpDn == "UP" then
544 return filterUp, valueUpf
545 elseif UpDn == "DN" then
546 return filterDn, valueDnf
547 end
548 end

549 local function rsitrend(UpDn)


550 local rsiValue = rsi(close, 14)
551 local filterUp = rsiValue < 30
552 local filterDn = rsiValue > 70
553 local valueUpf = rsiValue
554 local valueDnf = rsiValue

555 if UpDn == "UP" then


556 return filterUp, valueUpf
557 elseif UpDn == "DN" then
558 return filterDn, valueDnf
559 end
560 end

561 local function stotrend(UpDn)


562 local k, d = stochastic(high, low, close, 14)
563 local filterUp = k > d
564 local filterDn = k < d
565 local valueUpf = k
566 local valueDnf = d

567 if UpDn == "UP" then


568 return filterUp, valueUpf
569 elseif UpDn == "DN" then
570 return filterDn, valueDnf
571 end
572 end

573 local function macdtrend(UpDn)


574 local macdLine, signalLine, hist = macd(close, 12, 26, 9)
575 local filterUp = macdLine > signalLine
576 local filterDn = macdLine < signalLine
577 local valueUpf = macdLine
578 local valueDnf = signalLine

579 if UpDn == "UP" then


580 return filterUp, valueUpf
581 elseif UpDn == "DN" then
582 return filterDn, valueDnf
583 end
584 end

585 local function bullbeartrend(UpDn)


586 local maFast = sma(close, 9)
587 local maSlow = sma(close, 21)
588 local filterUp = maFast > maSlow
589 local filterDn = maFast < maSlow
590 local valueUpf = maFast
591 local valueDnf = maSlow

592 if UpDn == "UP" then


593 return filterUp, valueUpf
594 elseif UpDn == "DN" then
595 return filterDn, valueDnf
596 end
597 end

598 -- Filter Arrays for Different Indicators


599 local filterIndicators = {
600 supertrend, -- 1
601 ma3trend, -- 2
602 dctrend, -- 3
603 rsitrend, -- 4
604 stotrend, -- 5
605 adxtrend, -- 6
606 psartrend, -- 7
607 macdtrend, -- 8
608 bullbeartrend, -- 9
609 }

610 local arrayFiltBuy, arrayFiltSell, arrayFiltvalueBuy, arrayFiltvalueSell = {},


{}, {}, {}

611 local function createFilterAndValue(indicator)


612 local filtUP, valfiltUP = indicator("UP")
613 local filtDN, valfiltDN = indicator("DN")
614 return filtUP, filtDN, valfiltUP, valfiltDN
615 end

616 for k = 1, #filterIndicators, 1 do


617 local filterUP, filterDN, valuefilterUP, valuefilterDN =
createFilterAndValue(filterIndicators[k])
618 table.insert(arrayFiltBuy, filterUP)
619 table.insert(arrayFiltSell, filterDN)
620 table.insert(arrayFiltvalueBuy, valuefilterUP)
621 table.insert(arrayFiltvalueSell, valuefilterDN)
622 end

623 -- Complex Signal Generation


624 -- Example: Generate Complex Buy Signal
625 local function generateComplexBuySignal()
626 return combinedBuySignal and rsiValue < 30 and k > d
627 end

628 -- Example: Generate Complex Sell Signal


629 local function generateComplexSellSignal()
630 return combinedSellSignal and rsiValue > 70 and k < d
631 end

632 -- Execute Complex Buy and Sell Logic


633 if generateComplexBuySignal() then
634 -- Execute complex buy logic
635 end

636 if generateComplexSellSignal() then


637 -- Execute complex sell logic
638 end

639 -- Final Cleanup and Return Values


640 return {
641 combinedBuySignal = combinedBuySignal,
642 combinedSellSignal = combinedSellSignal,
643 rsiValue = rsiValue,
644 k = k,
645 d = d,
646 macdLine = macdLine,
647 signalLine = signalLine,
648 hist = hist,
649 }

650 -- Developer's Filters and Arrays for Final Integration


651 local arrayEntryBuy, arrayEntrySell, arrayValueBuy, arrayValueSell = {}, {},
{}, {}

652 -- For Developer: Create Entry Arrays


653 table.insert(arrayEntryBuy, entryUP)
654 table.insert(arrayEntrySell, entryDN)
655 table.insert(arrayValueBuy, valueUP)
656 table.insert(arrayValueSell, valueDN)

657 -- For Developer: Create Filter Function


658 local function supertrend(UpDn)
659 local filterUp = close > get_value(Tsl[1]) and STrend > 0
660 local filterDn = close < get_value(Tsl[1]) and STrend < 0
661 local valueUpf = Tsl
662 local valueDnf = Tsl

663 if UpDn == "UP" then


664 return filterUp, valueUpf
665 elseif UpDn == "DN" then
666 return filterDn, valueDnf
667 end
668 end

669 -- ADX Filter Function


670 local function adxtrend(UpDn)
671 local filterUp = pdi > mdi and adx > 15
672 local filterDn = pdi < mdi and adx > 15
673 local valueUpf = close
674 local valueDnf = close

675 if UpDn == "UP" then


676 return filterUp, valueUpf
677 elseif UpDn == "DN" then
678 return filterDn, valueDnf
679 end
680 end

681 -- PSAR Filter Function


682 local function psartrend(UpDn)
683 local filterUp = close > psarx
684 local filterDn = close < psarx
685 local valueUpf = close
686 local valueDnf = close

687 if UpDn == "UP" then


688 return filterUp, valueUpf
689 elseif UpDn == "DN" then
690 return filterDn, valueDnf
691 end
692 end

693 -- Combining All Filters


694 local filterIndicators = {
695 supertrend, -- 1
696 ma3trend, -- 2
697 dctrend, -- 3
698 rsitrend, -- 4
699 stotrend, -- 5
700 adxtrend, -- 6
701 psartrend, -- 7
702 macdtrend, -- 8
703 bullbeartrend, -- 9
704 }

705 local arrayFiltBuy, arrayFiltSell, arrayFiltvalueBuy, arrayFiltvalueSell = {},


{}, {}, {}

706 local function createFilterAndValue(indicator)


707 local filtUP, valfiltUP = indicator("UP")
708 local filtDN, valfiltDN = indicator("DN")
709 return filtUP, filtDN, valfiltUP, valfiltDN
710 end

711 for k = 1, #filterIndicators, 1 do


712 local filterUP, filterDN, valuefilterUP, valuefilterDN =
createFilterAndValue(filterIndicators[k])
713 table.insert(arrayFiltBuy, filterUP)
714 table.insert(arrayFiltSell, filterDN)
715 table.insert(arrayFiltvalueBuy, valuefilterUP)
716 table.insert(arrayFiltvalueSell, valuefilterDN)
717 end

718 -- Plot Combined Filters


719 for i = 1, #arrayFiltBuy do
720 plot(arrayFiltBuy[i], color = color.green, title = "Filtered Buy")
721 end

722 for i = 1, #arrayFiltSell do


723 plot(arrayFiltSell[i], color = color.red, title = "Filtered Sell")
724 end

725 -- Utility Function: Calculate True Range


726 local function trueRange()
727 return max(high - low, abs(high - close[1]), abs(low - close[1]))
728 end

729 -- Utility Function: Calculate ATR


730 local function averageTrueRange(length)
731 return rma(trueRange(), length)
732 end

733 -- Plot ATR


734 local atrValue = averageTrueRange(14)
735 plot(atrValue, color = color.yellow, title = "Average True Range")

736 -- Buy and Sell Conditions with Filters


737 local function generateFilteredBuySignal()
738 return combinedBuySignal and all(arrayFiltBuy)
739 end

740 local function generateFilteredSellSignal()


741 return combinedSellSignal and all(arrayFiltSell)
742 end

743 if generateFilteredBuySignal() then


744 -- Execute filtered buy logic
745 end

746 if generateFilteredSellSignal() then


747 -- Execute filtered sell logic
748 end

749 -- Final Cleanup and Return


750 return {
751 combinedBuySignal = combinedBuySignal,
752 combinedSellSignal = combinedSellSignal,
753 rsiValue = rsiValue,
754 k = k,
755 d = d,
756 macdLine = macdLine,
757 signalLine = signalLine,
758 hist = hist,
759 atrValue = atrValue
760 }

761 -- Indicator Arrays and Filter Functions for Developer


762 local arrayFiltBuy, arrayFiltSell, arrayFiltvalueBuy, arrayFiltvalueSell = {},
{}, {}, {}

763 local function createFilterAndValue(indicator)


764 local filtUP, valfiltUP = indicator("UP")
765 local filtDN, valfiltDN = indicator("DN")
766 return filtUP, filtDN, valfiltUP, valfiltDN
767 end

768 for k = 1, #filterIndicators, 1 do


769 local filterUP, filterDN, valuefilterUP, valuefilterDN =
createFilterAndValue(filterIndicators[k])
770 table.insert(arrayFiltBuy, filterUP)
771 table.insert(arrayFiltSell, filterDN)
772 table.insert(arrayFiltvalueBuy, valuefilterUP)
773 table.insert(arrayFiltvalueSell, valuefilterDN)
774 end

775 -- Plot Filtered Signals


776 for i = 1, #arrayFiltBuy do
777 plot(arrayFiltBuy[i], color = color.green, title = "Filtered Buy Signal")
778 end

779 for i = 1, #arrayFiltSell do


780 plot(arrayFiltSell[i], color = color.red, title = "Filtered Sell Signal")
781 end

782 -- Generate Combined Signals


783 local combinedBuySignal = generateFilteredBuySignal()
784 local combinedSellSignal = generateFilteredSellSignal()
785 if combinedBuySignal then
786 -- Execute combined buy logic
787 end

788 if combinedSellSignal then


789 -- Execute combined sell logic
790 end

791 -- Final Return Values


792 return {
793 combinedBuySignal = combinedBuySignal,
794 combinedSellSignal = combinedSellSignal,
795 rsiValue = rsiValue,
796 k = k,
797 d = d,
798 macdLine = macdLine,
799 signalLine = signalLine,
800 hist = hist,
801 atrValue = atrValue
802 }

803 -- Developer's Filters and Arrays for Final Integration


804 local filterIndicators = {
805 supertrend, -- 1
806 ma3trend, -- 2
807 dctrend, -- 3
808 rsitrend, -- 4
809 stotrend, -- 5
810 adxtrend, -- 6
811 psartrend, -- 7
812 macdtrend, -- 8
813 bullbeartrend, -- 9
814 }

815 local arrayFiltBuy, arrayFiltSell, arrayFiltvalueBuy, arrayFiltvalueSell = {},


{}, {}, {}

816 -- Create Filter and Value Arrays for Developer


817 local function createFilterAndValue(indicator)
818 local filtUP, valfiltUP = indicator("UP")
819 local filtDN, valfiltDN = indicator("DN")
820 return filtUP, filtDN, valfiltUP, valfiltDN
821 end

822 for k = 1, #filterIndicators, 1 do


823 local filterUP, filterDN, valuefilterUP, valuefilterDN =
createFilterAndValue(filterIndicators[k])
824 table.insert(arrayFiltBuy, filterUP)
825 table.insert(arrayFiltSell, filterDN)
826 table.insert(arrayFiltvalueBuy, valuefilterUP)
827 table.insert(arrayFiltvalueSell, valuefilterDN)
828 end

829 -- Plot Final Filtered Signals for Developer


830 for i = 1, #arrayFiltBuy do
831 plot(arrayFiltBuy[i], color = color.green, title = "Developer Filtered Buy
Signal")
832 end
833 for i = 1, #arrayFiltSell do
834 plot(arrayFiltSell[i], color = color.red, title = "Developer Filtered Sell
Signal")
835 end

836 -- Generate and Execute Final Combined Signals


837 local finalCombinedBuySignal = generateFilteredBuySignal()
838 local finalCombinedSellSignal = generateFilteredSellSignal()

839 if finalCombinedBuySignal then


840 -- Execute final combined buy logic
841 end

842 if finalCombinedSellSignal then


843 -- Execute final combined sell logic
844 end

845 -- Final Return for Developer


846 return {
847 finalCombinedBuySignal = finalCombinedBuySignal,
848 finalCombinedSellSignal = finalCombinedSellSignal,
849 rsiValue = rsiValue,
850 k = k,
851 d = d,
852 macdLine = macdLine,
853 signalLine = signalLine,
854 hist = hist,
855 atrValue = atrValue
856 }

857 -- Additional Filter Function Logic


858 elseif filterOptions[i] == true then
859 chFilterBuy = iff(arrayFiltBuy[i] == true, 0, 1)
860 table.insert(newfilterUp, chFilterBuy)
861 end
862
863 elseif UpDn == "DN" then
864 if filterOptions[i] == false then
865 table.insert(newfilterDn, 0)
866 elseif filterOptions[i] == true then
867 chFilterSell = iff(arrayFiltSell[i] == true, 0, 1)
868 table.insert(newfilterDn, chFilterSell)
869 end
870 end -- UpDn
871 end -- Loop

872 table.sort(newfilterUp)
873 table.sort(newfilterDn)

874 if UpDn == "UP" then


875 getFilter = iff(newfilterUp[#newfilterUp] == 0, true, false)
876 elseif UpDn == "DN" then
877 getFilter = iff(newfilterDn[#newfilterDn] == 0, true, false)
878 end

879 return getFilter


880 end

881 -- LOOP PLOT ARROW ------------


882 for i = 1, #arrayVisible, 1 do
883 nameEnt = get_value(arrayName[i])
884 for ii = 1, #filterOptions, 1 do
885 filterBuy = checkFilter("UP")
886 filterSell = checkFilter("DN")
887
888 getvalueBuy = arrayValueBuy[i] >= arrayFiltvalueBuy[ii]
889 getvalueSell = arrayValueSell[i] <= arrayFiltvalueSell[ii]
890
891 buy = iff(arrayVisible[i] and filterBuy and getvalueBuy,
arrayEntryBuy[i], false)
892 sell = iff(arrayVisible[i] and filterSell and getvalueSell,
arrayEntrySell[i], false)
893
894 plot_shape(buy, "buy"..i, arraybuyArrow[i], arrayarrowSize[i],
arrayColorBuy[i], shape_location.belowbar, 0, nameEnt, arrayColorBuy[i])
895 plot_shape(sell, "sell"..i, arraysellArrow[i], arrayarrowSize[i],
arrayColorSell[i], shape_location.abovebar, 0, nameEnt, arrayColorSell[i])
896 end
897 end
898
899 return getFilter
900 end
``` &#8203;:citation[oaicite:0]{index=0}&#8203;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy