%VARonMeanLongOnly is a long-only strategy that uses the average and price movement to find buying opportunities. The script takes into account the simple average over a longer timeframe than the observed timeframe. It then calculates the distance between point "X" (average) and point "Y" (market price). The algorithm will buy every time the price is lower than the average and has a percentage variation greater than the set one. So every time the price moves away from the average by XY% a long position will be opened. The position is closed only when a specific percentage distance of the price above the average is reached, without the use of stop losses and take profits.
This strategy is inspired by the classic academic mean and standard deviation approach, according to which the market tends to move around average values, which may deviate from the average for short periods. In this strategy the trader tries to find a statistical advantage over the distances between average and price.
%VARonMeanLongOnly is a very lightweight script created with Pine v5. We developed a user interface that can adjust the analysis period from a few days to several years. We chose the Moving Average Multi Time Frame and a simple mathematical expression to calculate the percentage distance from price to average and vice versa.
What can you do with %VARonMeanLongOnly ?
With %VARonMeanLongOnly you can implement a statistical arbitrage strategy that allows you to understand if buying above the average and selling the asset above the average can be profitable for a given market. Using the interface you can adjust the periods and variations and analyse if there is a possibility to use this strategy on that market. Understand if this approach has produced positive results on the market under analysis in the past.
The initial capital set is €1,000 (You can change this from the "Properties" section of the user interface). Each individual trade uses 100% of the set capital, in this case €1,000. The default commission per trade is 0.03% (You can change this in the "Properties" section of the user interface).
User Interface
1) General backtest time settings: Set the history period to be analysed
StartDate: backtest start date StartMonth: backtest start month StartYear: backtest start year EndDate: backtest end day EndMonth: backtest end month EndYear: backtest end year
2) Mean Setting
Length: Periods to be observed when calculating the average Source: Open, Close, High, Low TimeFrame: Time frame of the average (usually larger than the time frame under observation)
3) Entry Long Trades: EntryOnPercentVar: % distance from average to current price
4) Exit Long Trades: ExitOnPercentVar: % distance from the current price to the average
Please do not hesitate to contact us for any questions or information.
Disclaimer
Be careful, the past is not a guarantee of future performance, so remember to use the script as a pure analysis tool. The developer takes no responsibility for any use other than research and analysis and can in no way be held liable for damages resulting from wrong use of this code.
Этот скрипт опубликован с закрытым исходным кодом, вы можете свободно им пользоваться. Можно добавить его в избранное и использовать на графике. Вы не можете просматривать или менять его исходный код.
Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.