Long when touches VWAP

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #244208 quote
    efahmyefahmy
    Participant
    Average

    Could you please, check the below code, Buys once per day at Daily VWAP

    // Set the timeframe to daily for VWAP calculations
    TIMEFRAME (DAILY)
    //VWAP calculation
    //
    NoSunday = 0            //1=skip Sunday's
    IF (BarIndex = 0) OR (OpenDay <> OpenDay[1]) THEN
    SumVolPrice = 0
    SumVol      = 0
    ENDIF
    IF Volume > 0 THEN
    IF (OpenDayOfWeek <> 0) OR (OpenDayOfWeek = 0 AND Not NoSunday) THEN
    SumVolPrice = SumVolPrice + (Volume * close)
    SumVol      = SumVol      + Volume
    dailyVWAP        = SumVolPrice / SumVol
    ENDIF
    // Reset flags at the beginning of each new trading day
    IF IntradayBarIndex = 0 THEN
    flagDailyVWAP = 0
    ENDIF
    // Buy condition at VWAP levels (trigger only once per day)
    IF low <= dailyVWAP AND flagDailyVWAP = 0 THEN
    BUY 20 CONTRACT AT MARKET
    flagDailyVWAP = 1
    ENDIF
    #244237 quote
    JSJS
    Participant
    Master

    Try this one, I’ve done some small adjustment…

    DefParam CumulateOrders=False
    
    TIMEFRAME (DAILY)
    
    NoSunday = 0  // 1 = Skip zondag
    
    // Reset VWAP-calculation every new day
    IF (BarIndex = 0) OR (OpenDay <> OpenDay[1]) THEN
    SumVolPrice = 0
    SumVol = 0
    flagDailyVWAP = 0  // Reset flag
    ENDIF
    
    // VWAP-calculation
    IF Volume > 0 THEN
    IF (OpenDayOfWeek <> 0) OR (OpenDayOfWeek = 0 AND NOT NoSunday) THEN
    SumVolPrice = SumVolPrice + (Volume * close)
    SumVol = SumVol + Volume
    ENDIF
    ENDIF
    
    // Calculate daily VWAP (outside the IF Volume > 0)
    IF SumVol > 0 THEN
    dailyVWAP = SumVolPrice / SumVol
    ENDIF
    
    // Buy once a day when LOW <= VWAP
    IF low <= dailyVWAP AND flagDailyVWAP = 0 THEN
    BUY 1 CONTRACT AT MARKET
    flagDailyVWAP = 1  // No more orders that day
    ENDIF
    
    GraphOnPrice dailyVWAP as "DailyVWAP"
    Graph SumVol as "SumVol"
    Graph SumVolPrice as "SumVolPrice"

    Iván González thanked this post
    Scherm­afbeelding-2025-02-23-om-17.01.49.png Scherm­afbeelding-2025-02-23-om-17.01.49.png
    #244245 quote
    efahmyefahmy
    Participant
    Average
    Thanks mate
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Long when touches VWAP


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
efahmy @efahmy Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by efahmyefahmy
1 year, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/23/2025
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...