sigmastreet

IchiBot - [SigmaStreet]

sigmastreet تم تحديثه   

The IchiBot Indicator has been used to develop automated trading systems. It leverages the open-source Ichimoku framework provided by Trading View, to enable users to creatively generate over 1 trillion different combinations of trading conditions with the use of multiple timeframes to create unique “signal labels” that can be used to create custom strategies or provide in depth market analysis. At the end of this description, I have provided an example of input settings for a simple scalping strategy that I have back tested on US30 on the 5 minute timeframe.

Overview of the Settings:

The visuals section includes an option to show or hide certain parts of the indicator and change the size of the signal labels plotted on the chart.
Next to the “Signal color on baseline/candles” section, you can choose if you want to see additional signals generations from the most previous plotted label on a color changing baseline, or color changing candles. A color change from gray to blue/red indicate that the conditions from the most previously plotted signal label have been met again.

The next 5 sections are all related to the strategy portion of the indicator, used to aid in the back testing process. These sections are titled “Stop loss”, “Take Profit”, “Trail Stop”, “Trade Settings” and “Trade Schedule”.
The Stop Loss section includes an option to choose between value of “pts”, “atr” (average true range) or “None”. The stop loss value in “pts” is simply a specified number of points or pips from the current entry price of a trade that are input in the “SL” section. If the stop loss type is “atr” the “SL” section is not used and the value is calculated and displaced from the current entry price of a trade based on the atr period multiplied by the atr multiplier.
The take profit section is based on the same logic as the stop loss.
The Trail Stop section includes an option to choose between values “pts” or “None”. If the Trail Stop value is “pts”, a trailing stop loss is activated if a trade moves a point value into profit that exceeds the value of the “Trail Activation”. If the Trail Offset type is “pts”, the trailing stop loss is placed a point value away from the current price that is equal to the “Trail Offset” value.
The trade settings section has two options to either prevent or allow trade reversals and prevent or allow only 1 trade per signal label.

If the “Don’t allow trade reversals” is on, then a currently active trade can not be cancelled by an opposite trade signal. It can only be cancelled by the exit logic selected in the above sections. If the “One trade per signal” is selected, the strategy will only enter a trade if the most recent signal label is different from the last signal label where a trade was entered, or if the most recent signal label is in the opposite direction of the most recent signal label where a trade was entered.
The trade schedule section includes an option to only generate signal labels during the specified time. You can choose between 24/7 which will generate signals without any time restriction, or you can choose a custom time which is based on the America / New York time zone.

The timeframe settings section includes an option to choose “single” or “multiple” timeframes, as well as an option to show every signal label combination (“all”), or only the signal labels with the highest numerical value (“absolute”).
If you select “single” next to “timeframe”, the indicator will show you labels based on trade conditions met from only 1 selected timeframe. If you select “multiple” next to “timeframe”, the indicator is designed to return signal labels based on trade conditions that have been met on at least 2 different timeframes.
If you select “multiple” and “use current timeframe”, the indicator will include labels that always include a minimum of 2 timeframes where 1 timeframe is always the current timeframe. If you unselect the “use current timeframe”, the indicator will include labels with a minimum of 2 timeframes.
If you select “multiple” next to “timeframe” and “all” next to “Show all/absolute labels”, the indicator will show you every possible combination of labels that vary from trade conditions met on a minimum of 2 timeframes, to the maximum number of timeframes selected.
If you select “multiple” next to “timeframe” and “absolute” next to “Show all/absolute labels”, the indicator will only show you labels where the numerical value is equivalent to the maximum number of timeframes selected.

Each signal label provides a number which refers to the number of timeframes used to generate the label, offering insights briefly. Hover over a label to reveal detailed tooltip information that details the exact timeframes used to generate each label.
You can choose all from “Show all/absolute labels” to see every possible combination of trade signals or “absolute” to only see labels that have the highest possible numerical value. Absolute means that every condition selected from every timeframe was calculated to be true at the same time on the same candle.

The next 8 sections are “Current timeframe trade conditions”, “1-minute timeframe trade conditions”, “5-minute timeframe trade conditions”, “15-minute timeframe trade conditions”, “30-minute timeframe trade conditions”, “1-hour timeframe trade conditions”, “4-hour timeframe trade conditions”, “Daily timeframe trade conditions”.
These sections include the same 10 trade conditions, that can be used independently, or in combination with each other. This brings the total number of trade conditions to 70.
The final section includes a standard option to adjust the current Ichimoku values.

Understanding the Calculations:
The term “future” refers to a value that is calculated 26 candles to the right of the most recent closing price.
The term “current” refers to a value that is calculated on the most recent closing price.
The term “past” refers to a value that is calculated 26 candles to the left of the most recent closing price.
Bullish is referred to as “blue” and bearish is referred to as “red”.
Buy Signals:
1. The current closing price is greater than the current cloud value.
2. The future cloud is blue.
3. The current closing price is greater than the current conversion line.
4. The current conversion line is greater than the current baseline.
5. The lagging span is greater than the closing price of the last 25 candles.
6. The lagging span is greater than the past cloud.
7. The lagging span is greater than the past conversion line and the past baseline.
8. The current conversion line is greater than the current cloud.
9. The current baseline is greater than the current cloud.
10. The value of the current cloud to the future cloud is completely blue.

Sell Signals:
1. The current closing price is less than the current cloud value.
2. The future cloud is red.
3. The current closing price is less than the current conversion line.
4. The current conversion line is less than the current baseline.
5. The lagging span is less than the closing price of the last 25 candles.
6. The lagging span is less than the past cloud.
7. The lagging span is less than the past conversion line and the past baseline.
8. The current conversion line is less than the current cloud.
9. The current baseline is less than the current cloud.
10. The value of the current cloud to the future cloud is completely red.

The script enables users to access the value of these 10 trade conditions across the 7 major time frames (1-minute, 5-minute, 15-minute, 30-minute, 1-hour, 4-hour, Daily, and the current charts time frame) by using the official non repainting request security function provided by Trading View:

f_secSecurity(_src, _res, _exp) =>
request.security(_src, _res, _exp)

This indicator provides up to 70 variables (10 variables X 7 timeframes) that can be used separately, or in combination to generate signal labels.

Enhance your visual analysis with a color-changing baseline and candle colors that adapt to signal shifts, offering an immediate understanding of market trends. The base line will change from gray to blue/red which will reference the most previously plotted signal label. This change in color indicate that the conditions from the most recently plotted signal label have been met once again. Please refer to the example below.


Adjustments to the Ichimoku Indicator:
The script uses a slightly refined version of the Ichimoku indicator to calculate 10 different “trade conditions”. Each trade condition can create 1 bullish signal label and 1 bearish signal label. The calculations are primarily based on “greater than and less than logic” which is standard for signal generation.

In the original Ichimoku calculations, the “Lagging Span” has a default value of 26 periods. In the actual calculations, this input with the title “Lagging Span” is referred to as the “displacement”. When the lagging span is plotted on the chart, it is plotted with an offset value of offset = -displacement + 1 which technically plots the lagging span 25 candles to the left the most recent candle (if you count the most recent closing price as 0 and not 1). The clouds are plotted with an offset of offset = displacement -1 which technically plots the clouds 25 candles to the right of the most recent candle.

I have adjusted the logic of the Ichimoku indicator so the lagging span is still plotted 25 candles to the left of the most recently confirmed candle close, but the cloud is plotted 26 candles to the right of the most recent confirmed candle close.


This seemingly small adjustment of one candle cannot simply be adjusted in the settings of the original Ichimoku indicator since the calculations of the cloud and lagging span displacements are directly affected by the same value (displacement = 26, also known as the “lagging span”). My script is adjusted to make calculations where the lagging span is 25 candles to the left of the most recent candle, and the cloud is displaced 26 candles to the right of the most recent candle.
For example, my scripts logic to detect if the current closing price is over the current cloud is (close > leadLead1 and close > leadLine2 and leadLine1 > leadLine2. By using a lookback of , the logic assumes that the displaced value is 26 bars to the right of the most recent candle. My script also reflects this logic in the plotted values of the cloud where the offset values are offset = displacement. This adjustment is made without affecting any other part of the Ichimoku indicators calculations, only the displacement of the cloud which directly affects the logic of trade conditioins. This change is a deliberate and necessary function of this script’s logic to generate trade conditions and signal labels.
I’ve removed the conversion line and the lagging span and introduced a 26-period pivot high/low to provide a less cluttered chart. The pivot high/low looks 26 periods to the left and only 1 period to the right. The lagging span and conversion line logic is still built into the framework of the trading signals. If you choose to enable the lagging span, or conversion line.
trading approach, and always test your strategies thoroughly.

The function to generate the "Signal Labels" calculates every single possible combination of the 7 different timeframes which is a total of 127 combinations for bullish signal labels, and 127 combinations for bearish signal labels. This function also provides the necessary criteria for the strategy entry conditions, based on the dynamically calculated values derived from the signal labels themselves. For example: "buy signal on 1 minute and 5 minute timeframe" is considered 1 combination, and "Buy signal on current, 5 minute, 15 minute, 30 minute, 1 hour, 4 hour and daily timeframe" is also considered 1 combination. There are a total of 254 combinations between buy and sell signal labels along with 254 individual variables with their own unique tool tip description. The signal label function alone spans over 1340 lines of code (minus spaces and comments) to specifically account for every possible variable combination. This unique and original function also calculates the signal label "value" which is the number you see on the signal label. This function adjusts the amount of labels plotted, the value and description of all labels based on the timeframe settings "single"/"multiple", the use of "use current timeframe" setting, and the "trade schedule". This signal label function has been a landmark piece of code for me in my endeavor to create and optimize my strategies based on its ability to provide an in depth analysis of the timeframes used when generating signal labels. This function is main reason that this script has been published closed source.

Back tested results.
The current results are from US30 (Dow Jones Industrial Average CFD) on the 5-minute timeframe using regular candles. The inputs are as follows:
Stop loss = 5000 pts
No take profit.
Trail activation = 100 pts
Trail offset = 100 pts
Don’t allow trade reversals
Trade 24/7
Timeframe = multiple
Show absolute signals
Use current timeframe, lag span over/under candles
Use 30m timeframe, all cloud is bull/bear
Initial capital = $10,000 USD, 1 contract, $0.07 per contract, slippage = 3 ticks, use bar magnifier = on
Timeframe = June 1st, 2023 – November 10th, 2023, risk = 5% (greatest loosing trade = $500.44)
ملاحظات الأخبار:
UPDATE - the description of the non repainting request security function was cut off in the orignal description. The correct code the reflects the function in the script is written below

f_secSecurity(_src, _res, _exp) =>
request.security(_src, _res, _exp)

Also updated script to show pivot high/low when script is first loaded on the chart.
ملاحظات الأخبار:
UPDATE - I didn't used the "code" function to show the proper non repainting code used in the script. Below should correctly show the non repainting request security function.

f_secSecurity(_src, _res, _exp) => 
request.security(_src, _res, _exp[barstate.isrealtime ? 1: 0])[barstate.isrealtime ? 0: 1]

نص برمجي محمي
تم نشر هذا النص البرمجي بمصدر غير مفتوح ويمكنك استخدامه بحرية. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني. لا يمكنك مشاهدة أو تعديل كود المصدر الخاص به.
إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟