1,282 questions
0
votes
0
answers
49
views
cTrader FIX Logon returns RET_INVALID_DATA for both QUOTE and TRADE sessions on ICMarkets
I’m trying to connect to ICMarkets cTrader FIX and both FIX Logon requests are rejected with RET_INVALID_DATA.
The TCP + SSL connection succeeds, so the failure seems to be at the FIX authentication/...
0
votes
0
answers
86
views
Reversing positions on Pinescript
I am using Pine script and want some help.
When I am in trade and my strategy generates opposite signal, how to make how close the current trade and open in the opposite direction. I am executing with ...
0
votes
1
answer
60
views
Vectorbt import hangs on Windows unless Numba JIT is disabled
I’m trying to use vectorbt in Python on Windows, but the import hangs indefinitely:
import vectorbt as vbt # hangs here
Environment / Versions I’ve tested:
Python: 3.9, 3.10, 3.11, 3.12, 3.13 (all ...
Advice
0
votes
0
replies
55
views
In IBKR API, how to retrieve stock data after a corporate action causing a contract id change?
To retrieve stock data, I always used:
Contract contract = new Contract(); //contract instance
contract.Symbol = "LRCX”; //ticker here
contract.SecType = "STK"; //contract type stock
...
0
votes
0
answers
162
views
VOLD Ratio using Polygon data
HI I'm trying to calculate VOLD Ratio, but when I'm testing my functionality I'm facing below issues
Getting mismatch between polygon volume vs trading view volume (-2.5%)
My VOLD Ratio is much more ...
0
votes
0
answers
97
views
Lean CLI does not show "backtest" command after installation
I am trying to install Lean CLI on Windows 10 inside a virtual environment (venv), but after installation I do not see the backtest command.
Here are the exact steps I did:
Created and activated a ...
0
votes
0
answers
101
views
RL Trading Agent Can't Learn Sensible Behavior Even on a Simple Sine Wave — What Am I Doing Wrong?
I’ve been building a reinforcement learning trading agent using a synthetic sine wave as the price series — basically the simplest dataset I could imagine to test whether an agent can learn to buy low ...
0
votes
0
answers
96
views
In Algotrading, How to Incrementally Calculate Features for New Live Candles, Ensuring Full-Backtest Consistency (Pandas/TA/ML)
I'm developing a live trading bot in Python that fetches OHLCV data (e.g., 15m candles) and computes a large number of features—rolling indicators (VWAP/Volume-ADI,SMA/EMA/ATR/RSI), price action, ...
0
votes
1
answer
186
views
How to place IBKR bracket order before market open using actual open price for TP/SL?
I'm trying to place a market-on-open (MOO) bracket order through Interactive Brokers using ib_insync. My goal is to:
Enter the trade strictly at the market open (9:30 AM ET)
Calculate take-profit (TP)...
1
vote
1
answer
113
views
IBKR place order issue "Can not contain field # 8089"
When I try to place order using following payload and following error although payload is correct, is there something that I need to for placing order on IBKR. I am using paper trading account.
Here ...
-1
votes
1
answer
40
views
Future Looking Target Variables in Light GBM
I am working on a ML model using LightGBM classifier with a task to maximise a value( PnL) for a quantitative strategy.
I am entering a trade every Monday and can hold till Friday close.
I want to ...
0
votes
0
answers
290
views
How to add a multi-timeframe signal dashboard (table) in a Pine Script strategy based on the strategy signals?
I'm working on a Pine Script strategy on TradingView that generates buy/sell signals using custom logic based on vwap and EMA crossover. The core signals are already implemented using strategy.entry() ...
0
votes
1
answer
60
views
How to resolve the error: "cannot initialize variable with None; optionals are explicit"
I'm using TakeProfit's Indie Script Indicator.
I'm getting an error when trying to initialize a variable to None.
Here's a simplified version of the code:
# indie:lang_version = 5
from math import nan,...
0
votes
1
answer
74
views
Indie indicator loads, but plotting randomly fails
I'm trying to create the Oscillator based on Indie Script. The logic seems fine, and the indicator compiles successfully in Indie. However, at runtime, I get a math domain error with no line number or ...
0
votes
1
answer
100
views
MQL4 OrderSend Failed Error 130 - why even with no SL?
I'm trying to create a simple EA tool in MT4 so that I can drag and drop two lines on the chart, and based on input parameters it calculates lot size, and then when I press execute, it enters a limit ...
2
votes
0
answers
35
views
How to preserve state across bars in @sec_context in TakeProfit's Indie?
I'm trying to port an indicator from Pine Script to TakeProfit's Indie V5. I use @sec_context to get higher-timeframe values, similar to request.security() in Pine.
In PineScript, I can use var to ...
1
vote
1
answer
36
views
How to reference the current instrument ID to use calc_on()
I'm writing an indicator in Indie v5 and want to get higher timeframe values using calc_on(). The documentation suggests using something like:
sec_ctx = self.calc_on(self.symbol, htf)
However, this ...
4
votes
1
answer
54
views
TakeProfit Indie - Displaying Labels in Front of Candlesticks
I'm working with the Indie library to create a candlestick pattern indicator, and I'm facing an issue with how labels are displayed on the chart. As you can see in the attached screenshot, the ...
1
vote
1
answer
28
views
"Symbol wave.set not found" when trying to modify a MutSeriesF
I’m facing an Indie script error. I’m running into an issue when trying to update a MutSeriesF variable. Specifically, I get this error:
Error: [internal] symbol wave.set not found
My code:
# indie:...
0
votes
0
answers
71
views
"None" return in a buy order in MT5 via Python
I'm trying to put a buy order but the result is "none".
If I try to put the same order (same lot, SL,TP) directly in MT5 it goes well.
Below the abstract code.
I set "algo trading" ...
0
votes
0
answers
132
views
Writing a mql5 function that calculates the profit and loss of a position in cash
I would like to make an EA that calculates the loss in cash in the account's currency base. This function is considered as an essential function for all the profitable multi-currency trading EAs that ...
0
votes
1
answer
431
views
How to get the ADX with pandas-ta library in Python without smoothing?
I need the ADX indicator in my Python code and I am using the pandas-ta library. The values given from the pandas-ta library is the smoothed version of the ADX, I need the 'raw' version.
I have tried ...
1
vote
2
answers
230
views
Why is my python script working sometimes but not others? There seems to be a delay for it to work
HI i have put the below code together to look at the previous days high and low and then compare it to the day before to see what type of day it is with regards to the stock market.
I am having ...
0
votes
1
answer
504
views
Cannot get SPX live data to pull from IBKR API
I'm using the following code to try and pull the current price of SPX during regular trading hours, but it is giving me yesterday's close price. This is utilizing the TWS API.
I have market data ...
0
votes
2
answers
615
views
TradingView Pine Script Breakout Strategy - Problem same bar close
I build a breakout strategy in Pine Script:
If the close of the current bar is higher than the highest high of the last 100 bars, go long
If the close of the current bar is lower than the lowest low ...
0
votes
0
answers
188
views
How to calculate a provisional HTF indicator value on the current timeframe?
I hope I find great guidance with you :)
I'm struggling with an issue related to calculating higher timeframe (HTF) indicators on a lower timeframe (LTF) chart in Pine Script. Specifically, I want to ...
0
votes
0
answers
47
views
My weekly/month dema strategies doesn't compatible with tradingview
Even after using GPT, I couldn't quite figure out the exact reason why my code isn't working as expected.
Here's what I'm trying to achieve:
For Weekly Signals: My goal is to receive buy and sell ...
0
votes
2
answers
334
views
I am merging the RSI and VWAP codes to create a AI bot. The error is - The 'strategy.exit' function does not have an argument with the name 'when'
I am new to pinescript/ coding/ AI/ trading and am using chatGPT to sort of gain an understanding of things.
I am merging the VWAP and RSI code to create an AI strategy. I come to the same error ...
0
votes
0
answers
41
views
Question about the proper setup of exit alarms
Maybe you can help me with the following:
The problem is with the exit after TSL. On entry, I pass the initial value of the TSL (which is still an SL at the time) to the PineConnector. With the exit ...
1
vote
0
answers
384
views
Real SMT Divergence indicator
I am trying to build real smt divergence indicator. The ones on tradingview arent good. I have the code for the fractal indicator, which marks out, in real time, proper lows and highs. I want to add ...
3
votes
2
answers
78
views
How to open an opposite position immediately after hit SL? An issue in MQL4
When a certain buy condition is met, I want to open a buy position and set the take profit (TP) and stop loss (SL) based on the candle length.
I found a Martingale strategy on Forex Factory that is ...
1
vote
0
answers
53
views
The value of the two variables calculated in same way but can't match in pine script
I am trying to transfer the pine script to another programming language, so I need to figure out all the variables. Here is my code :
// Define bar structure for Heikin Ashi method
type HA
...
1
vote
1
answer
105
views
Understanding history reference operator with Custom Functions in Pine Script
I am trying to understand how to use history reference operator with custom functions in Pine Script Version 5 to better understand the usages of history reference operator.
I have seen the following ...
0
votes
0
answers
111
views
Pinscript 2 - Write strategy instructions for alerts and webhook
I have an indicator that is still written in Pinscript 2. I tried to convert the indicator to Pinescript 5.
Unfortunately, the indicator loses its precision when converted to Pinescript. The displays ...
0
votes
0
answers
84
views
Removing Weekends from Historical Stock Data from Oanda API
I'm pretty new to programming and I am learning to code a backtest with data from Oanda API. When I plot the chart below, I get these gaps on weekends. I check the data and index(time) does not show ...
0
votes
0
answers
258
views
How to Transfer 5-Minute Boxes to 1-Minute Timeframe in Pine Script without Changing Their Position or Count?
I am currently working on a Pine Script project where I need to transfer boxes drawn on a 5-minute timeframe to a 1-minute timeframe. My goal is to do this without changing the position or the number ...
1
vote
0
answers
532
views
Schwab API Trade Python Account Hash
I'm trying to set up an API that allows me to trade stocks via my Schwab account. It seems like Schwab requires me to obtain my account hash first before I can send out any trade orders. I've tried ...
0
votes
1
answer
175
views
AlertCondition() is not triggering the buy and sell alerts even after handling the state management
Below is the script for plotting option premium as candles in a seperate pane (not in main chart/pane) and triggering buy and sell alerts. But the script is not trigerring any alerts or alerts are ...
2
votes
0
answers
376
views
I need help to combined two swaps in one transaction like a bundle on jupiter api, I always got Transaction too large error
What I did is, get the quotes from two swaps using jupiter api, then make the quotes as swap instructions and bundle it together like this:
// Combine both swap instructions into a single transaction
...
0
votes
1
answer
67
views
KeyError when accessing tuned signal data in backtest function
I'm working on a trading algorithm and encountering a KeyError while trying to access a column in a DataFrame. Specifically, I run into the error during the backtesting phase when accessing a tuned ...
-1
votes
1
answer
342
views
how to implement ask and bid price in entry price in backtesting.py
I want to implement spread so I calculate the ask and bid price already
class TestStrategy(Strategy):
def next(self):
current_price = self.data.Close[-1]
current_spread = self....
0
votes
1
answer
168
views
How can I calculate my spread data upon entry and exit I only have spread in for per row in my csv
I'm trying to make a back trading class. but I don't really get how spread works for example if you buy in 1.06649 how will spread works here? and in the same trade if I exit in my intended take ...
0
votes
1
answer
43
views
Can't the multiple-value return of a function be attributed to multiple global variables? If not, what's the best alternative?
The following doesn't work. How to fix it or what's the best alternative?
var float avgBuyPrice = na
var float safetyTradeSize = na
var float safetyTradePrice = na
recalculate() =>
_avgBuyPrice ...
0
votes
1
answer
53
views
How to properly put a "safety trade" into a trade strategy? (How to add a long positon to an already existing open one?)
I'm struggling to add a safe trade to the following strategy.
When I run the code, the safety trades are not put, even if the conditions are met.
In the example below, it should buy 2* the initial ...
0
votes
1
answer
207
views
Wrong greeks (delta, vega, ...) results when requesting data using reqMktData
I am using the native library ibapi (Interactive Brokers). I have the following code:
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import ...
0
votes
1
answer
129
views
How to add prefix before value in the status line of chart(PINE script)
can't add prefix here
below is my code
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Bao1984
//@version=5
indicator("...
1
vote
0
answers
123
views
problem on state representaion Finrl StockTradingEnv
i'm trying to adjust and apply my own trading strategies on Finrl meta environment and ensmeble agent method. in this process i decide to add some new features which are produced by a neuran network ...
1
vote
1
answer
2k
views
How to automate tradingview.com with binance to automaticly buy and sell based on indicator
I want to automate buying and selling on tradingview.com based on loaded indicator.
I have connected tradingview.com with binance.
I want to trade BTCUSDT.
I have loaded UT Bot Alerts indicator into ...
1
vote
0
answers
80
views
Import Pandas in MetaEditor5 Python Script
I am trying to write a python script for a trading bot. I have opened up MetaEditor5 and I have created a new python script where the next pop-up asks me which packages I want to import and only ...
1
vote
1
answer
3k
views
MT5 and Python Trading Bot
I am relatively new to trading and autonomous trading. I have implemented a trading bot in python (using anaconda navigator and Spyder) where I am using the MetaTrader5 API which is offered.
My bot ...