OPEN-SOURCE SCRIPT

AynetBox 2 Timeframe Strategy

This Pine Script code defines a strategy called "AynetBox 2 Timeframe Strategy".

1. Timeframe Inputs
The user can manually select two different timeframes (tf1 and tf2).
These inputs are minute-based, with the following options: 1, 3, 5, 15, 30, 60, 120, 240, 360, 720.
2. AynetBox Calculation
AynetBox tracks price movements within a specific range (e.g., 125 USD).
The function compares the current price with the previous AynetBox level to check if the price has moved up or down by at least the specified box_size.
If the price exceeds this threshold:
A new AynetBox level is set.
The trend (current_trend) is assigned as upward (+1) or downward (-1).
3. Date and Time Filtering
The user can manually configure the start (fromDay, fromMonth, fromYear) and end dates (toDay, toMonth, toYear).
The time_cond variable ensures the strategy operates only within the specified date range.
4. Multi-Timeframe Calculation
Based on the timeframes selected by the user (e.g., tf1 = 60, tf2 = 240), separate AynetBox calculations are performed for each timeframe.
tf1Counter and tf2Counter:
These counters track the elapsed time in each timeframe.
When the counter reaches the length of the specified timeframe, it resets, and the AynetBox level is updated.
5. Plotting and Visualization
The plot() function draws the AynetBox levels for both timeframes:
The first timeframe is plotted in light blue (#3C8CE0), and the second in dark red (#FF4A68).
fill() function:
Fills the area between the two timeframes.
If tf1 value is greater than tf2, the fill is in blue shades; otherwise, it is in red shades.
6. Signals and Trading Logic
Long Signal:
Triggered when tf1AynetBox crosses above tf2AynetBox.
Short Signal:
Triggered when tf1AynetBox crosses below tf2AynetBox.
Small dots (plotchar) mark the signal points on the chart.
The strategy automatically enters positions based on the signal (strategy.entry):
strategy.long for long signals and strategy.short for short signals.
7. Visual Additions
A title is added to the top-right corner using a table:
It displays "AynetBox 2 Timeframe Strategy."
This code allows users to track price movements within specified date ranges and two different timeframes, using the AynetBox logic. The intersections between the two timeframes form the basis for generating signals.
Bands and Channelsconcepteducational

Script de código aberto

No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Quer usar esse script no gráfico?


Também em:

Aviso legal