Welcome to the Traders Laboratory.

Automated Trading Black box systems, strategy automation, algorithmic trading, etc...

Reply
Old 02-03-2011, 08:41 PM   #1

Join Date: Mar 2009
Posts: 34
Ignore this user

Thanks: 20
Thanked 1 Time in 1 Post

Can't Follow the Code, Please Help....

Hello , I am trying to understand these codes line by line. I spent 2 hrs try to figure out what each line does, obviously I couldn't figure out. Can someone please put comment next to each line and help me understand? I know it's a lot, but I really appreciate your help. Thanks much!


Code:
{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(white),
	sellColor(yellow);
	
	
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);
	
	

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);
		Sell next bar at market;
		
        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;
feng2088 is offline  
Reply With Quote
Old 02-04-2011, 06:57 AM   #2

Trader333's Avatar

Join Date: May 2008
Location: UK
Posts: 152
Ignore this user

Thanks: 79
Thanked 24 Times in 20 Posts

Re: Can't Follow the Code, Please Help....

Do you have any understanding of coding ?


Paul
Trader333 is offline  
Reply With Quote
Old 02-04-2011, 11:12 AM   #3

Join Date: Mar 2009
Posts: 34
Ignore this user

Thanks: 20
Thanked 1 Time in 1 Post

Re: Can't Follow the Code, Please Help....

Yes, I do, but not too much. I don't understand how these variable are defined. I need someone to help me get started. If you can help me understand the first half of the codes, I would really appreciate it.
feng2088 is offline  
Reply With Quote
Old 02-04-2011, 11:55 AM   #4

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 4,056
Ignore this user

Thanks: 2,273
Thanked 1,648 Times in 1,007 Posts

Re: Can't Follow the Code, Please Help....

Quote:
Originally Posted by feng2088 »
Yes, I do, but not too much. I don't understand how these variable are defined. I need someone to help me get started. If you can help me understand the first half of the codes, I would really appreciate it.
you have to be more specific...

if you have problem with a section, let us know what you understood, and what you didn't.
a blanket question will get a blank stare in return. Nobody is going to spoon feed you.
__________________
Arguing with a troll is a lot like wrestling in the mud with a pig, after a couple of hours you realize the pig likes it.
Tams is offline  
Reply With Quote
The Following User Says Thank You to Tams For This Useful Post:
feng2088 (02-05-2011)
Old 02-05-2011, 12:20 AM   #5

Join Date: May 2010
Posts: 31
Ignore this user

Thanks: 0
Thanked 20 Times in 14 Posts

Re: Can't Follow the Code, Please Help....

Hi Feng,

If you have specific questions about the code it'd be easier to answer, as the previous posts state. This appears to be tradestation code and if you have that charting platform you could just run it and see what it does. I think it looks for lower highs to indicate that an uptrend is over and a downtrend beginning and then gives a setup to go short the market. And conversely looks for higher lows to indicate the end of a downtrend and beginning of a reversal. The variables are used to store values calculated by and used in the code. The numbers next to the variables are default values to initialize the code but will be changed as the code is executed on each price bar.

Not sure if this helps, if you can narrow down your question it may be easier to answer.

tradestation by the way has extensive documentation about coding in their help file and in the help file reference section there's a link to downloaded their coding tutorial pdf document. You should download it and go through it as it does a great job of teaching how to program in their platform. It explains the use of inputs, variables, logic structures, etc. Some of the commands in the code are actually programmed functions and if you look their name up in the tradestation help you'll find an explanation of what they do and how to use them.

Good luck in your studies.
TraderWill is offline  
Reply With Quote
The Following User Says Thank You to TraderWill For This Useful Post:
feng2088 (02-05-2011)
Old 02-05-2011, 09:55 AM   #6

Join Date: Feb 2010
Location: austin
Posts: 7
Ignore this user

Thanks: 2
Thanked 1 Time in 1 Post

Re: Can't Follow the Code, Please Help....

Hey Feng,
A few things to get you started. First either read Carter's book or google for "swing high" this is the chart pattern the code is checking for. Next, this is Easy Language from tradestation and they do provide a lot of online documentation. This code is rather trival to understand after about 1-2 hours of studying just basic EL. If you have a desire to trade then it is best to spend the time learning what tools you have availble.
mushin2003 is offline  
Reply With Quote
The Following User Says Thank You to mushin2003 For This Useful Post:
feng2088 (02-05-2011)
Old 02-05-2011, 02:21 PM   #7

Join Date: Dec 2010
Posts: 20
Ignore this user

Thanks: 0
Thanked 12 Times in 6 Posts

Re: Can't Follow the Code, Please Help....

After reviewing the code, I seriously doubt it is worth the trouble to decipher it in detail. Besides being poorly documented, it doesn't appear to have much potential for consistant profit. The difference between 'can work' and 'does work' is reliability. The reason this code if free is because that is what it is worth. Move on to something better. As a stand alone indicator this code will never increase your account balance by the end of the month.
jdevron is offline  
Reply With Quote
Old 02-05-2011, 10:58 PM   #8

Join Date: Mar 2009
Posts: 34
Ignore this user

Thanks: 20
Thanked 1 Time in 1 Post

Re: Can't Follow the Code, Please Help....

Thank you all for your advice. I downloaded the EasyLanguage Essentials and read some pages of it. I put some comment on a few lines but not sure if I understand the codes correctly. Can your guys please take a look? For the ones that have ?? at the end , can you please shred some lights? Thank you for your time and help. Enjoy your weekend.


Code:
if trend = _UP then begin
	if swingHighBar(1,H,2,barsSincePaint+2) > -1 then begin  //  if this is true then 
		possibleHighBarsAgo = swingHighBar(1,H,2,barsSincePaint+2); // possibleHighBarsAgo changed from 1 to 2
		possibleHigh = H[possibleHighBarsAgo]; // possibleHigh changed from -2 to H[2] ???? (No sure)
	end;

	if possibleHigh >= hightoBeat then begin  //if possibleHigh is true then begin??? (No Sure)
		highBarsAgo = possibleHighBarsAgo;    // highBarsAgo = 2
		hightoBeat = possibleHigh;            //hightoBeat = H[2]
		triggerPriceSell = L[HighBarsAgo - 1]; //triggerPirceSell = L[2-1]= L[1]
	end;
	
	if C < triggerPriceSell and highest(high,highBarsAgo) < hightoBeat then begin //highest(high,2) < h[2]
		plot1[highBarsAgo](H[highBarsAgo],"",sellColor);
        alert("Scalper Sell");
		trend = _DOWN;
		barsSincePaint = highBarsAgo-1; // barsSincePaint= 1
		hightoBeat = -1;
		lowtoBeat = 10000000;
		triggerPriceBuy = 10000000;
		triggerPriceSell = -1;
		highBarsAgo = 1;
		possibleHigh = -2;
	end;
Attached Thumbnails
Can't Follow the Code, Please Help....-chart.jpg  
feng2088 is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:

Similar Threads
Thread Thread Starter Forum Replies Last Post
ADE Code karsat Coding Forum 1 06-25-2013 03:28 AM
Does Anyone Use a Smartphone to Follow the Markets and the News... HighStakes Tools of the Trade 11 05-27-2011 01:16 PM
P&F Code point-figure Coding Forum 0 02-17-2009 07:24 AM
Follow The Smart $$: Let Candles & Volume Guide The Way brownsfan019 The Candlestick Corner 16 01-13-2009 11:27 PM
Hey Guys, just follow the smart money ¡¡ walterw General Discussion 2 03-22-2007 08:54 PM

All times are GMT -4. The time now is 08:05 PM.
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
2006-2011 Traders Laboratory, All Rights Reserved.