Implementing Pivot Point Strategy for Trading Decisions in ProBuilder

13 Jan 2018
0 comment
0 attachment

This code snippet demonstrates how to use pivot points as a trading strategy in the ProBuilder language. Pivot points are used to determine potential support and resistance levels. The script identifies conditions under which to enter buy or sell trades based on these pivot points.

DEFPARAM CumulateOrders = False
SL = 200 * PipSize
TP = SL * 3
N = 5
PP = (DHigh(1) + DLow(1) + DClose(1))/3 //PP calculation

// Res1 = summation[N](close <= PP) = N
Res2 = summation[N](high >= PP)
Res = Res1 AND Res2

// Sup1 = summation[N](close >= PP) = N
Sup2 = summation[N](low <= PP)
Sup = Sup1 AND Sup2

IF Sup AND Not LongOnMarket THEN
    BUY 1 CONTRACT AT MARKET
ELSIF Res AND Not ShortOnMarket THEN
    SELLSHORT 1 CONTRACT AT MARKET
ENDIF

// SET TARGET pPROFIT TP
// SET STOP pLOSS SL

// GraphOnPrice PP AS "Pivot" coloured("Fuchsia",255)
GraphOnPrice TradePrice AS "TradePrice" coloured("Cyan",255)

Explanation of the Code:

  • Parameter Settings: Orders are not cumulated, and stop loss (SL) and take profit (TP) levels are set based on pip size.
  • Pivot Point Calculation: The pivot point (PP) is calculated as the average of the previous day's high, low, and close prices.
  • Resistance Conditions: Two conditions are checked over the past N days: whether the close was below the PP (Res1) and whether the high was above the PP (Res2). A trade signal for selling is generated if both conditions are true.
  • Support Conditions: Similarly, it checks if the close was above the PP (Sup1) and the low was below the PP (Sup2) over the past N days. A buy signal is issued if both conditions hold true.
  • Trade Execution: The script executes a buy order if there is support and no existing long position, or a sell order if there is resistance and no existing short position.
  • Graphical Representation: The pivot point and the trade price are graphically represented on the price chart for visual reference.

This snippet is a practical example of how to implement a basic pivot point trading strategy using conditional logic and graphical elements in ProBuilder.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/pivots-points-buy-and-sell-short-strategy/#post-220547

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.
ROBERTO New
I usually let my code do the talking, which explains why my bio is as empty as a newly created file. Bio to be initialized...
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...