| Automated Trading Black box systems, strategy automation, algorithmic trading, etc... |
![]() | | Tweet | |
| | #1 | ||
![]() | Can't Follow the Code, Please Help.... 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; | ||
| |
|
| | #2 | ||
![]() | Re: Can't Follow the Code, Please Help.... Paul | ||
| |
|
| | #3 | ||
![]() | Re: Can't Follow the Code, Please Help.... | ||
| |
|
| | #4 | ||
![]() | Re: Can't Follow the Code, Please Help.... Quote:
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.
__________________ Only an idiot would reply to a stupid post | ||
| |
|
| The Following User Says Thank You to Tams For This Useful Post: | ||
feng2088 (02-05-2011) | ||
| | #5 | ||
![]() | Re: Can't Follow the Code, Please Help.... 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. | ||
| |
|
| The Following User Says Thank You to TraderWill For This Useful Post: | ||
feng2088 (02-05-2011) | ||
| | #6 | ||
![]() | Re: Can't Follow the Code, Please Help.... 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. | ||
| |
|
| The Following User Says Thank You to mushin2003 For This Useful Post: | ||
feng2088 (02-05-2011) | ||
| | #7 | ||
![]() | Re: Can't Follow the Code, Please Help.... | ||
| |
|
| | #8 | ||
![]() | Re: Can't Follow the Code, Please Help.... , 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; | ||
| |
|
![]() |
| Thread Tools | |
| Display Modes | Help Others By Rating This Thread |
| |
| ∧ Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Does Anyone Use a Smartphone to Follow the Markets and the News... | HighStakes | Tools of the Trade | 11 | 05-27-2011 12:16 PM |
| ADE Code | karsat | Coding Forum | 0 | 03-08-2009 08:06 PM |
| P&F Code | point-figure | Coding Forum | 0 | 02-17-2009 06:24 AM |
| Follow The Smart $$: Let Candles & Volume Guide The Way | brownsfan019 | The Candlestick Corner | 16 | 01-13-2009 10:27 PM |
| Hey Guys, just follow the smart money ¡¡ | walterw | General Discussion | 2 | 03-22-2007 07:54 PM |