VWAP Code not working on longs

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #232077 quote
    MacroT
    Participant
    Average

    Hi,

     

    I have taken the VWAP code logic used by PRT and have a simple trading system to buy when close is below VWAP. I am running this on US 500 DFB on a 15M timeframe. The code works as an indicator but when I am trying to use it to build a trading strategy it is not returning any executions which is incorrect. Can you see any error in the code posted below

     

    DEFPARAM CumulateOrders = FALSE// Cumulating positions deactivated
    
    timeframe(daily,updateonclose)
    //PRC_VWAP intraday
    //SAME VERSION AS THE ORIGINAL VWAP FROM THE PLATFORM
    //09.01.2020
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    if day<>day[1] then
    d=0
    else
    d=d+1
    if volume >0 then
    VWAP = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
    endif
    
    
    sd = std[d](abs(typicalprice-vwap))
    
    //SDHigh8 = vwap
    //SDLow8 = vwap
    //SDHigh9 = vwap+(sd*1)
    //SDLow9 = vwap-(sd*1)
    //SDHigh10 = vwap+(sd*2)
    //SDLow10 = vwap-(sd*2)
    endif
    
    
    timeframe(default)
    
    IF Close[0]<VWAP THEN
    Trend= 1
    ELSIF Close[0]> VWAP THEN
    Trend = -1
    ELSE
    Trend = 0
    ENDIF
    
    StopLossBuy = 20
    StopLossSell = 20
    
    SellTarget = 30
    BuyTarget = 30
    
    
    
    
    
    IF Trend = 1 THEN
    BUY 10 PERPOINT AT MARKET
    SET STOP LOSS StopLossBuy
    SET TARGET pPROFIT BuyTarget
    ELSE
    ENDIF
    
    #232081 quote
    GraHal
    Participant
    Master

    Is it due to day always being different to day[1] and so d will always = o and so vwap will always = 0 using d = 0 in the formula below …

    if day<>day[1] then
    d=0
    else
    d=d+1
    if volume >0 then
    VWAP = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
    endif
    #232083 quote
    fifi743
    Participant
    Master

    it’s not the other way round

     

    IF Close[0]<VWAP THEN
    Trend= 1
    ELSIF Close[0]> VWAP THEN
    Trend = -1
    #232084 quote
    MacroT
    Participant
    Average

    Perfect – thanks

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

VWAP Code not working on longs


General Trading: Market Analysis & Manual Trading

New Reply
Author
author-avatar
MacroT @macrot Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by MacroT
1 year, 9 months ago.

Topic Details
Forum: General Trading: Market Analysis & Manual Trading
Language: English
Started: 04/30/2024
Status: Active
Attachments: No files
Logo Logo
Loading...