Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

daedalus

Storing a Pivot Level in .eld?

Recommended Posts

I'm trying to store a prior scalper swing high or low in an indicator so I can reference the swing high or low to check the bar that breaks through that level for a candlestick pattern.

 

But i'm a little bit stumped because in a show me indicator its only comparing the current bar... and without knowing how far back the prior H/L was I can't code up a comparison if/then statement.

 

Any ideas on how to form this?

 

attachment.php?attachmentid=12402&stc=1&d=1248373064

 

The baseline scalper code is as follows:

{Scalper Buys and Sells		7/18/2007
Written by Luis Gomez 
inspired by John Carters "Mastering the Trade"
This plots swing highs/lows with a strength of 2 bars on each side, on the condition that there is a
	close above/below the high/low the bar after the said swing bar......whew that's a mouthful!
}

inputs:
buyColor(magenta),
sellColor(cyan);
variables:
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);


//***************************************************
//****** Find and plot the highest swing high *******
//***************************************************

if trend = _UP then begin
if swingHighBar(1,H,2,barsSincePaint+2) > -1 then begin
	possibleHighBarsAgo = swingHighBar(1,H,2,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
	plot1[highBarsAgo](H[highBarsAgo],"",sellColor);
	alert("Scalper Sell");
	trend = _DOWN;
	barsSincePaint = highBarsAgo-1;
	hightoBeat = -1;
	lowtoBeat = 10000000;
	triggerPriceBuy = 10000000;
	triggerPriceSell = -1;
	highBarsAgo = 1;
	possibleHigh = -2;
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
	plot1[lowBarsAgo](L[lowBarsAgo],"",buyColor);
	alert("Scalper Buy");
	trend = _UP;
	barsSincePaint = lowBarsAgo-1;
	possibleLow = 10000001;
	lowtoBeat = 10000000;
	hightoBeat = -1;
	triggerPriceBuy = 10000000;
	triggerPriceSell = -1;
	lowBarsAgo = 1;
end;		

end;

barsSincePaint = barsSincePaint+1;
if trend = _UP then highBarsAgo = highBarsAgo + 1;
if trend = _DOWN then lowBarsAgo = lowBarsAgo + 1;

 

Thanks for your input and advice!!!

1.jpg.30436764a218e073497093b4a9bdfd5e.jpg

Share this post


Link to post
Share on other sites

you can set up a variable, say call it myswinghigh(0).

 

when a swing high occurs, do an assignment to store the swing high value:

 

myswinghigh = h;

 

 

The high will change with every bar, but this "swinghigh" value will remain constant in the variable, thus allowing you to reference it later.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.