标签: algorithmic-trading

R Quant Trading

我可以使用一些帮助让我的代码正常工作.我试图根据收盘价高于MACD,布林带和慢速随机指标创建一个简单的头寸信号.我在第17行开始出错了.我不确定这是不是因为"Stock"是一个xts对象.我想在最后绘制输出图.谢谢!

#install.packages("quantmod")
library("quantmod")
#install.packages("FinancialInstrument")
library("FinancialInstrument")
#install.packages("PerformanceAnalytics")
library("PerformanceAnalytics")
#install.packages("TTR")
library("TTR")

#######################################

Stock <- get(getSymbols('CAT'))["2014::"]

# add the indicators
Stock$BBands <- BBands(HLC(Stock))
Stock$MACD <- MACD(HLC(Stock))
Stock$stochOSC <- stoch(Stock[,c("High","Low","Close")])
Stock$position <- ifelse(Cl(Stock) > Stock$BBands > Stock$MACD > Stock   $stockOSC , 1 , -1)

Gains <- lag(Stock$position) * dailyReturn(Stock)
charts.PerformanceSummary(cbind(dailyReturn(Stock),Gains))
Run Code Online (Sandbox Code Playgroud)

finance r trading algorithmic-trading quantmod

1
推荐指数
1
解决办法
703
查看次数

EA 交易与 MQL4 指标之间的交互

是否可以通过专家顾问读取预建指标的变化(例如:其价值变化),当然 - 根据这些读取自动进行交易?

负责执行此操作的功能是什么?

我试图在谷歌上查找这个,但似乎我只能做跟踪对象创建或删除之类的事情......称为图表事件......也许我错过了什么?

trading algorithmic-trading forex metatrader4 mql4

1
推荐指数
1
解决办法
2282
查看次数

我想使用 ADX 和 RSI 制定 PineScript V5 策略,但不断收到相同的错误

看来我无法找出适合我的策略的正确脚本,如下所示:

\n
    \n
  • 当 ADX 高于 46 并且同时 RSI 超卖等于或低于 20 时为买入信号
  • \n
\n

在每日时间范围内效果更好,收到的信号更少,但更有效,脚本是这样的:

\n
//@version=5\nstrategy("Estrategia Long Only")\n// Definir el indicador ADX\nlen = input(14, title="ADX Length")\nth = input(44, title="ADX Threshold")\nadx_val = ta.adx(high, low, close, len)\n// Definir el indicador RSI\nrsi_len = input(14, title="RSI Length")\nrsi_buy = input(20, title="RSI Buy Threshold")\nrsi_sell = input(35, title="RSI Sell Threshold")\nrsi_val = ta.rsi(close, rsi_len)\n// Generar se\xc3\xb1ales de compra\nadx_above_th = adx_val > th\nrsi_above_buy = rsi_val >= rsi_buy and rsi_val < rsi_sell\nbuy_signal = adx_above_th and rsi_above_buy\n// Entradas largas\nif buy_signal\n …
Run Code Online (Sandbox Code Playgroud)

algorithmic-trading tradingview-api pine-script pine-script-v5

1
推荐指数
1
解决办法
4247
查看次数

为什么我的For循环跳过步骤?[R

我的For循环似乎是跳过它应该一步一步的步骤.

简化我的代码:

for(j in 1:5){
  ventana <- spread_real[j + 1: 180 + j]
}
Run Code Online (Sandbox Code Playgroud)

它从矢量'spread_real'获取子集[j + 1:180 + j]并将其分配给变量'ventana'.

但是一旦我运行代码并且j等于5,那么ventana将获得子集spread_real [9:190]

任何帮助都会非常感激,因为我已经坚持了很长时间了.

r algorithmic-trading

0
推荐指数
1
解决办法
84
查看次数

当价格低于阈值时使用 Pandas DataFrame 实现矢量化止损

鉴于此示例数据帧:

date;close;signal;positions
2017-01-02;27.90;0.0;0.0
2017-01-03;27.76;0.0;0.0
2017-01-04;28.65;1.0;1.0
2017-01-05;28.72;1.0;0.0
2017-01-06;28.00;1.0;0.0
2017-01-09;27.03;1.0;0.0 # <<<--- Note the price is -5% when compared to 28.65 (in 2017-01-04)
2017-01-10;28.26;1.0;0.0
2017-01-11;28.35;0.0;-1.0 # <<-- Sell
2017-01-12;29.12;0.0;0.0
2017-01-13;28.99;0.0;0.0
2017-01-16;28.50;1.0;1.0
2017-01-17;28.45;1.0;0.0
2017-01-18;29.06;1.0;0.0
2017-01-19;28.74;0.0;-1.0
2017-01-20;28.76;0.0;0.0
2017-01-23;29.50;0.0;0.0
2017-01-24;29.12;1.0;1.0
2017-01-25;29.87;1.0;0.0
2017-01-26;27.22;1.0;0.0 # <<<--- Note the price is -5% when compared to 29.12 (in 2017-01-24)
2017-01-27;29.76;1.0;0.0 # <<-- still holding the position...
Run Code Online (Sandbox Code Playgroud)

我想在价格低于 5% 时实施“止损”。在这种情况下,DataFrame 应如下所示:

date;close;signal;positions
2017-01-02;27.90;0.0;0.0
2017-01-03;27.76;0.0;0.0
2017-01-04;28.65;1.0;1.0 # <<-- Buy
2017-01-05;28.72;1.0;0.0
2017-01-06;28.00;1.0;0.0
2017-01-09;27.03;0.0;-1.0 # <<-- Sell with stop-loss
2017-01-10;28.26;0.0;0.0
2017-01-11;28.35;0.0;0.0
2017-01-12;29.12;0.0;0.0
2017-01-13;28.99;0.0;0.0 …
Run Code Online (Sandbox Code Playgroud)

numpy vectorization algorithmic-trading dataframe pandas

0
推荐指数
1
解决办法
1115
查看次数

为什么我无法运行 robin_stocks 的 .login() 属性?

我正在尝试通过 robin_stocks 从 Robinhood 导入数据。我能够导入该包,但是当我尝试使用 .login() 属性时,它会在 Jupyter Notebook 中返回此错误消息:error

模块“robin_stocks”没有属性“login”

我确信 robin_stocks 确实具有 Python 告诉我不存在的属性。我这里哪里出错了?

我对编程比较陌生,但通常我可以在 StackOverflow 或任何其他资源上很快找到问题的答案。不过,我似乎无法弄清楚这一点。

任何帮助将不胜感激。谢谢你!

python authentication api attributes algorithmic-trading

0
推荐指数
1
解决办法
2387
查看次数