I am trying to create an indicator for NT7 from the logic as below:
lenF = 12; // amount of bars used as sample to calculate fast moving average
lenS = 26; // amount of bars used as sample to calculate slow moving average
lenT = 9; // amount of bars used to calculate signal for VPCI
mult = 2.0;
// Functions
PriceFun(VPC,VPR,VM,src) => //function calculating stop-loss step in relation with Volume and minimal price
VPCI=VPC*VPR*VM
lenV = if VPC <0
int(round(abs(VPCI-3)))
else if VPC>=0
round(VPCI+3)
else
1
VPCc = if (VPC > -1 and VPC <0)
-1
else if (VPC < 1 and VPC >= 0)
1
else
VPC
Price=0.0
for i=0 to lenV - 1
Price = Price+(src[i]*1/VPCc[i]*1/VPR[i])
PriceV=Price/lenV/100
PriceV
// Calculations
VWmaS = vwma(Close, lenS) // Fast volume weighted moving average
VWmaF = vwma(Close, lenF) // Slow volume weighted moving average
AvgS = sma(Close, lenS) // Slow Volume average
AvgF = sma(Close, lenF) // Fast Volume average
VPC = VWmaS - AvgS // Volume-Price Confirmation/Contradication VPC+/-
VPR = VWmaF/AvgF // Volume-Price Ratio
VM = sma(volume,lenF)/sma(volume,lenS) // Volume Multipler
VPCI=VPC*VPR*VM // Volume-Price Confirmation indicator
DeV = mult*VPCI*VM // Deviation
StopLoss = sma(low - PriceFun(VPC,VPR,VM,low) + DeV , lenS)
But when I plotted the indicator kind of weird curve and far away from Price. Could anyone please take a look and point out what is wrong with it?
Any help will be appreciated !
Comment