Implementing Time and Day Conditional Flags in ProBuilder

09 Jul 2019
0 comment
0 attachment

This code snippet demonstrates how to use time and day conditions to set flags for trading decisions in ProBuilder. The flags are used to determine whether to execute a trade based on the specific time and day of the week.


if opentime = 110000 and opendayofweek = 1 then 
tradeflag = 1 
endif
if opentime = 110000 and opendayofweek = 6 then 
tradeflag = 0 
endif
if tradeflag and (your entry conditions) then 
buy 1 contract at market 
endif

Explanation of the Code:

  • The code uses conditional statements to set the value of tradeflag based on the time and day of the week.
  • opentime and opendayofweek are variables that represent the opening time of the trading session and the day of the week, respectively.
  • The first condition checks if the opening time is exactly 11:00:00 AM (110000) and it is Monday (opendayofweek = 1). If both conditions are true, tradeflag is set to 1 (on).
  • The second condition checks the same opening time but for Saturday (opendayofweek = 6). If true, tradeflag is set to 0 (off).
  • The final condition checks if tradeflag is on (1) and if additional user-defined entry conditions are met. If both are true, the command to buy 1 contract at market price is executed.

This snippet is useful for implementing trading strategies that are dependent on specific market opening times and days, allowing for automated trading decisions based on predefined conditions.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/no-entry-before-11am-monday/#post-76305

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.
Vonasi Master
V-oyaging ON A S-mall I-ncome
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...