| TradeStation Custom Programming Discuss projects, ideas, obstacles in programming with TradeStation. |
![]() | | Tweet | |
| | #1 | ||
![]() | Stop Trading Counter 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 | ||
| |
|
| | #2 | ||
![]() | Re: Stop Trading Counter 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 | ||
| |
|
| | #3 | ||
![]() | Re: Stop Trading Counter Randall | ||
| |
|
| | #4 | ||
![]() | Re: Stop Trading Counter could someone look at the code and help me out to understand what i'm doing wrong? thanks, binthere Quote:
| ||
| |
|
| | #5 | ||
![]() | Re: Stop Trading Counter 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. | ||
| |
|
| | #6 | ||
![]() | Re: Stop Trading Counter 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 | ||
| |
|
| | #7 | ||
![]() | Re: Stop Trading Counter 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; | ||
| |
|
| The Following User Says Thank You to rkurzon For This Useful Post: | ||
binthere (12-27-2010) | ||
| | #8 | ||
![]() | Re: Stop Trading Counter 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 | ||
| |
|
![]() |
| Tags |
| counter, stop |
| Thread Tools | |
| Display Modes | 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 |