TradingView
thequantscience
4 mar 2022 20:22

Algorithmic Trading on ETH/USDT 1H Backtesting Strategy  

Ethereum / TetherKuCoin

Descrizione

How it works [/I]

%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.
Commenti
CHIH0
Wonderful strategy!!! May I see the script? Thx a lot!
thequantscience
@yauho624, Hello thank you very much! At the moment the strategy is in the testing phase, I will release a public version when I have finished testing this script.
CHIH0
@thequantscience, you are awesome!!! SIMPLE CANDLESTICK PATTERN also is an excellent strategy. It is lightweight script but the profit is quite heavy. Haha
thequantscience
@yauho624, Thank you very much. I love researching investment strategies. This was a test, I usually develop algorithms in Python and I'm approaching Pine Script slowly. I simply translated a statistical argument into Pine Script language using bars/candlesticks as a tool. It may sound very superficial but it analyses the market from a purely statistical approach. I am a bit busy at the moment but will try to get new projects out soon. I hope you'll have a chance to give me your opinion on future works as well. Thanks again and I'm here for any information you need.
CHIH0
@thequantscience, Thank you for your prompt reply. I also find it interesting, I am learning now. If you have a private version, I'd be happy buy for it.
thequantscience
@yauho624 it's easy to answer quickly: I live my life in front of screens lol. You are very kind. I am preparing some bundles with statistical algorithms which I am currently testing on a personal account. As soon as the testing period is end, they can be purchased. I will post more information about this in the near future.
CHIH0
@thequantscience, Thanks! I am looking forward to your new work!
thequantscience
@yauho624, thank you for your kindness and for taking the time to analyze the projects. I will publish soon.
CHIH0
@thequantscience, Dear Sir, may I ask you some questions about my script?
CHIH0
@thequantscience, I have written a code of time limit but doesn’t work. Could you help me fix it?
Altro