Code Error Correction Assistance

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #226793 quote
    Marketpunk
    Participant
    New

    Hello,

    Looking for some assistance to fix some code please.  The code with in BOLD lines are errors that appear to be incorrect

    Any assistance is greatly appreciated.Thank you for your time

    Here is the code

    // Rolling VWAP
    // v3, 2022.07.24

    // Constants
    MS_IN_MIN = 60 * 1000;
    MS_IN_HOUR = MS_IN_MIN * 60;
    MS_IN_DAY = MS_IN_HOUR * 24;

    TT_SRC = ‘The source used to calculate the VWAP. The default is the average of the high, low, and close prices.’;
    TT_WINDOW = ‘By default, the time period used to calculate the RVWAP automatically adjusts with the chart”s timeframe.’;
    TT_MINBARS = ‘The minimum number of last values to keep in the moving window, even if these values are outside the time period.’;
    TT_STDEV = ‘The multiplier for the standard deviation bands offset above and below the RVWAP.’;
    TT_TABLE = ‘Displays the time period of the rolling window.’;

    // Inputs
    srcInput = close; // Assuming hlc3 in Pine Script is equivalent to the close in ProRealTime
    fixedTfInput = request.bool(false, ‘Use a fixed time period’);
    daysInput = request.integer(1, ‘Days’) * MS_IN_DAY;
    hoursInput = request.integer(0, ‘Hours’) * MS_IN_HOUR;
    minsInput = request.integer(0, ‘Minutes’) * MS_IN_MIN;
    showInfoBoxInput = request.bool(true, ‘Show time period’);
    infoBoxSizeInput = request.string(‘small’, ‘Size ’, ‘tiny;small;normal;large;huge;auto’);
    infoBoxYPosInput = request.string(‘bottom’, ‘↕’, ‘top;middle;bottom’);
    infoBoxXPosInput = request.string(‘left’, ‘↔’, ‘left;center;right’);
    infoBoxColorInput = request.color(gray, ”);
    infoBoxTxtColorInput = request.color(white, ‘T’);

    stdevMult1 = request.float(0.0, ‘Bands Multiplier 1’);
    stdevMult2 = request.float(0.0, ‘Bands Multiplier 2’);
    stdevMult3 = request.float(0.0, ‘Bands Multiplier 3’);
    stdevColor1 = request.color(green, ”);
    stdevColor2 = request.color(yellow, ”);
    stdevColor3 = request.color(red, ”);

    minBarsInput = request.integer(10, ‘Bars’);

    // Functions
    function timeStep: integer;
    var
    tfInMs: integer;
    begin
    tfInMs := timeframeinseconds * 1000;

    if tfInMs <= MS_IN_MIN then
    result := MS_IN_HOUR
    else if tfInMs <= MS_IN_MIN * 5 then
    result := MS_IN_HOUR * 4
    else if tfInMs <= MS_IN_HOUR then
    result := MS_IN_DAY * 1
    else
    result := 0; // You may want to handle additional cases as needed
    end;

    // Calculations and Plots
    if islast and ta.cum(nz(volume)) = 0 then
    print(‘No volume is provided by the data vendor.’);

    timeInMs := fixedTfInput ? minsInput + hoursInput + daysInput : timeStep();

    sumSrcVol := totalforTimeWhen(srcInput * volume, timeInMs, true, minBarsInput);
    sumVol := totalforTimeWhen(volume, timeInMs, true, minBarsInput);
    sumSrcSrcVol := totalforTimeWhen(volume * power(srcInput, 2), timeInMs, true, minBarsInput);

    rollingVWAP := sumSrcVol / sumVol;

    variance := sumSrcSrcVol / sumVol – sqr(rollingVWAP);
    variance := max(0, variance);

    stDev := sqrt(variance);

    upperBand1 := rollingVWAP + stDev * stdevMult1;
    lowerBand1 := rollingVWAP – stDev * stdevMult1;

    upperBand2 := rollingVWAP + stDev * stdevMult2;
    lowerBand2 := rollingVWAP – stDev * stdevMult2;

    upperBand3 := rollingVWAP + stDev * stdevMult3;
    lowerBand3 := rollingVWAP – stDev * stdevMult3;

    plot(rollingVWAP, ‘Rolling VWAP’, orange);

    p1 = plot(stdevMult1 <> 0 ? upperBand1 : na, ‘Upper Band 1’, stdevColor1);
    p2 = plot(stdevMult1 <> 0 ? lowerBand1 : na, ‘Lower Band 1’, stdevColor1);

    p3 = plot(stdevMult2 <> 0 ? upperBand2 : na, ‘Upper Band 2’, stdevColor2);
    p4 = plot(stdevMult2 <> 0 ? lowerBand2 : na, ‘Lower Band 2’, stdevColor2);

    p5 = plot(stdevMult3 <> 0 ? upperBand3 : na, ‘Upper Band 3’, stdevColor3);
    p6 = plot(stdevMult3 <> 0 ? lowerBand3 : na, ‘Lower Band 3’, stdevColor3);

    fill(p1, p2, color.new(green, 95), ‘Bands Fill’);
    fill(p3, p4, color.new(green, 95), ‘Bands Fill’);
    fill(p5, p6, color.new(green, 95), ‘Bands Fill’);

    // Display of time period.
    tfDisplay = table.new(infoBoxYPosInput + ‘_’ + infoBoxXPosInput, 1, 1);
    if showInfoBoxInput and islastconfirmedhistory then
    table.cell(tfDisplay, 0, 0, tfString(timeInMs), bgcolor = infoBoxColorInput, text_color = infoBoxTxtColorInput, text_size = infoBoxSizeInput);

    #226797 quote
    robertogozzi
    Moderator
    Master

    That code is written in a different language than ProReralTime’s. Each line contains several errors.

    It should be converted to PRT.

    You may want to ask for a free conversion at https://www.prorealcode.com/free-code-conversion/.

    #226799 quote
    Marketpunk
    Participant
    New

    Thank you. I have sent conversion request as advised. Thank you for your help.

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

Code Error Correction Assistance


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Marketpunk @marketpunk Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Marketpunk
2 years, 1 month ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/23/2024
Status: Active
Attachments: No files
Logo Logo
Loading...