Welcome to the Traders Laboratory Forums.
TradeStation Custom Programming Discuss projects, ideas, obstacles in programming with TradeStation.

Reply
Old 12-25-2010, 05:24 PM   #1

Join Date: Aug 2010
Posts: 23
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Stop Trading Counter

hi guys,
using tradestation 8.8
I'm looking for a way to have my strategy stop trading for "x" amount of minutes after
"y" number of winning trades or
"z" number of loosing trades
thanks for your help!!
binthere
binthere is offline  
Reply With Quote
Old 12-27-2010, 09:15 AM   #2

Join Date: Mar 2009
Location: Chicago
Posts: 58
Ignore this user

Thanks: 6
Thanked 23 Times in 15 Posts

Re: Stop Trading Counter

Hi,

If you are using intraday time based charts, you can use the EasyLanguage reserved word BarInterval to count time in multiples of your chart inverval. You could also simply stop your stragegy for X bars. You can also access the PC clock to get the time that way.

There are reserved words for all the variables you mention in your question.

Best Regards,
Scott
ScottB is offline  
Reply With Quote
Old 12-27-2010, 09:20 AM   #3

Join Date: Apr 2009
Posts: 7
Ignore this user

Thanks: 0
Thanked 2 Times in 2 Posts

Re: Stop Trading Counter

How much experience do you have with EasyLanguage? You can use the PositionProfit function to count the losers and winners then when you reach the count use calctime to time it. Don't forget to re-set the count at the end of the day or session. If you like I can code it up for you (no charge) but if you are experienced then this info should answer your question. Glad to help if you want me to code it.

Randall
rkurzon is offline  
Reply With Quote
Old 12-27-2010, 04:20 PM   #4

Join Date: Aug 2010
Posts: 23
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: Stop Trading Counter

thank's for the response, i'm trying to do this baby steps, first making the strategy stop trading when a specific number of winners or loosers is hit but it seems it's not working
could someone look at the code and help me out to understand what i'm doing wrong?
thanks, binthere
Quote:
Input:
NumberWinningTrades( 111 ),
NumberLosingTrades ( 111 );

Vars:
WinTrades( 0 ),
LosTrades( 0 ),
tradeOn (true);

If time = 0 then
Wintrades = NumLosTrades ;
Lostrades = NumWinTrades ;

IF ( Wintrades >= NumberWinningTrades) or (LosTrades >= NumberLoosingTrades) then
tradeOn (false)
else
begin

//strategy entries

//strategy exits
binthere is offline  
Reply With Quote
Old 12-27-2010, 04:30 PM   #5

Join Date: Mar 2009
Location: Chicago
Posts: 58
Ignore this user

Thanks: 6
Thanked 23 Times in 15 Posts

Re: Stop Trading Counter

Hi,

If that is the actual code, you are missing Begin/End after If time = 0 but time isn't ever 0 (it the time at the end of the bar), so your initialization wouldn't ever happen. Use either the Once keyword or a bool variable like needInit and then once you have done your initialization set it equal false.

I also assume you are incrementing the winning/losing trade counters somewhere in your code.
ScottB is offline  
Reply With Quote
Old 12-27-2010, 05:07 PM   #6

Join Date: Aug 2010
Posts: 23
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: Stop Trading Counter

Randall
well this is the first time i actually code a strategy and have no prior developing experience, i've been strugling to make this hapen if you could help me out coding it would greatly appreciate it!!
every word i've used in the above code has taken me for ever to understand it and try to implement it
cheers!!, binthere
binthere is offline  
Reply With Quote
Old 12-27-2010, 08:04 PM   #7

Join Date: Apr 2009
Posts: 7
Ignore this user

Thanks: 0
Thanked 2 Times in 2 Posts

Re: Stop Trading Counter

There are many ways to do it but I slapped this together and it should do what you want.
Could probably be done a little neater but it does verify.

Input: NumberWinningTrades(111), NumberLosingTrades (111), TimeOutMin(15);

Vars: TradeOff(FALSE), StopTime(0), StartAgainTime(0), WinTrades(0), LoseTrades(0),
LCount(0), WCount(0);

LoseTrades = NumLosTrades;
WinTrades = NumWinTrades;

//reset win/lose and TradeOff here on start of new day or firstbar after maxbarsback
//I am resetting it on new day but you can reset with anything, session time, another calctime, etc., etc.
if currentbar = 1 or date <> date[1] then begin
TradeOff = FALSE;
WCount = 0;
LCount = 0;
end;

//track win/lose trade count
if LoseTrades > LoseTrades[1] then LCount = LCount +1;
if WinTrades > WinTrades[1] then WCount = WCount +1;

//set TradeOff to TRUE and StopTime to time when win/lose trades was exceeded
if (WCount >= NumberWinningTrades) or (LCount >= NumberLosingTrades) then begin
TradeOff = TRUE;
StopTime = time;
end;

//calculate time to start again (add TimeOutMin to StopTime)
StartAgainTime = calctime(StopTime, TimeOutMin);

//reset TradeOff to FALSE after TimeOutMin to allow trading again on the same day
//reset trade counters to zero also
if TradeOff = TRUE and time > StartAgainTime then begin
TradeOff = FALSE;
WCount = 0;
LCount = 0;
end;

//allow entries
if TradeOff = FALSE then begin

//strategy entries

end;
rkurzon is offline  
Reply With Quote
The Following User Says Thank You to rkurzon For This Useful Post:
binthere (12-27-2010)
Old 12-27-2010, 11:42 PM   #8

Join Date: Aug 2010
Posts: 23
Ignore this user

Thanks: 1
Thanked 0 Times in 0 Posts

Re: Stop Trading Counter

Randall, this is HUGE!!!!
thanks for your help!, i've been strugling for over a week to get to the code i had posted earlier... and to get to the code you did it would have taken me a gazillion years in a very frustrating journey.
i can't thank you enough for your help
cheers,, keep it spinning!
binthere
binthere is offline  
Reply With Quote

Reply

Tags
counter, stop

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
Trading with Market Statistics VI. Scaling In and Risk Tolerance jperl Market Profile 127 10-18-2011 08:07 PM
CouldaWouldaShoulda (The Wyckoff Forum) DbPhoenix The Wyckoff Forum 59 11-02-2009 11:51 AM
Educational Trading Programs kevinfeeder Beginners Forum 47 09-13-2007 09:33 AM
Trading Pyschology and Opening Gap with Leroy Rushing Soultrader Chat Room Scripts 2 02-11-2007 01:05 PM
Three Pervasive Myths in the Trading World Brett N. Steenbarger Trading Articles 9 01-02-2007 12:48 AM

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