Implementing a Short Trading Strategy with Multiple Conditions in ProBuilder

15 Nov 2017
0 comment
0 attachment

This code snippet demonstrates how to implement a short trading strategy for EUR/USD on a 15-minute chart using multiple technical indicators in ProBuilder. The strategy includes conditions for entry and dynamic exit based on market movements.

DEFPARAM CumulateOrders = False
DEFPARAM Preloadbars = 6000
N = 1 //MINI LOT $1
Cv1 = (close < Average[100]) and (Average[50] < Average[50](close[1]))
Cv2 = RSI[14](close) < 28
Cv3 = STD[10](close) >= 10.93 * pipsize
Cv4 = close <= BollingerDown[13](close[2])
indicator1 = ExponentialAverage[5000](close)
c1 = (close > indicator1)
OKSHORT = cv1 and cv2 and cv3 and Cv4 and c1
IF OKSHORT then
    Sellshort n CONTRACT at market
endif
startBreakeven = 9
PointsToKeep = 1
IF SHORTONMARKET AND (tradeprice(1) - close) >= (startBreakeven * pipsize) THEN
    breakevenLevel = tradeprice(1) + (PointsToKeep * pipsize)
    IF breakevenLevel > 0 THEN
        EXITSHORT AT breakevenLevel STOP
    ENDIF
ENDIF
SET STOP pLOSS 48
SET TARGET ppROFIT 12

Explanation of the Code:

  • DEFPARAM: Sets parameters for the trading system. CumulateOrders is set to False to prevent accumulation of orders, and Preloadbars specifies the number of bars to preload for calculation.
  • Conditions for Short Entry (Cv1 to Cv4 and c1): Multiple conditions using moving averages, RSI, standard deviation, and Bollinger Bands to determine the right conditions for entering a short position.
  • OKSHORT: A boolean variable that combines all conditions. If all conditions are true, a short position is initiated.
  • Sellshort: Executes a short sell order if the conditions specified in OKSHORT are met.
  • Dynamic Exit Strategy: Includes a breakeven mechanism where the position is exited at a breakeven level plus a small buffer (PointsToKeep) once the trade has moved in favor by a specified number of pips (startBreakeven).
  • Stop Loss and Take Profit: Sets a stop loss and take profit level to manage risk and secure profits.

This snippet is a practical example of combining various technical indicators to create a comprehensive trading strategy in ProBuilder, focusing on short positions with dynamic exit strategies.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/short-eur-usd-m15-pac-man-strategy/#post-69698

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.
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
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...