Wednesday, 16 April 2025

Introduction to the "3-Candle Pattern with Highlighted First Candle" Pine Script

  No comments
13:40



This Pine Script is designed to identify and highlight specific candlestick patterns on a chart. Specifically, it detects 3 consecutive bullish or bearish candles and highlights the first candle of each valid 3-candle pattern. The key features of the script include:

  • Bullish Pattern Detection: The script identifies when there are 3 consecutive bullish candles, each with higher closing prices and rising lows.

  • Bearish Pattern Detection: It also identifies 3 consecutive bearish candles with falling highs and lower closing prices.

  • Highlighting: When a valid pattern is detected, only the first candle of the 3-candle pattern is highlighted using a colored rectangle. The first bullish candle is highlighted with a green rectangle, while the first bearish candle is highlighted with a red rectangle.

  • Reset Mechanism: The script resets after a pattern ends, ensuring that only the first candle of a new 3-candle sequence is highlighted.

  • Customizable for Trading: The script can be easily adapted to trigger trading signals (buy/sell) based on the detection of these candlestick patterns.

Buying and Selling Strategies

Based on the 3-candle pattern detection, the following buying and selling strategies can be applied:

Buy Strategy (Bullish Pattern)

  • Trigger: When the script identifies the first bullish candle of a valid 3-candle bullish pattern (i.e., 3 consecutive bullish candles with higher lows), it signals a potential buy opportunity.

  • Confirmation: A buy signal can be confirmed if the price is at or near the low of the first bullish candle. Traders might also wait for the price to pull back slightly and then bounce off the low before entering a position.

  • Take Profit: Set a target for a small profit based on a risk-to-reward ratio (e.g., 1:2), or use a trailing stop to capture larger trends.

  • Stop Loss: Place a stop loss slightly below the low of the first candle of the pattern to limit downside risk in case the pattern fails.

Sell Strategy (Bearish Pattern)

  • Trigger: When the script identifies the first bearish candle of a valid 3-candle bearish pattern (i.e., 3 consecutive bearish candles with falling highs), it signals a potential sell opportunity.

  • Confirmation: A sell signal can be confirmed if the price is at or near the high of the first bearish candle. Traders might wait for a retracement and a rejection at the high before entering a short position.

  • Take Profit: Set a target for a small profit based on a risk-to-reward ratio (e.g., 1:2), or use a trailing stop to capture larger downward trends.

  • Stop Loss: Place a stop loss slightly above the high of the first candle of the pattern to protect against the pattern failing.

Example Scenario:

  • Bullish Example: After detecting the first bullish candle of a 3-candle pattern, the script would highlight it with a green rectangle. A trader could then place a buy order near the low of this candle, looking for the price to rise further.

  • Bearish Example: After detecting the first bearish candle of a 3-candle pattern, the script would highlight it with a red rectangle. A trader could place a sell order near the high of this candle, looking for the price to decline further.

//@version=5
indicator("3-Candle Pattern with Highlighted First Candle", overlay=true)

// === Function: Detect 3 consecutive bullish candles with rising lows ===
isValidBullishPattern() =>
    close[2] > open[2] and close[1] > open[1] and close > open and low[1] > low[2] and low > low[1]

// === Function: Detect 3 consecutive bearish candles with falling highs ===
isValidBearishPattern() =>
    close[2] < open[2] and close[1] < open[1] and close < open and high[1] < high[2] and high < high[1]

// === Persistent variables to store box reference ===
var box bullishBox = na
var box bearishBox = na
var bool isBullishHighlighted = false
var bool isBearishHighlighted = false

// === Detect patterns ===
bullishPattern = isValidBullishPattern()
bearishPattern = isValidBearishPattern()

// === Create Rectangle for First Bullish Candle of the Pattern ===
if bullishPattern and not isBullishHighlighted
    // Highlight the first candle in the bullish pattern (candle at index 2)
    bullishBox := box.new(left=bar_index[2], top=high[2], right=bar_index[2] + 1, bottom=low[2], border_color=color.green, bgcolor=color.new(color.green, 90))
    isBullishHighlighted := true // Mark as highlighted

// === Create Rectangle for First Bearish Candle of the Pattern ===
if bearishPattern and not isBearishHighlighted
    // Highlight the first candle in the bearish pattern (candle at index 2)
    bearishBox := box.new(left=bar_index[2], top=high[2], right=bar_index[2] + 1, bottom=low[2], border_color=color.red, bgcolor=color.new(color.red, 90))
    isBearishHighlighted := true // Mark as highlighted

// === Reset Highlight Flags After 3-Candle Pattern Ends ===
if not bullishPattern and isBullishHighlighted
    isBullishHighlighted := false
if not bearishPattern and isBearishHighlighted
    isBearishHighlighted := false

// === Reset Boxes at the Start of New Day or New Trend ===
if (dayofweek != dayofweek[1])
    box.delete(bullishBox)
    box.delete(bearishBox)

Read More

Thursday, 16 May 2024

A Performance Guide to Java Collections

  No comments
08:05

 [1] List


- ArrayList
Uses an array to store elements, allowing for fast access and traversal through index-based operations.

However, when elements are inserted or removed in the middle, it requires shifting subsequent elements to accommodate the change.

This shifting operation can lead to inefficiencies for frequent insertions/removals.

- LinkedList
Stores elements as nodes, where each node points to the next and/or previous node.

This structure makes inserting and removing elements efficient, especially in the middle, as it only requires updating references.

However, random access to elements is slower compared to ArrayList because you need to traverse the list from the beginning or end to reach a specific index.

[2] Set

- HashSet
Uses hash codes to store and retrieve elements, offering constant-time complexity for common operations like adding, removing and checking for containment.

However, it doesn't guarantee any specific order of elements and doesn't maintain insertion order.

- LinkedHashSet
It is similar to a HashSet, but it maintains the insertion order of elements.

This means that when you iterate through a LinkedHashSet, the elements are returned in the order they were added.

Additionally, it offers faster iteration compared to a regular HashSet.

- TreeSet
Uses a self-balancing binary search tree to store elements in sorted order.

This enables efficient operations like adding, removing and checking for containment in logarithmic time complexity.

The sorted nature of a TreeSet is useful when you need elements to be ordered according to their natural ordering or a custom comparator.

[3] Map

- HashMap
Uses hash codes to store and retrieve key-value pairs, providing constant-time complexity for common operations like adding, removing and retrieving.

However, it doesn't guarantee any specific order of elements and doesn't maintain insertion order.

Hash collisions (when different keys produce the same hash code) can impact performance by slowing down access in such cases.

- LinkedHashMap
Similar to a HashMap, but it maintains the insertion order of key-value pairs.

When iterating through a LinkedHashMap, the entries are returned in the order they were added.

Additionally, it offers faster iteration compared to a regular HashMap.

- TreeMap
Uses a self-balancing binary search tree to store key-value pairs in sorted order based on the keys.

This allows for efficient operations like adding, removing, and checking for containment in logarithmic time complexity.

The sorted nature of a TreeMap is beneficial when you need keys to be ordered according to their natural ordering or a custom comparator.

Read More

Saturday, 3 February 2024

Important Points for Accurate Candle Reading

  No comments
06:03

1. Never judge a candle before it closes.

2. A clear prior trend is important for a meaningful reversal.

3. Higher the time frame, higher the accuracy and reliability.

4. Use sufficient filters before a trade commitment; choose only the best trading opportunities.

5. Look for confirmation of a candle signal before making a trade commitment.

6. Location of the candle is extremely important and must be looked at carefully.

7. Pattern timing is crucial; choose high probability timings for better success.

8. Nothing is accomplished in a single candle — it usually takes 3, 5 or 8 candles.

9. Newer trends are more profitable to trade than the more matured ones.

10. Trades with the trend are superior to trading counter trend moves.

11. Volume support makes a big difference, it must be checked.

12. Never forget the 50% retracement rule; the retracement must stay within the 50% limit for the trend to continue for longer

Read More

Thursday, 12 October 2023

1 Min Scalping

  No comments
22:06

Read More

Tuesday, 10 October 2023

Mcx Chart 3-30

  No comments
12:37

Read More

Monday, 12 June 2023

Code to check whether device is rooted or not

  No comments
22:04

Utility methods to check whether device is rooted? or contains magisk and exposed modules etc.

Read More

Tuesday, 6 June 2023

List of all the awesome tools which will you to reverse engineer any android application

  No comments
06:47


 Burp Suite:

Burp community version includes few essential manual tools from the Burp platform, however some of the features are available only in paid version.

https://portswigger.net/burp


Frida

It is a toolkit which allows run time hooking into application for developers, reverse-engineers and security researchers.

https://github.com/frida/frida


JADX-GUI

JADX has Command line and GUI tools for produce Java source code from Android Dex and JADX-GUI is UI based. .

https://github.com/skylot/jadx


scrcpy

This application provides display and control of Android devices connected via USB or over TCP/IP. It does not require any root access.

https://github.com/Genymobile/scrcpy


Logcat - Pidcat

It shows log entries for processes from a specific application package.

https://github.com/JakeWharton/pidcat


MobSF

Mobile Security Framework (MobSF) is an automated, all-in-one mobile application (Android/iOS/Windows) pen-testing framework capable of performing static, dynamic and malware analysis.

https://github.com/MobSF/Mobile-Security-Framework-MobSF


Radare2

Radare is a portable reversing framework that can Disassemble/assemble many different architectures.

https://rada.re/r/


Objection

Objection is a runtime mobile exploration toolkit, powered by Frida It was built with the aim of helping assess mobile applications and their security posture without the need for a jailbroken or rooted mobile device.

https://github.com/sensepost/objection


Ghidra

A software reverse engineering (SRE) suite of tools developed by NSA's Research Directorate and this reverse engineering tool helps to dig up the source code of a proprietary program which further gives you the ability to detect virus threats or potential bugs

https://ghidra-sre.org/




Checkra1n

Jailbreak for iPhone 5s through iPhone X, iOS 12.0 and up

https://checkra.in/


Metasploit

It is a penetration testing framework that enables pentesters to find, exploit, and validate vulnerabilities.

https://www.offsec.com/metasploit-unleashed/requirements/


Sqlmap

sqlmap is an open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws

https://github.com/sqlmapproject/sqlmap


DB Browser for SQLite

DB Browser for SQLite (DB4S) is a high quality, visual, open source tool to create, design, and edit database files compatible with SQLite.

https://sqlitebrowser.org/


frida-ios-dump

Pull a decrypted IPA from a jailbroken device.

https://github.com/AloneMonkey/frida-ios-dump


Nmap

Nmap Free Security Scanner, Port Scanner, & Network Exploration Tool.

https://nmap.org/


Scrcpy

This application provides display and control of Android devices connected on USB (or over TCP/IP). It does not require any root access. It works on GNU/Linux, Windows and macOS.

https://github.com/Genymobile/scrcpy


Grapefruit: Runtime Application Instruments for iOS

Grapefruit is a runtime application instrumentation tool for iOS

https://github.com/ChiChou/grapefruit

Read More