Average of TTM Scalp
Posted: Thu Nov 20, 2008 9:41 pm
Everything plots the way it should except if you have to reboot chart the values change. Do you think that's a data or charting (MultiChart) issue? I use it as a 50% line, price always wants to come back it to. Make up your own rules and profit.
inputs:
len (4);
variables:
theavg(0),
highBarsAgo(1),
possibleHighBarsAgo(1),
possibleHigh(-2),
hightoBeat(-1),
barsSincePaint(1),
lowBarsAgo(1),
possibleLowBarsAgo(1),
possibleLow(10000001),
lowtoBeat(10000000),
triggerPriceSell(-1),
triggerPriceBuy(1000000),
trend(1),
_UP(1),
_DOWN(-1),
_ON(1),
_OFF(-1),
s_low(1),
s_high(1);
//***************************************************
//****** Find and plot the highest swing high *******
//***************************************************
if trend = _UP then begin
if swingHighBar(1,H,1,barsSincePaint+2) > -1 then begin
possibleHighBarsAgo = swingHighBar(1,H,1,barsSincePaint+2);
possibleHigh = H[possibleHighBarsAgo];
end;
if possibleHigh >= hightoBeat then begin
highBarsAgo = possibleHighBarsAgo;
hightoBeat = possibleHigh;
triggerPriceSell = L[HighBarsAgo - 1];
end;
if C < triggerPriceSell and
highest(high,highBarsAgo) < hightoBeat then begin
//plotpb[highBarsAgo](H[highBarsAgo],L[highBarsAgo],"");
trend = _DOWN;
barsSincePaint = highBarsAgo-1;
hightoBeat = -1;
lowtoBeat = 10000000;
triggerPriceBuy = 10000000;
triggerPriceSell = -1;
highBarsAgo = 1;
possibleHigh = -2;
s_high = L[HighBarsAgo - 1];
theavg = average((( s_low + s_high) /2 ), len);
end;
end;
//***************************************************
//****** Find and plot the lowest swing low *********
//***************************************************
if trend = _DOWN then begin
if swingLowBar(1,L,2,barsSincePaint+2) > -1 then begin
possibleLowBarsAgo = swingLowBar(1,L,2,barsSincePaint+2);
possibleLow = L[possibleLowBarsAgo];
end;
if possibleLow <= lowtoBeat then begin
lowBarsAgo = possibleLowBarsAgo;
lowtoBeat = possibleLow;
triggerPriceBuy = H[LowBarsAgo - 1];
end;
if C > triggerPriceBuy and
lowest(L,lowBarsAgo) > lowtoBeat then begin
//plotpb[lowBarsAgo](H[lowBarsAgo],L[lowBarsAgo],"");
trend = _UP;
barsSincePaint = lowBarsAgo-1;
possibleLow = 10000001;
lowtoBeat = 10000000;
hightoBeat = -1;
triggerPriceBuy = 10000000;
triggerPriceSell = -1;
lowBarsAgo = 1;
s_low = H[LowBarsAgo - 1];
theavg = average((( s_low + s_high) /2 ), len);
end;
end;
Plot3(theavg, "Avg" ) ;
barsSincePaint = barsSincePaint+1;
if trend = _UP then highBarsAgo = highBarsAgo + 1;
if trend = _DOWN then lowBarsAgo = lowBarsAgo + 1;
inputs:
len (4);
variables:
theavg(0),
highBarsAgo(1),
possibleHighBarsAgo(1),
possibleHigh(-2),
hightoBeat(-1),
barsSincePaint(1),
lowBarsAgo(1),
possibleLowBarsAgo(1),
possibleLow(10000001),
lowtoBeat(10000000),
triggerPriceSell(-1),
triggerPriceBuy(1000000),
trend(1),
_UP(1),
_DOWN(-1),
_ON(1),
_OFF(-1),
s_low(1),
s_high(1);
//***************************************************
//****** Find and plot the highest swing high *******
//***************************************************
if trend = _UP then begin
if swingHighBar(1,H,1,barsSincePaint+2) > -1 then begin
possibleHighBarsAgo = swingHighBar(1,H,1,barsSincePaint+2);
possibleHigh = H[possibleHighBarsAgo];
end;
if possibleHigh >= hightoBeat then begin
highBarsAgo = possibleHighBarsAgo;
hightoBeat = possibleHigh;
triggerPriceSell = L[HighBarsAgo - 1];
end;
if C < triggerPriceSell and
highest(high,highBarsAgo) < hightoBeat then begin
//plotpb[highBarsAgo](H[highBarsAgo],L[highBarsAgo],"");
trend = _DOWN;
barsSincePaint = highBarsAgo-1;
hightoBeat = -1;
lowtoBeat = 10000000;
triggerPriceBuy = 10000000;
triggerPriceSell = -1;
highBarsAgo = 1;
possibleHigh = -2;
s_high = L[HighBarsAgo - 1];
theavg = average((( s_low + s_high) /2 ), len);
end;
end;
//***************************************************
//****** Find and plot the lowest swing low *********
//***************************************************
if trend = _DOWN then begin
if swingLowBar(1,L,2,barsSincePaint+2) > -1 then begin
possibleLowBarsAgo = swingLowBar(1,L,2,barsSincePaint+2);
possibleLow = L[possibleLowBarsAgo];
end;
if possibleLow <= lowtoBeat then begin
lowBarsAgo = possibleLowBarsAgo;
lowtoBeat = possibleLow;
triggerPriceBuy = H[LowBarsAgo - 1];
end;
if C > triggerPriceBuy and
lowest(L,lowBarsAgo) > lowtoBeat then begin
//plotpb[lowBarsAgo](H[lowBarsAgo],L[lowBarsAgo],"");
trend = _UP;
barsSincePaint = lowBarsAgo-1;
possibleLow = 10000001;
lowtoBeat = 10000000;
hightoBeat = -1;
triggerPriceBuy = 10000000;
triggerPriceSell = -1;
lowBarsAgo = 1;
s_low = H[LowBarsAgo - 1];
theavg = average((( s_low + s_high) /2 ), len);
end;
end;
Plot3(theavg, "Avg" ) ;
barsSincePaint = barsSincePaint+1;
if trend = _UP then highBarsAgo = highBarsAgo + 1;
if trend = _DOWN then lowBarsAgo = lowBarsAgo + 1;