Bid Ask Spread stats not compiling

Questions about MultiCharts and user contributed studies.
designer01
Posts: 80
Joined: 02 Feb 2010

Bid Ask Spread stats not compiling

Postby designer01 » 18 Jun 2013

I need help with this PL code not compiling getting error on line 55 of function. Please help. Thanks in advance..

PLCode Function

_BIDASKSTATS

Code: Select all

//FX_HistMean
Inputs: Run1_Roll2(Numericsimple), BAMinutes(Numericsimple), oMax(numericref), oMin(numericref);

vars:
intrabarpersist PriceBA(0), intrabarpersist TicksBA(0),
intrabarpersist TimerBA(0), intrabarpersist HistMeanBA(0),
intrabarpersist MaxBA(0), intrabarpersist MinBA(0), intrabarpersist spread(0);

if LastbaronChart then begin

Spread = (InsideAsk - InsideBid);
Once Begin
MaxBA = InsideAsk - InsideBid;;
MinBA = 100;
end;

if Spread >= (MinMove / PriceScale) then begin

TicksBA = TicksBA + 1;
PriceBA = PriceBA + Spread;

if TimerBA = 0 AND Run1_Roll2 = 2 then
TimerBA = Time;

if Run1_Roll2 = 2 AND TimeToMinutes(Time) - TimeToMinutes(TimerBA) > BAMinutes then begin
TimerBA = Time;
PriceBA = PriceBA * .25;
TicksBA = TicksBA * .25;
MaxBA = Spread;
MinBA = 100;
end;

if Run1_Roll2 = 2 AND TimeToMinutes(Time) - TimeToMinutes(TimerBA) < 0 then begin
TimerBA = 001;
PriceBA = PriceBA * .25;
TicksBA = TicksBA * .25;
MaxBA = Spread;
MinBA = 100;
end;

if TicksBA > 0 then
HistMeanBA = PriceBA / TicksBA;

if InsideAsk - InsideBid > MaxBA then
MaxBA = InsideAsk - InsideBid;

if InsideAsk - InsideBid < MinBA then
MinBA = InsideAsk - InsideBid;

oMin = MinBA;
oMax = MaxBA;

end;

_BidAskStats = HistMeanBA;

end;
PLCode

FX_BidAsk Spread Stats

Code: Select all

Inputs:
TradeSize(100000), // Trade Size to Base Dollar Conversions
Run1_Roll2(1), // Choose Average Spread Calculation, 1 = Ongoing 2 = Rolling Average Spread over RollMinutes
RollMinutes(180); // Used only for Rolling Average Spread Calculations

vars: AvgBidAsk(0), AvgBidAskPips(0), MnMv(0), oMax(0), oMin(0),
AvgBidAsk$(0), MnMv$(0),Max$(0), Min$(0), MaxPips(0), MinPips(0), AvgCF(0);

AvgCF = (ProfitCF + LossCF) * .5;
AvgBidAsk = _BidAskStats(Run1_Roll2, RollMinutes, oMax, oMin);
AvgBidAsk$ = ((AvgBidAsk )* AvgCF) * TradeSize;
AvgBidAskPips = DecConvPip(AvgBidAsk);

MnMv = MinMove/PriceScale;
MnMv$ = MnMv * AvgCF * TradeSize;
MaxPips = DecConvPip(oMax);
Max$ = ((oMax )* AvgCF) * TradeSize;
MinPips = DecConvPip(oMin);
Min$ = ((oMin ) * AvgCF) * TradeSize;

Plot1(MnMv, "Frac MinMove");
Plot2(MnMv$, "Acct MnMv");
Plot3(AvgBidAsk, "Avg Sprd");
Plot4(AvgBidAskPips, "Avg Pips");
Plot5(AvgBidAsk$, "Acct AvgPips");
Plot6(oMax, "Max Sprd");
Plot7(MaxPips, "Max Pips");
Plot8(Max$, "Acct MaxPips");
Plot14(TradeSize, "Trade Size");


sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Bid Ask Spread stats not compiling

Postby sptrader » 18 Jun 2013

I made this change and function compiles... I hope it helps..

Code: Select all

vars:
intrabarpersist PriceBA(0), intrabarpersist TicksBA(0),
intrabarpersist TimerBA(0){, intrabarpersist HistMeanBA(0)},intrabarpersist _BidAskStats(0),
intrabarpersist MaxBA(0), intrabarpersist MinBA(0), intrabarpersist spread(0);
I tried to compile the indicator but it's calling for the "DecConvPip" function that I don't have...

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Bid Ask Spread stats not compiling

Postby designer01 » 18 Jun 2013

sptrader, Thank you...See requested function below... is the vars you added in addition to the vars or replacing the vars in the code? Could you post the full code as compiled... I'm not able to compile yet.

PLCode Function

DecConvPip

Code: Select all

inputs: DecNum(numeric);
vars: PipVal(0), YenOffset(0);

YenOffset = Fx_YenOffset;

if Category = 12 then
PipVal = DecNum * 10000 * YenOffset
else
PipVal = DecNum / (MinMove/PriceScale);

DecConvPip = PipVal;

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Bid Ask Spread stats not compiling

Postby sptrader » 19 Jun 2013

//FX_HistMean
Inputs: Run1_Roll2(Numericsimple), BAMinutes(Numericsimple), oMax(numericref), oMin(numericref);

vars:
intrabarpersist PriceBA(0), intrabarpersist TicksBA(0),
intrabarpersist TimerBA(0),intrabarpersist _BidAskStats(0),
intrabarpersist MaxBA(0), intrabarpersist MinBA(0), intrabarpersist spread(0);

if LastbaronChart then begin

spread = (InsideAsk - InsideBid);
Once Begin
MaxBA = InsideAsk - InsideBid;;
MinBA = 100;
end;

if spread >= (MinMove / PriceScale) then begin

TicksBA = TicksBA + 1;
PriceBA = PriceBA + spread;

if TimerBA = 0 AND Run1_Roll2 = 2 then
TimerBA = Time;

if Run1_Roll2 = 2 AND TimeToMinutes(Time) - TimeToMinutes(TimerBA) > BAMinutes then begin
TimerBA = Time;
PriceBA = PriceBA * .25;
TicksBA = TicksBA * .25;
MaxBA = spread;
MinBA = 100;
end;

if Run1_Roll2 = 2 AND TimeToMinutes(Time) - TimeToMinutes(TimerBA) < 0 then begin
TimerBA = 001;
PriceBA = PriceBA * .25;
TicksBA = TicksBA * .25;
MaxBA = spread;
MinBA = 100;
end;

if TicksBA > 0 then
HistMeanBA = PriceBA / TicksBA;

if InsideAsk - InsideBid > MaxBA then
MaxBA = InsideAsk - InsideBid;

if InsideAsk - InsideBid < MinBA then
MinBA = InsideAsk - InsideBid;

oMin = MinBA;
oMax = MaxBA;

end;

_BidAskStats = HistMeanBA;
end;
//**************************************************************************
The corrected function HistMeanBA is the code above...it compiles...

The function"DecConvPip" that you just sent includes "Fx_YenOffset" must be another function that I don't have..
It's preventing compiling..

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Bid Ask Spread stats not compiling

Postby designer01 » 20 Jun 2013

Sorry about that... here it is

PLCode Function

FX_YenOffset

Code: Select all

vars: YenOffset(1);

YenOffset = 1;
if ISYEN then
YenOffset = .01;

FX_YenOffset = YenOffset;

ISYEN

Code: Select all

ISYEN = FALSE;
if RightStr(GetSymbolName, 3) = "JPY" then
ISYEN = TRUE;

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Bid Ask Spread stats not compiling

Postby sptrader » 20 Jun 2013

Code: Select all

AvgCF = (ProfitCF + LossCF) * .5;
"Profitcf" and "Losscf" seem to be the only things stopping it from compiling...


Return to “MultiCharts”