Implementing Multi-Timeframe Analysis for Intraday Trading Decisions

20 Jul 2018
0 comment
0 attachment

This ProBuilder code snippet demonstrates how to use multi-timeframe analysis to make intraday trading decisions based on daily and 5-minute timeframes. The strategy aims to buy and sell within the same trading day under specific conditions.

defparam cumulateorders=false

TIMEFRAME (daily,updateonclose)
close30=close[30]
close9=close[9]

TIMEFRAME (5 minute,updateonclose)
condition = close>close30 and close if not onmarket and condition then
buy at market
endif
if longonmarket and time=172500 then
sell at market
endif

graph close30
graph close9 coloured(200,0,0)
graph close
//graph condition

This code snippet is structured to facilitate understanding of how to handle multiple timeframes and conditional trading within the ProBuilder language:

  • Parameter Settings: The defparam cumulateorders=false line ensures that each order is executed independently without combining with previous orders.
  • Setting Timeframes: The TIMEFRAME function is used twice to specify different timeframes:
    • Daily timeframe to calculate two moving averages (close30 and close9).
    • 5-minute timeframe to set trading conditions and execution times.
  • Condition Definition: A condition is defined where the current price (close) must be greater than the 30-day moving average (close30) and less than the 9-day moving average (close9) at exactly 9:00 AM.
  • Buy Order: A market order to buy is placed if the defined condition is true and there is no open position (not onmarket).
  • Sell Order: If there is a long position (longonmarket), a market order to sell is placed at 5:25 PM.
  • Graphical Output: The moving averages and the current price are plotted for visual analysis. The close9 moving average is colored red for distinction.

This example illustrates the practical application of multi-timeframe analysis in trading strategies, allowing for more nuanced decision-making based on different market conditions observed on various time scales.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/sell-same-bar-close/#post-87943

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 Legend
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
135
strategy
171

Recent Snippets

A multi indicator Dashboard for ProRealTime
indicator
This snippet creates a compact on-chart dashboard that aggregates multiple indicator states into a single, readable [...]
How to Track Up/Down Cumulative Volume Inside Each Candle (Tick Volume Delta)
indicator
This snippet separates the real-time, intra-candle volume into up-volume and down-volume based on whether the last [...]
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 [...]
Logo Logo
Loading...