Grid Strategy Back Tester (Long/Short/Neutral)Preface
I'd like to send a thank you to @xxattaxx-DisDev.
The 'Line' Code, which was the most difficult to plan the Grid Indicator, was solved through the 'Grid Bot Simulator' script of @xxattaxx-DisDev.
A brief description of the indicators
These indicators are designed for backtesting of grid trading that can be opened on various exchanges.
Grid trading is a method of selling at particular intervals as prices rise and fall for gird interval price range.
This indicator is actually designed to see what the Long / Short / Neutral grid has achieved and how much it has achieved over a given period of time.
How to use
1. Lower Limit and Upper Limit are required when putting indicators on the chart.
After that, choose the 'Time' when to open the grid.
Also, select Long / Short / Neutral direction if necessary.
2. Statistics Table
Matched Grid shows how many grid pairs were engaged during the backtesting period.
The Daily Average Matching Profit is calculated based on the number of these closed grids.
Total Matching Profit is calculated as Matching Grid * Per Matching Profit.
Position Profit/Loss shows the benefits and losses from your current position.
Total Profit/Loss is sum of Total Matching Profit and Position Profit/Loss.
The Expanded APY shows the benefits of running the strategy on these terms for a year.
Max Loss of Upper is the maximum loss assumed to be directly at the top of the grid range.
BEP days (Upper) show how many days of maintenance relative to Average Matching Profit can result in greater profit than maximum loss if the grid continues to move within range.
(In the case of Long Strategy, it appears to be 'Min Profit', which shows minimal benefit if it reaches the top.)
Max Loss of Lower and BEP days (Lower) shows the opposite.
(In the case of Short Strategy, it is also referred to as 'Min Profit', which shows minimal benefit if it reaches the bottom.)
3. Grid Info
Total Grid Number, Upper Limit, and Lower Limit show the values you set in INPUT.
Grid Open Price shows the price for the period you decide to open.
Starting Position shows the number of positions that were initially held in the case of a Long / Short Strategy.
(0 for Neutral Strategy)
Per Grid qty shows how many positions are allocated to one grid
Grid Interval shows the spacing of each grid.
Per Matched Profit shows how much profit is generated when a single grid is matched.
Caution
Backtesting results for these indicators may vary depending on the time frame.
Therefore, I recommend that you use it only to compare Profit/Loss over time.
*In addition, there is a problem that all lines in the grid are not implemented, but it is independent of the backtest results.
--------------------------------------
서문
지표를 기획함에 있어서 가장 어려웠던 line 코드를 @xxattaxx-DisDev의 'Grid Bot Simulator' 스크립트를 통해 해결할 수 있었습니다.
이에 감사의 말씀을 드립니다.
해당 지표에 대한 간단한 설명
해당 지표는 다양한 거래소에서 오픈할 수 있는 그리드 매매에 대한 백테스팅을 위해 만들어졌습니다.
그리드매매는, 특정 가격 구간에 대해 가격이 오르고 내림에 따라 일정 간격에 맞춰 매매를 하는 방식입니다.
이 지표는 실질적으로 롱/숏/중립 그리드가 어떠한 성과를, 특정 기간동안 얼마나 냈는지를 확인하고자 만들어졌습니다.
사용방법
1. 인풋
지표를 차트위에 넣을 때, Lower Limit과 Upper Limit이 필요합니다.
그 후 그리드를 언제부터 오픈할 것인지를 선택하세요.
또, 필요하다면 Long / Short / Neutral의 방향을 선택하세요.
2. 그리드 통계
Matched Grid는, 백테스팅 기간동안 체결된 그리드 쌍이 몇개인지를 보여줍니다.
이 체결된 그리드의 갯수를 바탕으로 Daily Average Matched Profit이 계산됩니다.
Total Matched Profit은, Matched Grid * Per Matched Profit으로 계산됩니다.
Position Profit/Loss는, 현재 갖고 있는 포지션으로 인한 이익과 손실을 보여줍니다.
Total Matched Profit과 Position Profit/Loss를 합친 금액이 Total Profit/Loss가 됩니다.
Expcted APY는, 이러한 조건으로 전략을 1년동안 운영했을 때의 이익을 보여줍니다.
Max Loss of Upper는, 그리드 범위의 최상단에 바로 도달했을 경우를 가정한 최대 손실입니다.
BEP days(Upper)는, 그리드가 범위 내에서 계속 움직일 경우, Average Matched Profit을 기준으로 며칠동안 유지되어야 최대손실보다 더 큰 이익이 발생할 수 있는지를 보여줍니다.
(Long Strategy의 경우, ‘Min Profit’이라고 나타나는데, 최상단에 도달했을 경우 최소한의 이익을 보여줍니다)
Max Loss of Lower는 그 반대의 경우를 보여줍니다.
(Short Strategy의 경우, 역시 ‘Min Profit’이라고 나타나는데, 최하단에 도착했을 경우 최소한의 이익을 보여줍니다)
3. 그리드 정보
그리드 갯수, Upper Limt, Lower Limt은 자신이 설정한 값을 보여줍니다.
Grid Open Price는, 자신이 오픈하기로 정했던 기간의 가격을 보여줍니다.
Starting Position은, 롱/숏 그리드의 경우에 처음에 들고 시작했던 포지션의 갯수를 보여줍니다.
Neutral Strategy의 경우 0입니다.
Per Grid qty는, 하나의 그리드에 얼마만큼의 포지션이 배분되었는지를 보여주며
Grid Interval은 각 그리드의 간격을 보여줍니다.
또, Per Matched Profit은 하나의 그리드가 체결될 때 얼마만큼의 이익이 발생하는 지를 보여줍니다.
이러한 지표에 대한 역테스트 결과는 시간 프레임에 따라 달라질 수 있습니다.
따라서 시간 경과에 따른 손익을 비교할 때만 사용하는 것이 좋습니다.
*추가로, 그리드의 라인이 모두 구현되지 않는 문제가 있지만, 백테스팅 결과와는 무관합니다.
Полосы и каналы
DR/IDR V1Defining Range DR and Implied Defining Range IDR for regular Session and overnight Session
This script is showing the IDR and DR for the regular trading session and for the overnight session based on the rules from the creator of the DR/IDR concept.
It works for all major Forex Pairs, BTC, ETH and the US Equity indices. This concept is based on rules and has a 80 % probability to be correct.
It should be applied in the 5 Min. Timeframe.
The timings for the RDR are from 09.30 - 10.30 am New York local time.
The timings for the ODR are from 03.00 - 04.00 am New York local time.
Rules:
1. If price in the 5 Min timeframe closes above the DR high after 10.30 am or 04.00 am then the DR low will be with 80 percent probability the low of the trading session. This is called confirmation.
2. If price in the 5 Min timeframe closes below the DR low after 10.30 am or 04.00 am then the DR high will be with 80 percent probability the high of the trading session. This is called confirmation.
3. If price closes above the IDR high after 10.30 am or 04.00 am it is an early indication that the low of the DR will be the low of the day and vice versa.
Credits:
This script imports the recently published (VisibleChart) library containing functions that return values calculated from the range of visible bars on the chart.
bmistiaen helped me a lot with this script. Thank you a lot.
[blackcat] L3 YACD38Level 3
Background
"3/8 moving average" golden cross enters, and dead cross exits.
Function
This set of methods is an improved moving average usage - "38 moving average usage", we need to use three moving averages:
3-day, 8-day and 21-day moving averages.
Why is it the 3-day, 8-day, and 21-day moving averages? Most of my friends may not be clear. 3, 8, and 21 are all Fibonacci numbers, also known as the golden section numbers. The Fibonacci number is a basic pattern of nature, which exists in all things. If you don’t understand it, you can go to a certain degree to understand it. In short, it is a very magical existence.
Keep in mind the principle of only doing uptrends and not downtrends. Then we have to use our 21-day moving average skillfully. The 21-day moving average happens to be the average price line for one month. We take it as the decision-making line. When the decision-making line goes down or goes flat, we mainly wait and see; , the operation success rate is higher!
Let's directly share the technical points of "38 moving average usage":
1. Entry point: the 3-day line crosses the 8-day line to form a golden cross, or both the 3-day and 8-day line cross the 21-day moving average; the position of the golden cross must be above the 21-day moving average, and it is invalid if it is below;
2. Basis for holding shares: After entering the market, the moving averages are arranged in a long position, and the K-line rises along the 3-day and 8-day moving averages, hold it patiently, and sell for whatever reason you buy!
3. Exit point: When the 3-day moving average crosses the 8-day moving average to form a dead cross, or the 3-day and 8-day moving averages break below the 21-day moving average, then decisively leave the market;
Note: "38 moving average usage" only needs to refer to the moving average, and the other most reference quantities can be changed. As long as the above conditions are met, you can boldly intervene, and after the intervention, you will rise to the top! Don't underestimate the usage of this set of moving averages, carefully comprehend and memorize them by heart, and be able to achieve the unity of knowledge and action, and you will be able to stand up and be the master from now on!
Remarks
Feedbacks are appreciated.
Price Average ZonesThis indicator shows the areas where LONGS or SHORTS can be made, the areas are calculated based on the mathematical averages of the high and low peaks of the price.
It also has a line that shows the average of the price movement. you can make shorts when the price enters the orange zone called the "Short Zone".
You can make longs when the price enters the orange zone called the sell zone.
It works in all timeframes, personally I use it in 1 min and in 1 hour.
Band of Filtered RS by Mustafa ÖZVERBand of Filtered RS by Mustafa ÖZVER
This code shows a range (max-min values) price may get if we get strong movements. These values is based on RSI (Relative Strange Index). And also these are calculated using RSI, if we get trades to make rsi is equal to 25 (or rsi down limit) or 75 (rsi up limit) or any value you set, how much will price value get? This code calculate these and shows these to you on graph.
This price are between these band limits because we expect cross reaction to hard movements on price.
For scalping, we can use these values as
long signal when price under down limit,
short signal when price over up limit,
But only these values can not guarantee good results for trading. BE CAREFUL
Strategy Myth-Busting #20 - HalfTrend+HullButterfly - [MYN]#20 on the Myth-Busting bench, we are automating the " I Found Super Easy 1 Minute Scalping System And Backtest It 100 Times " strategy from " Jessy Trading " who claims 30.58% net profit over 100 trades in a couple of weeks with a 51% win rate and profit factor of 1.56 on EURUSD .
This one surprised us quite a bit. Despite the title of this strategy indicating this is on the 1 min timeframe, the author demonstrates the backtesting manually on the 5 minute timeframe. Given the simplicity of this strategy only incorporating a couple of indicators, it's robustness being able to be profitable in both low and high timeframes and on multiple symbols was quite refreshing.
The 3 settings which we need to pay most attention to here is the Hull Butterfly length, HalfTrend amplitude and the Max Number Of Bars Between Hull and HalfTrend Trigger. Depending on the timeframe and symbol, these settings greatly impact the performance outcomes of the strategy. I've listed a couple of these below.
And as always, If you know of or have a strategy you want to see myth-busted or just have an idea for one, please feel free to message me.
This strategy uses a combination of 3 open-source public indicators:
Hull Butterfly Oscillator by LuxAlgo
HalfTrend by Everget
Trading Rules
5 min candles but higher / lower candles work too.
Stop loss at swing high/low
Take Profit 1.5x the risk
Long
Hull Butterfly gives us green column, Wait for HalfTrend to present an up arrow and enter trade.
Short
Hull Butterfly gives us a red column , Wait for HalfTrend to present a down arrow and enter trade.
Alternative Trading Settings for different time frames
1 Minute Timeframe
Move the Hull Butterfly length from the default 11 to 9
Move the HalfTrend Amplitude from the default 2 to 1
Enabling ADX Filter with a 25 threshold
2 Hour Timeframe
Move the HalfTrend Amplitude from the default 2 to 1
Laddered Take Profits from 14.5% to 19% with an 8% SL
SPX Expected MoveThis indicator plots the "expected move" of SPX for today's trading session. Expected move is the amount that SPX is predicted to increase or decrease from its current price, based on the current level of implied volatility. The implied volatility in this indicator is computed from the current value of the VIX (or one of several volatility symbols available on Trading view). The computation is done using standard formula. The resulting plots are labeled as 1 and 2 standard deviations. The default values are to use VIX as well as 252 trading days in the years.
Use the square root of (days to expiration, or in this case a fraction of the day remaining) divided but the square root of (252, or number of trading days in a year).
timeRemaining = math.sqrt(DTE) / math.sqrt(252)
Standard deviation move = SPX bar closing price * (VIX/100) * timeRemaining
[blackcat] L3 Bull ChannelLevel 3
Background
This is a bullish channel with spikes for long entries. Optimized for 4H time frame.
Function
This indicator places a fast and smooth lines into a channel for 4H time frame. The channel can work as overbought and oversould threshold for judgement. Also, the fast and smooth (green , red lines) will cross together and you can judge short term momentum with their cross status as golden cross or dead cross status.
For the color definitions:
Output upper_rail = 21-day moving average of the highest price*1.05, draw upper_rail
Output lower_rail = 21-day moving average of the lowest price*0.95, painted yellow
Output smooth_trend = 5-day moving average of the lowest price, painted red
Output fast_trend = 2-day moving average of the closing price, painted green
Output swing_long = If fast_trend wears smooth_trend, return upper_rail*1.05, otherwise return smooth_trend, draw red
Output leader_long = If fast_trend wears upper_rail, return upper_rail*1.10, otherwise return lower_rail, draw orange
Remarks
Feedbacks are appreciated.
[blackcat] L3 Bull Bear GameLevel 3
Background
A bull bear banker fund game trajectories.
Function
This technical indicator draws a track diagram of the long-short power comparison through a custom trend line. The red curve represents the long line, and the green curve represents the short line. When the red line crosses the green line, it means that the upward momentum is sufficient, the whale is controlling the market, and the rise is imminent, which is a buy signal. When the red line enters the strong zone, it means that the whale is in control of the stock, and the stock is about to enter the stage of pulling up. On the contrary, if the green line turns upwards, it means that the whale is washing or retreating, and we must quickly reduce or clear the position. Sometimes when the indicator sends out a long entry signal, because the whale still has to go through a round of washing, I introduced a golden pit inflection point filter scheme, which can filter out these signals, so only when the signals appear at the same time is a long entry point signal.
Remarks
Feedbacks are appreciated.
VWAP Market Session AnchoredVWAP Market Session Anchored differs from the traditional VWAP or VWAP Auto Anchored indicator in that the Volume Weighted Average Price calculation is automatically anchored to four major market session starts: Sydney, London, Tokyo, New York.
Settings
Source: the source for the VWAP calculation.
Offset: changing this number will move the VWAP either Forwards or Backwards, relative to the current market. Zero is the default.
Band: enabling this will show Standard Deviation bands.
Band Multiplier: the value the Standard Deviation bands will be multiplied by before being plotted on the chart.
Sessions : enabling the sessions will plot the respective anchored VWAP on chart.
Custom: enabling this will show a custom user-defined session.
Custom UTC : the custom session is defined by a starting UTC hour followed by the ending UTC hour.
Usage
Similar to the traditional VWAP, VWAP Market Session Anchored is a technical analysis tool used to measure the average price weighted by volume. VWAP Market Session Anchored can be used to identify the trend during a specific market session.
Limitations
When setting a custom session, be mindful that calculations are based off of the Coordinated Universal Time (UTC) time, you must convert your local time zone to UTC in order to have an accurate representation of your custom session.
It is not recommended to use this indicator on timeframes above 1 hour as market sessions only last a few hours.
VWMA Fibonacci Bands (VFIBs)This is a momentum indicator , utilizing Volume Weighted Moving Averages (VWMAs), Average True Range (ATR), and Fibonacci Levels.
This indicator can be used in most, if not all, financial markets. I have personally found it to be most useful in mid or large cap stocks, index funds, and cryptocurrencies in the top 25 by market cap. I have not tested this indicator in Forex markets, but I imagine that it would function well there, too.
The idea behind proper use of this indicator centers around mean reversion. If price is low compared to previous price action, mean reversion implies that it is likely to revert back to the mean, over time. If price is high, it implies that it will move lower. Generally, the different period VWMAs (center lines) will act as support when in an uptrend and resistance when in a downtrend. Additionally, it is rare for price to go above the upper bounds or lower bounds of the Fibonacci Bollinger Bands . Price action doing so may indicate a potential short or long position, respectively.
This indicator is intended to be used in tandem with the oscillator 'VFIBs Agreement', to be published shortly.
As we can see in the chart, the 50 week VWMA has been acting as resistance and recently dipped down to the bottom range of the band, only to bounce back. Holding above the 50 VWMA might indicate a bullish reversal, treating it as support moving forward.
Fibonacci Bollinger Band ClusterThis indicator creates moving averages based on Fibonacci numbers (3-233, divided by 10 to average) sourced by high, low, and ohlc4 and plots lines based on these three. The Fib MA High line is either green or red (Fib High < Close), the Fib MA Low line is either lime or orange (Fib Low < Close), and the Fib MA OHLC4 line is constantly white. A cluster or series of Bollinger Bands is then created using the Fib MA OHLC4 line as the basis. Fibonacci-based deviations (1, 2, 3, 5, 8) are then used to create three upper and three lower Bollinger lines.
Four Block Zone - Oliver VelezThis is pretty straight forward indicator as explained by Oliver Velez ... Be bullish if price crosses upper band and bearish if crosses lower band.. that's it.
[blackcat] L2 Dragon CloudLevel 2
Background
In addition to characterizing the trend through the special parameter SAR, this dragon cloud indicator also indicates that it is currently in the corresponding stage of the bull and bear market through the cloud layer of the large parameter.
Function
The SAR indicator characterizes short-term trend changes and provides swing buying and selling points. Red crosses and candles represent declines and their strength; green crosses and candles represent rises and their strength. At the same time, this technical indicator can judge which stage the market is currently in through the thickness of the bear cloud and the thickness of the bull cloud. When the blue cloud layer on the main picture is relatively thick, it means that it is in a deep bear market; as the blue cloud becomes thinner, and the red cloud is edited, it means that the bull-bear power game is in the process of transformation. The red cloud indicates the strength of doing more, and when its thickness is greater than the blue cloud, it means that the bull market is coming!
Remarks
Feedbacks are appreciated.
Distance Bands Oscillator_KT █ OVERVIEW
This tool is based on both Bollinger Bands and Keltner Channels, and measures 3 distances between the two, respectively.
Upper Kelt to Upper Bollinger Band
Lower Kelt to Lower Bollinger Band
Kelt Basis to Bollinger Basis Basis
Similar to the Band Width indicator, this can be used as a measure of volatility, and can be used to measure uptrend, downtrend and chop regions on a given chart.
Happy Trading,
ET
[HM] Fibonacci Fractals Absolute Auto v20221114Basically:
F - Fibonacci levels
F - fractals: retracement of retracement
A - absolute: based on two fixed points instead user chosen Fibonacci points
A - auto: automatically draws based on volatility
Explanation:
This script will automatically trace TWO Fibonacci levels from these points:
- ALL TIME HIGH (ATH) and ALL TIME LOW ( ATL ) prices
This is our first Fibonacci FRACTAL retracement and the line caption will show ONE character:
"↥" for 0.618
"↧" for 0.382
The FRACTAL with two lines will define THREE regions.
The second Fibonacci FRACTAL retracement will show TWO characters:
the same "↥" "↧" characters with:
"a" if the price is between TOP region of previous fractal
"b" if the price is between MIDDLE region of previous fractal
"c" if the price is between BOTTOM region of previous fractal
The third Fibonacci FRACTAL will show THREE characters and so on.
Delimited by volatility (otherwise this script will go to 10th fractal maximum).
OPTIONS to give a try:
- use ALL TIME HIGH and ZERO prices (instead ATH and ATL )
- use a non-Fibonacci retracement:
---> "⅓": 1/3 and 2/3 levels instead 0.618 and 0.382 (based on chess master Hindenburg Melão article hint)
---> "fibonaccing": 0.764 and 0.236 levels (based on Brazilian trader Marco Antonio Rossi method hint)
#script under development, sugestions and questions are welcome.
Volume RSIThis is an indicator that shows the inflow and outflow of volume into a financial instrument. Volume is likely one of the most underrated source of data in trading unfortunately so there seems to be a lack of studies on it. The size of the candle is related to the strength of the move. The calculations for this are: cumulative sum of +volume if open < close OR -volume if open > close. This has been now transformed into an rsi style indicator to give a distinct advantage (or atleast thats the idea). The idea is that we take rsi of candles so we might as well take the rsi of volume candles. As far as I can tell it is faster/its own thing compared to regular rsi. I ave also added a smoothing option. Dont forget you can change the settings and you wont die. Thank you for your interest in this release I hope you find great piles of money with it.
link to the script I used to make this
Z Score BandThis is a band based on Z Score. What is Z Score? In layman's terms it's a method of finding outliers within a sequence of numbers. It's highly effective to quantify pump and dumps in the crypto market.
The middle line is a simple Exponential Moving Average, you can configure this with whatever period you prefer. It comes default with a period of 247 to which I find suitable for my style of trading. The upper and lower bound are determined by the standard deviation you choose in the settings, it comes with a default of 1.69 although I've heard people saying 2.5 is a better number to really pinpoint outliers.
Trading with this indicator is like trading with any band based indicator. The main difference is that this indicator's sole purpose when I wrote it is to help me find shorting positions in the futures market. On the contrary though, longs are also achievable although I rarely long the futures market.
If prices hit the upper bound and get rejected, it's probably because the move was an outlier, it doesn't happen often and when it does usually it reveals crypto's nature of buying spot and hedging short in the futures market. When prices stay above the upper bound, switch to a higher timeframe until we can see that it's still have some ways upwards.
What's true about using this as a shorting tool is also true with longs. However, it might not be as effective, I'd like to be proven wrong.
Fibonacci Zones EMA Zones StrategyThis idea is only for fun and learning purposes only.
The strategy represents 2 simple math formulas that are very simple. the "Fibo Formula" and the "EMA Formula" Please see source code for reference
I Feel like coders can learn a lot about developing strategies using this source code
This is to show that there is unlimited amount of variables and factors to a strategy and its all about working with probability.
Also to show that unlimited amount of conditions could be added to a strategy.
And unlimited amount of variables/factors with the settings that could change the results.
Rules are simple
Entry on close, Close/Entry must be in the blue Fibo Zone
Blue Fibonacci zone fully customizable
Other Conditions could be added involving EMA zones, Over Ema1, Under Ema1 etc..
TP/SL and Dates Fully Customizable
This script is just an idea fully for learning purposes.
Adaptive VWAP Stdev BandsIntroduction
Heyo, here are some adaptive VWAP Standard Deviation Bands with nice colors.
I used Ehlers dominant cycle theories and ZLSMA smoothing to create this indicator.
You can choose between different algorithms to determine the dominant cycle and this will be used as reset period.
Everytime bar_index can be divided through the dominant cycle length and the result is zero VWAP resets if have chosen an adaptive mode in the settings.
The other reset event you can use is just a simple time-based event, e.g. reset every day.
Usage
I think people buy/sell when it reaches extreme zones.
Enjoy!
---
Credits to:
@SandroTurriate - VWAP Stdev Bands
@blackcat1402 - Dominant Cycle Analysis
@DasanC - Dominant Cycle Analysis
@veryfid - ZLSMA
(Sry, too lazy for linking)
I took parts of their code. Ty guys for your work! Just awesome.
Swing BandsThis indicator is a result of experimentation with price action of candle high and lows for quantifying reversals and trend continuation.
The band area shows trend reversal incoming and possible chop.
Middle line is the trend reversal price level. Candle colors change if the close price is above or below the middle line.
Long and short positions can be taken when above or below the bands.
Trend continuations are in effect when price retraces into the bands and breaks above or below in the same direction of the trend.
Hull Moving Average Bollinger Bands (HMABB)Hello! This is simply Bollinger Bands calculated with HMA! Heres a recap on both.
The Hull Moving Average (HMA) attempts to minimize the lag of a traditional moving average while retaining the smoothness of the moving average line. Developed by Alan Hull in 2005, this indicator makes use of weighted moving averages to prioritize more recent values and greatly reduce lag.
Bollinger Bands are envelopes plotted at a standard deviation level above and below a simple moving average of the price. Because the distance of the bands is based on standard deviation, they adjust to volatility swings in the underlying price. Bollinger Bands use 2 parameters, Period and Standard Deviations, StdDev.