Support Board
Date/Time: Thu, 28 Nov 2024 01:29:30 +0000
Post From: [Programming Help] convert this snippet of Python to ASCIL, will pay
[2023-06-21 06:02:15] |
ronvle - Posts: 4 |
hi all, appreciate if anyone could help to convert this snippet of Python to ascil. Below is my own ascil attempt code but could not achieve what I want, avgMaxATR == 0 always, willing to pay for your time also, thx Python code: df['tr0'] = abs(df["high"] - df["low"]) df['tr1'] = abs(df["high"] - df["close"].shift()) df['tr2'] = abs(df["low"] - df["close"].shift()) df['ATR'] = df[['tr0', 'tr1', 'tr2']].max(axis=1) df['avgATR'] = df['ATR'].rolling(window=length).mean() avgMaxATR = df['avgATR'].rolling(window=length).max().mean() My ascil attempt: SCFloatArray meanMaxATR; SCFloatArray ATRHigh; sc.ATR(sc.BaseDataIn, SG_ATR, 20, MOVAVGTYPE_SIMPLE); ATRHigh[sc.Index] = sc.GetHighest(SG_ATR, 20); sc.SimpleMovAvg(ATRHigh,meanMaxATR,20); msg.Format("avgMaxATR=%f, highATR=%f, currentATR=%f",meanMaxATR[sc.Index],ATRHigh[sc.Index],SG_ATR[sc.Index]); |