Tracking Buy and Sell Signals During Market Positions in ProBuilder

27 Jun 2021
0 comment
0 attachment

This ProBuilder code snippet is designed to track and count buy and sell signals during open market positions. It specifically counts the signals that occur while a long or short position is active, excluding the signals that initiate these positions. This can be useful for analyzing the frequency and timing of trading signals during open trades.


thnx. I've got a snippet I added to a rough version, i'am unsure how useful it will be. What it does i.e. for long, it shows the buy signals you miss when you're in a long positionposition, So it doesn't count the signal when the position is opened, only the buysignals when longonmarket. It does also calculated cumulative those signals which total could go up quite rapidly. In general the higher the amount of cumulative signals, is not a good sign for robustness. for testing if interested. conbuy=buysignal condsell=sellsignal // show signals once showsignals=1 if showsignals then once count1l=0 once count1s=0 if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then count2l=0 count2s=0 endif if longonmarket then if condbuy then count1l=count1l+1 count2l=count2l+1 endif endif if shortonmarket then if condsell then count1s=count1s-1 count2s=count2s-1 endif endif graph count1l as "long signals in position cumulative" graph count2l as "long signals in position" graph count1s coloured(255,0,0,255) as "short signals in position cumulative" graph count2s coloured(255,0,0,255) as "short signals in position" endif

Explanation of the Code:

  • The code initializes by setting conbuy and condsell to represent buy and sell signals respectively.
  • It uses a variable showsignals to control whether the signals are processed (set to 1 to enable processing).
  • Two sets of counters, count1l and count1s for cumulative counts, and count2l and count2s for non-cumulative counts, are initialized once when the script runs.
  • The counters are reset to zero when there is no open market position or when transitioning between long and short positions.
  • When a long position is active (longonmarket), and a buy condition (condbuy) is true, both cumulative and non-cumulative buy counters are incremented.
  • Similarly, for an active short position (shortonmarket), when a sell condition (condsell) is true, both cumulative and non-cumulative sell counters are decremented.
  • The final values of these counters are then graphed, with different colors used for long and short signals.

This snippet is particularly useful for traders and analysts looking to understand signal behaviors and their frequency during open market positions, which can be critical for refining trading strategies.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/renko-automatic-trading/page/2/#post-153425

Visit Link
What is a Snippet? A snippet is a small, reusable chunk of code designed to solve specific tasks quickly. Think of it as a shortcut that helps you achieve your coding goals without reinventing the wheel. How to Use: Simply copy the snippet and paste it into your project where needed. Don't forget to tweak it to fit your context. Snippets are not just time-savers; they're also learning tools to help you become a more efficient coder.
paul New
Code artist, my biography is a blank page waiting to be scripted. Imagine a bio so awesome it hasn't been coded yet.
Author’s Profile

Comments

Search Snippets

Showing some results...
Sorry, no result found!

Snippets Categories

global
35
indicator
133
strategy
171

Recent Snippets

How to Create a Simple MTF Trend Dashboard with EMA and SMA
indicator
This indicator builds a compact multi-timeframe (MTF) dashboard that shows whether price is trading above or below a [...]
How to Display Per-Bar Volume Accumulation in Real Time (Intrabar Updates)
global
This snippet tracks and displays the current bar’s accumulated volume while the bar is still forming, instead of only [...]
Ticks Counter: Count Tick Updates Per Bar on Tick or Time Charts
global
This snippet counts how many tick updates have occurred for the current bar by incrementing a per-bar counter on each [...]
How to Build a Step-Based Trailing Stop That Moves to Break-Even First
strategy
This snippet implements a step trailing stop that advances in fixed increments once price reaches predefined profit [...]
Utilizing Arrays to Track and Compare Indicator Values Within the Same Bar in ProBuilder
indicator
This ProBuilder code snippet demonstrates how to use arrays to compare the values of an indicator (RSI in this case) [...]
Logo Logo
Loading...