|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +# |
| 4 | +# Jackrabbit Relay Technical Analysis example |
| 5 | + |
| 6 | +# 2021-2025 Copyright © Robert APM Darin |
| 7 | +# All rights reserved unconditionally. |
| 8 | + |
| 9 | +import sys |
| 10 | +sys.path.append('/home/GitHub/JackrabbitRelay/Base/Library') |
| 11 | +import os |
| 12 | +import math |
| 13 | +import json |
| 14 | +import datetime |
| 15 | +import time |
| 16 | + |
| 17 | +import JackrabbitRelay as JRR |
| 18 | +import JRRtechnical as jrTA |
| 19 | + |
| 20 | +# Example output: |
| 21 | + |
| 22 | +# Header is NOT inclused in output, I added it here to demonstrate the way the |
| 23 | +# code works as you build the rolling window. This CAN and WILL get very |
| 24 | +# complicated as you add indicators and layers to your analysis. |
| 25 | + |
| 26 | +# 9/Crossing distance is the distance between the first value and the second value. |
| 27 | +# 10/Crossing, 1 fast (first value) crosses over slow (second value), bullish. |
| 28 | +# -1, Bearish, opposite of bullish, 0 no crossing. |
| 29 | + |
| 30 | +# 0/Date and Time 1/Open 2/High 3/Low 4/Close 5/Volume 6/+DI 7/-DI 8/ADX 9/Cross Dist 10/Crossing |
| 31 | +# 2025-09-20 11:38:00 0.88973000 0.89000000 0.88970000 0.89000000 868.53787000 ---------------- ---------------- ---------------- ---------------- ---------------- |
| 32 | +# 2025-09-20 11:39:00 0.89056000 0.89060000 0.89056000 0.89060000 73747.03466000 42.12806933 45.97977853 4.37158470 ---------------- ---------------- |
| 33 | +# 2025-09-20 11:40:00 0.89060000 0.89092000 0.89060000 0.89092000 36793.91174000 46.29913221 41.09239408 5.95794393 5.20673813 1.00000000 |
| 34 | +# 2025-09-20 11:41:00 0.89092000 0.89110000 0.89092000 0.89110000 19803.87053000 45.71723426 41.53766770 1.07580130 4.17956656 0.00000000 |
| 35 | +# 2025-09-20 11:42:00 0.89143000 0.89183000 0.89143000 0.89183000 263069.34027000 47.00251889 40.55415617 0.14729574 6.44836272 0.00000000 |
| 36 | + |
| 37 | +def main(): |
| 38 | + ta=jrTA.TechnicalAnalysis('kraken','MAIN','ADA/USD','1m',197) |
| 39 | + ohlcv=ta.ReadOHLCV('ADAUSD.txt') |
| 40 | + |
| 41 | + Period=14 |
| 42 | + |
| 43 | + Opening=1 |
| 44 | + HighIDX=2 |
| 45 | + LowIDX=3 |
| 46 | + Closing=4 |
| 47 | + Volume=5 |
| 48 | + |
| 49 | + # Colums representing +DI and -DI |
| 50 | + |
| 51 | + diP=6 # +DI |
| 52 | + diM=7 # -DI |
| 53 | + |
| 54 | + for slice in ohlcv: |
| 55 | + ta.Rolling(slice) |
| 56 | + |
| 57 | + ta.ADX(HighIDX,LowIDX,Closing,Period) |
| 58 | + ta.Cross(diP,diM) # +DI>-DI bullish, +DI<-DI bearish, these as crossings |
| 59 | + |
| 60 | + ta.Display(-1) |
| 61 | + |
| 62 | +if __name__=='__main__': |
| 63 | + main() |
| 64 | + |
| 65 | +### |
| 66 | +### End demo |
| 67 | +### |
| 68 | + |
| 69 | + |
0 commit comments