Relative Content

Tag Archive for pine-script

pinescript strategy_direction as a variable?

I want only one strategy.entry() rule in my script (the both directions should be in a variable). The reason for that is, that I want a strategy.exit() rule independent of the strategy.entry() rule.
The following code shows what I mean, but it doesn’t work.

Is there a way to make Renko bars, retrieved from request.security(), consistent between re-compilations?

I am building a strategy that is partially based on Renko bars. The strategy will produce decent results in backtesting, but then I will close the chart and reload it and it produces different results. I plotted the renko bars for debugging purposes and when I get bad results the bars are completely different. Someone from the Pine team suggested to use lookahead_on and close[1] when using the request.security() method. This causes massive delays, since I am accessing Renko from the same timeframe, and makes my strategy extremely unprofitable. It also doesn’t fix the repainting issue when recompiling. The only fix I could see fixing it, would be to add an extra parameter for the Renko request function that specifies a starting bar or starting price level so the Renko calculations will remain consistent between compilations. Maybe the Renko logic already starts at a static level and it is a different problem I am missing. Let me know if someone else has seen this problem / drawback before.

time-structure heatmap for trades

I would like to visualize the time structure of my trades in a heatmap. The x-axis should be the days of the week from Monday to Sunday, and the y-axis should be the hours. Displaying it in a table is probably best suited for this. The height of the cells should be 4 hours and the frequency of trages in a certain time window should be expressed in different colors (blue for a few and red for many trades). I’ve been trying for a while now, but I can’t find my mistake. attached is the example code.

add the trade number to trade_id

I’m currently learning, i.e. I’m working my way through the pine-script manual, trying out a lot of things and looking to see whether there are already solutions to my questions. But now I can’t find a satisfactory solution to the following point: I want to display the trade numbers, which can be found in the first column in the strategy tester in the ‘List of trades’ tab, on the chart both at entry and at exit. I tried the following:
The chart on tradingview is: BTCUSDTPERP PERPETUAL MIX CONTRACT.30.BITGET
is the corresponding 30min chart with the following script (essentially from the manual):

add the trade number to trade_id

I’m currently learning, i.e. I’m working my way through the pine-script manual, trying out a lot of things and looking to see whether there are already solutions to my questions. But now I can’t find a satisfactory solution to the following point: I want to display the trade numbers, which can be found in the first column in the strategy tester in the ‘List of trades’ tab, on the chart both at entry and at exit. I tried the following:
The chart on tradingview is: BTCUSDTPERP PERPETUAL MIX CONTRACT.30.BITGET
is the corresponding 30min chart with the following script (essentially from the manual):

add the trade number to trade_id

I’m currently learning, i.e. I’m working my way through the pine-script manual, trying out a lot of things and looking to see whether there are already solutions to my questions. But now I can’t find a satisfactory solution to the following point: I want to display the trade numbers, which can be found in the first column in the strategy tester in the ‘List of trades’ tab, on the chart both at entry and at exit. I tried the following:
The chart on tradingview is: BTCUSDTPERP PERPETUAL MIX CONTRACT.30.BITGET
is the corresponding 30min chart with the following script (essentially from the manual):