jgtstrategies
JGT Strategies repo
Alligator Mouth State and Water State Documentation
This document provides an overview of the Alligator Mouth State and Water State used in the trading strategy implemented in the jgwill/jgtstrategies repository. These states are determined based on the positions of the Alligator’s Jaw, Teeth, and Lips lines, as well as the price relative to these lines.
Alligator Mouth State
The Alligator Mouth State is determined by analyzing the positions of the Alligator’s Jaw, Teeth, and Lips lines. These lines are calculated using the ALLIGATOR indicator. The Jaw, Teeth, and Lips lines are represented by al.Jaw[period], al.Teeth[period], and al.Lips[period] respectively in the code.
Possible States
(Still has issues in understanding that the direction of the trend determined the states and reverses the logics but that sequences is interesting to show the sequence of the states)
- 🐊 Buy: If the Jaw, Teeth, and Lips lines are all increasing and the Lips line is above the Teeth line, and the Teeth line is above the Jaw line.
- 🐊 Sell: If the Jaw, Teeth, and Lips lines are all decreasing and the Lips line is below the Teeth line, and the Teeth line is below the Jaw line.
- 🐊 Neither: If neither of the above conditions is met.
Possible Phases
- 🏊 Open: If the Jaw, Teeth, and Lips lines are well-separated and aligned.
- 🏊 Closed: If the Jaw, Teeth, and Lips lines are intertwined or very close together.
- 🏊 Opening: If the Jaw line crosses above the Teeth line while the Teeth line is still below the Lips line (for buy) or if the Jaw line crosses below the Teeth line while the Teeth line is still above the Lips line (for sell).
- 🏊 None: If none of the above conditions is met.
The function parse_mouth_dir_state in strategies/standard/xptoDSPrep231124v5.lua determines the direction and state of the Alligator’s mouth based on these conditions.
Water State
The Water State is determined by the position of the price relative to the Alligator’s mouth and the state of the Alligator’s mouth. The function parse_mouth_bs_state_barpos__water in strategies/standard/xptoDSPrep231124v5.lua implements this logic.
Possible Values
- 🌊 Splashing: If the price is outside the Alligator’s mouth and the Alligator’s mouth is in a “sell” state with the price below the Lips line.
- 🐊 Eating: If the price is within the Alligator’s mouth and the Alligator’s mouth is in a “sell” state with the price above the Lips line.
- 🏊 Throwing: If the price is within the Alligator’s mouth and the Alligator’s mouth is in a “sell” state with the price below the Jaw line.
- 💧 Poping: If the price is outside the Alligator’s mouth and the Alligator’s mouth is in a “sell” state with the previous period’s price above the Lips line.
- 🌊 Entering: If the price is within the Alligator’s mouth and the Alligator’s mouth is in a “sell” state with the previous period’s price below the Lips line.
- 🐊 Switching: If the price is within the Alligator’s mouth and the Alligator’s mouth is in a “sell” state with the Alligator’s mouth in an “opening” phase.
- 🌊 Splashing: If the price is outside the Alligator’s mouth and the Alligator’s mouth is in a “buy” state with the price above the Lips line.
- 💧 Eating: If the price is within the Alligator’s mouth and the Alligator’s mouth is in a “buy” state with the price below the Lips line.
- 🏊 Throwing: If the price is within the Alligator’s mouth and the Alligator’s mouth is in a “buy” state with the price above the Jaw line.
- 💧 Poping: If the price is outside the Alligator’s mouth and the Alligator’s mouth is in a “buy” state with the previous period’s price below the Lips line.
- 🌊 Entering: If the price is within the Alligator’s mouth and the Alligator’s mouth is in a “buy” state with the previous period’s price above the Lips line.
- 🐊 Switching: If the price is within the Alligator’s mouth and the Alligator’s mouth is in a “buy” state with the Alligator’s mouth in an “opening” phase.
Functions
parse_mouth_dir_state
This function determines the direction and state of the Alligator’s mouth based on the positions of the Jaw, Teeth, and Lips lines. It returns the mouth direction (buy, sell, or neither) and the mouth state (open, closed, opening, or none).
parse_mouth_bs_state_barpos__water
This function determines the position of the price relative to the Alligator’s mouth and the water state. It returns the price mouth position (in or out) and the water state (splashing, eating, throwing, poping, entering, or switching).
signal_alligator_mouth_state_changed
This function handles the change in state of the Alligator’s mouth. It is used to signal when the Alligator’s mouth state changes, which can be used for making trading decisions.
Output Values
The output values for the Alligator Mouth State and Water State are:
mouth_dir: The direction of the Alligator’s mouth (buy, sell, or neither).
mouth_state: The state of the Alligator’s mouth (open, closed, opening, or none).
mouth_bar_pos: The position of the price relative to the Alligator’s mouth (in or out).
water_state: The water state (splashing, eating, throwing, poping, entering, or switching).
These values are essential for making trading decisions based on the Alligator indicator.
Alligator Indicator Overview
The Alligator Indicator is a technical analysis tool used to identify market trends and potential reversals. It consists of three lines: the Jaw, Teeth, and Lips.
Jaw Line
The Jaw line is a 13-period Smoothed Moving Average (SMMA) shifted by 8 periods into the future. It acts as a support or resistance level.
Teeth Line
The Teeth line is an 8-period Smoothed Moving Average (SMMA) shifted by 5 periods into the future. It provides additional confirmation of the trend.
Lips Line
The Lips line is a 5-period Smoothed Moving Average (SMMA) shifted by 3 periods into the future. It is the most sensitive to price changes.
Possible States and Phases
The Alligator Indicator identifies the following states:
- Buy: If the Jaw, Teeth, and Lips lines are all increasing and the Lips line is above the Teeth line, and the Teeth line is above the Jaw line.
- Sell: If the Jaw, Teeth, and Lips lines are all decreasing and the Lips line is below the Teeth line, and the Teeth line is below the Jaw line.
- Neither: If neither of the above conditions is met.
The Alligator Indicator also identifies the following phases:
- Open: If the Jaw, Teeth, and Lips lines are well-separated and aligned.
- Closed: If the Jaw, Teeth, and Lips lines are intertwined or very close together.
- Opening: If the Jaw line crosses above the Teeth line while the Teeth line is still below the Lips line (for buy) or if the Jaw line crosses below the Teeth line while the Teeth line is still above the Lips line (for sell).
- None: If none of the above conditions is met.
Market Conditions
The market is either advancing or not advancing (oscillating). The interaction between the Alligator Mouth State and the Water State involves analyzing the positions of the Alligator’s Jaw, Teeth, and Lips lines, as well as the price relative to these lines. Contradictions can occur when the market is oscillating, making it difficult to determine a clear direction.
For more detailed information, refer to the ALLIGATOR_MOUTH_STATE.md file.