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.

binthere

Stop Trading Counter

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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;

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Well, binthere got back to me and said the code would not start trading again after the time out. That's what I get for not testing my code :crap:. Below it is fixed and tested :-). It will reset on a change in date or exceeding the win/loss amount and will not trade for the time out period after that change. There are other ways to reset it, such as session end, session start, a specific time, etc., etc.

 

I have included the code here as a simple system that buys on one bar and exits on the next. I have also included the code (at bottom of system code) I use for de-bugging with the expert commentary. Just set the "Comm" input to true and using the expert commentary you can click anywhere on the chart to see the values at the close of that bar. Many people may also use a print statement for de-bugging but I personally prefer to use the commentary.

 

All of this goes to show something that I learned a long time ago but foolishly failed to implement here- always, always check your code to make sure it is doing what you think. More often than not code looks great and might do what you think part of the time but check, re-check, and re-check again. I hate to imagine how many great ideas have been discarded because they were coded wrong and failed.

 

I apologize for the error. ELD attached, coded in TS 8.6

 

 

Input: NumberWinningTrades(5), NumberLosingTrades (5), TimeOutMin(5), Comm(FALSE);

 

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

LCount(0), WCount(0), MP(0);

 

LoseTrades = NumLosTrades;

WinTrades = NumWinTrades;

MP = marketposition;

 

 

//reset all on date change or first bar

//you could reset here for whatever you choose

if currentbar = 1 or date <> date[1] then begin

StopTime = time;

StartAgainTime = calctime(StopTime, TimeOutMin);

TradeOff = TRUE;

WCount = 0;

LCount = 0;

end;

 

//track win/lose trade count (note reset above and date = date[1])

//will not carry count over after date change- easy to change this

if date = date[1] then begin

if LoseTrades > LoseTrades[1] then LCount = LCount +1;

if WinTrades > WinTrades[1] then WCount = WCount +1;

end;

 

//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;

//calculate time to start again (add TimeOutMin to StopTime)

StartAgainTime = calctime(StopTime, TimeOutMin);

WCount = 0;

LCount = 0;

end;

 

//reset TradeOff

if TradeOff = TRUE and time >= StartAgainTime then TradeOff = FALSE;

 

//allow entries

if TradeOff = FALSE then begin

 

if MP = 0 then buy next bar at market;

 

end;

 

if MP = +1 then sell next bar at market;

 

 

//beging expert commentary code used for debugging

if Comm then begin

 

Vars: Str0(""),

Str1(""),

Str2(""),

Str3(""),

Str4(""),

String1("");

 

#BeginCmtryOrAlert

if CommentaryEnabled and AtCommentaryBar then begin

 

if TradeOff = TRUE then Str0 = "TRUE" else

Str0 = "FALSE";

 

String1 =

newline +

newline + " TimedTrades_Sys " +

newline +

newline + " Date = " + NumToStr(Date, 0) +

newline + " Time = " + NumToStr(Time, 0) +

newline + " Open = " + NumToStr(Open, 4) +

newline + " Close = " + NumToStr(Close, 4) +

newline + " High = " + NumToStr(High, 4) +

newline + " Low = " + NumToStr(Low, 4) +

newline +

newline + " MP = " + NumToStr(MP, 0) +

newline + " TradeOff = " + Str0 +

newline + " StopTime = " + NumToStr(StopTime, 0) +

newline + " StartAgainTime = " + NumToStr(StartAgainTime, 0) +

newline + " LoseTrades = " + NumToStr(LoseTrades, 2) +

newline + " WinTrades = " + NumToStr(WinTrades, 2) +

newline + " WCount = " + NumToStr(WCount, 2) +

newline + " LCount = " + NumToStr(LCount, 2) +

newline +

newline;

Commentary(String1);

end;

#end;

end;// comm end

TIMEDTRADES.ELD

Share this post


Link to post
Share on other sites

You are very welcome. I received a lot of help from a lot of people over the years and very honestly continue to receive help. This is one of the toughest professions in the world and at very least it could become just a little easier if we help one another. Feel free to ask anytime.

 

Regards, Randall

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.


  • Topics

  • Posts

    • Date : 25th November 2021. Market Update – November 25 – Solid US data lifts USD, Stocks, & Yields. USD (USDIndex 96.70) holds on at 16-mth highs; Strong set of US data yesterday GDP (2.1%) up a tick but missed by a tick, Claims (199k) at 52-yr low, PCE (0.4% m/m & 4.1% y/y), in-line & largest since Jan.1991, along with a big beat (5.9%) for GDP Price index, Durable Goods (0.5%) in-line, Personal Spending (1.3%) a big beat, Personal Income (0.5%) a beat, Trade balance a big beat (14.6%) on strong Exports, Inventories (-2.2%) a big miss, but shows demand is strong. Consumer Sentiment a beat and New Home Sales flat (745K) and missed. Stocks & Yields pushed higher, Oil held onto gains and Gold tested 3-week lows.   The FOMC Minutes showed (1) there could be a faster taper than the $15bn/mth currently planned, (2) Inflation could indeed be “persistent” (3) Clear division over 2022/23 rate hike cycle, Doves hold sway for now. US Yields 10yr trades at 1.644%, down from yesterday’s 1.694% high. Equities – Gains into the Holiday USA500 +10.76 (0.23%) at 4701 – USA500.F trades higher at 4713. USOil – peaked at $78.53 Inventories +1.0 vs -1.7 weakened prices – now at $77.65 Gold found a floor at 1782, but struggles to recoup $1800 at $1790. FX markets – EURUSD now 1.1216, having broken 1.1200, USDJPY now 115.36, from 115.50 & Cable back to 1.3350 from 1.3315 yesterday. Overnight – JPY PPI (1.0%) hit a 10-yr high, German GDP and consumer confidence both missed (1.7% vs 1.8% and -1.6% vs -1.0%) respectively. European Open – December 10-yr Bund future up 16 ticks, while US futures are slightly in the red. Bunds already outperformed yesterday, as EZ spreads widened in the wake of hawkish leaning ECB comments & confirmation that German finance ministry will go to the liberal FDP, which likely means more resistance to debt mutualisation across the EZ & more pressure on ECB to limit asset purchases. DAX & FTSE 100 futures are currently up 0.4% & 0.3% respectively & US futures are posting gains of 0.3-0.4%, suggesting markets are coping quite well with the prospect of less accommodative policies. Indeed, it seems to an extent that they welcome the CB’s acknowledgement that inflation risks could be less temporary than previously thought. Today – ECB Minutes, ECB’s Elderson, Schnabel, Lagarde and BOE’s Bailey Biggest FX Mover @ (07:30 GMT) CADJPY (0.20%) The rally from Tuesday’s low under 90.00 has been sustained with 91.25 being tested earlier today. MAs aligned higher, MACD signal line & histogram rising & over 0 line, RSI 61, H1 ATR 0.077, Daily ATR 0.707. Always trade with strict risk management. Your capital is the single most important aspect of your trading business. Please note that times displayed based on local time zone and are from time of writing this report. Click HERE to access the full HotForex Economic calendar. Want to learn to trade and analyse the markets? Join our webinars and get analysis and trading ideas combined with better understanding on how markets work. Click HERE to register for FREE! Click HERE to READ more Market news. Stuart Cowell Head Market Analyst HotForex Disclaimer: This material is provided as a general marketing communication for information purposes only and does not constitute an independent investment research. Nothing in this communication contains, or should be considered as containing, an investment advice or an investment recommendation or a solicitation for the purpose of buying or selling of any financial instrument. All information provided is gathered from reputable sources and any information containing an indication of past performance is not a guarantee or reliable indicator of future performance. Users acknowledge that any investment in FX and CFDs products is characterized by a certain degree of uncertainty and that any investment of this nature involves a high level of risk for which the users are solely responsible and liable. We assume no liability for any loss arising from any investment made based on the information provided in this communication. This communication must not be reproduced or further distributed without our prior written permission.
    • Date : 24th November 2021. Market Update – November 24 – USD & Yields Higher, Stocks Mixed, Oil Recovers. Trading Leveraged Products is risky USD (USDIndex 96.50) holds on at highs; EM currencies under particular pressure. (TRY lost 15% after Erdogan refused a rate rise). RBNZ raised rates but NZD fell (like the last time they raised rates!) JPY Inflation 2 ticks better than expected. USDJPY at January 2017 levels around 115.00. PMI data better across the globe, Stocks mixed in US & Asia, Yields bid, Oil recovered significantly and Gold pressured by yields. Biden invites Taiwan to its “Summit for Democracy”, WHO talks of additional 700k Covid deaths across Europe (Slovakia latest to talk lockdowns). US Yields 10yr trades at 1.667%, down from yesterday’s 1.684% high. Equities Mixed. Musk sold more stock, Banks & Oil majors lead. USA500 +7.76 (0.17%) at 4690 – USA500.F trades lower at 4684. USOil – rallied over 3% to $78.20 highs despite global strategic reserves being sold to cool prices. Gold found a floor at 1782, but struggles to recoup $1800 at $1790. FX markets – EURUSD down to 1.1245, USDJPY over 115.23, earlier now at 114.88 & Cable back to 1.3375. European Open – December 10-yr Bund future up 26 ticks, US futures also broadly higher. RBNZ delivered expected rate hike & markets seem to be scaling back fears of escalating inflation as even dovish leaning BoE & ECB members highlight risk of second round effects. ECB VP Guindos highlighted overnight that the drivers of inflation are becoming more structural, which adds to signals that the CB is finally ready to start reining in stimulus. DAX & FTSE 100 futures currently up 0.3% & 0.2% respectively. Today – Big data day ahead of Thanksgiving Weekend. – German Ifo, US Weekly Claims GDP, PCE, Durables, FOMC Mins. & ECB speak Biggest FX Mover @ (07:30 GMT) NZDJPY (-0.77%) RBNZ in-line but Dovish, sank from breach of 80.00 yesterday to 79.24, and 79.40 now. Faster MAs aligned lower, MACD signal line & histogram falling & below 0 line, RSI 35 & weak, Stochs OS. H1 ATR 0.17, Daily ATR 0.70. Please note that times displayed based on local time zone and are from time of writing this report. Click HERE to access the full HotForex Economic calendar. Want to learn to trade and analyse the markets? Join our webinars and get analysis and trading ideas combined with better understanding on how markets work. Click HERE to register for FREE! Click HERE to READ more Market news. Stuart Cowell Head Market Analyst HotForex Disclaimer: This material is provided as a general marketing communication for information purposes only and does not constitute an independent investment research. Nothing in this communication contains, or should be considered as containing, an investment advice or an investment recommendation or a solicitation for the purpose of buying or selling of any financial instrument. All information provided is gathered from reputable sources and any information containing an indication of past performance is not a guarantee or reliable indicator of future performance. Users acknowledge that any investment in FX and CFDs products is characterized by a certain degree of uncertainty and that any investment of this nature involves a high level of risk for which the users are solely responsible and liable. We assume no liability for any loss arising from any investment made based on the information provided in this communication. This communication must not be reproduced or further distributed without our prior written permission.
    • EURUSD HOVERS NEAR MULTI-MONTH LOW, UNDER 1.1250 LEVEL   EURUSD Price Analysis – November 24 Throughout the session, the EURUSD pair remained on the losing side and was last seen moving with considerable losses around the 1.1250-36 level. The announcement that the White House has opted to reappoint incumbent Fed Chair Jerome Powell for a second term sparked the recent strong dip. The spot is trading at 1.1253 at the time of writing, down 0.25 percent on the day. Key Levels Resistance Levels: 1.1525, 1.1422, 1.1300 Support Levels: 1.1200, 1. 1150, 1.1100 EURUSD Long term Trend: Bearish EURUSD has sunk to fresh multi-day lows, as seen on the daily chart, after extending the recent breach beneath the moving averages 5 around the 1.1300 level. This exposes the possibility of a deeper pullback and a re-test of the psychological support around 1.1200. Under the 1.1200 level, the euro’s underlying bullish attitude is in jeopardy. Overall, the EURUSD stays bearish while trading under the major horizontal support turned resistance and significant level at 1.1422. A breakout of the 1.1300 level, on the other hand, would aim for the 1.1350 level on the way to the 1.1400 zones. The fall of the 1.1200 zones, in the alternative scenario, is viewed as a bearish continuation indicator. EURUSD Short term Trend: Bearish The risk is weighted to the negative on the 4-hour chart, as the pair is developing below the firmly bearish 5 and 13 moving averages. Technical indicators have shifted to the downside, with negative levels. However, in the present scenario, the RSI has not yet reached oversold territory, allowing for more selling. On the upside, a break over the modest resistance level of 1.1300 might shift the intraday bias to neutral. On the downside, the 1.1200 zones provide initial support. The next important level of support is around the 1.1150 mark. If there are any more losses, the 1.1100 extension level of the low decline may be tested. Source: https://learn2.trade 
    • IS IT RATIONAL TO SETTLE FOR 10% RETURNS PER MONTH? “One of the secrets few know and fewer implement when it comes to trading success is that you have to really care about doing well. These days, I see a lot of traders not caring enough, not prioritizing learning about trading, and making pathetic weak-willed excuses.” – Chris T. Perfectionism – a bane of the trading world When people look for a solution to their trading problems, they tend to look for the solution in the wrong places, having the wrong mindset. One problem with most traders is perfectionism. For instance, we tend to go to those who promise us 50% to 100% per week or month. If someone gives an estimate of 5% profits per month, we would think that is too small. If an investment salesperson promises huge returns in a short period of time, we’re drawn to them. What if I tell you that 5% per month is good returns on your trading or investment, would you agree with me? Is 60% growth per annum not good enough? Many years ago, one of my mentors in the financial industry told me that, even 20% growth per annum is good. In schools, we tend to ridicule those who make average grades and praise those who make excellent grades. The same is true of the world of sports. Do you think great sports teams win all their matches always? No! But they do well over time. Are 10% gains per month too low? Now let me ask these questions: How much percentage do you earn on your savings account per annum? How much do you earn on your fixed deposit account per month? How many people can pay off their mortgages within one year? If you buy a bus, to use for commercial purposes, is it easy for you to recover your money in one year? Can you buy a property and sell it for 100% profit within 10 months? If you found a startup, how long do you think it would take you to start making profits? Please attempt to answer these questions yourself, based on real-life experiences. Now, back to the question that makes the last subheading: Are 10% gains per month too low? Why do we tend to be unrealistic and fallacious when it comes to online trading? Making 10% returns per month from Learn2.trade crypto signals One good thing about the margin trading of cryptos is that you can make money, both in bull and bear markets. You don’t make money only when the price is going up. If your timing and methodology are right, you can predict a downward movement or an upward movement and participate in them. Learn2.trade provides quality crypto signals to interested traders. Each signal comes with stop loss and take profit targets. Sometimes a trade is closed before the stop or the target is hit. We use 5 types of orders for the crypto signals. They are Instant Execution, also known as Market Execution, Buy Limit, Sell Limit, Buy Stop, and Sell Stop. Generating an average of 2 – 3 signals per day, we also use risk settings that are usually around 1% per trade and we attempt to gain more than we risk. As these signals are sent, we ensure that we also use them, practicing what we preach. Learn2.trade crypto signals – recent performances Please check the image below to peruse what has been made recently. You see can that we use stop loss, and use small lot sizes, relative to the size of the accounts. It just doesn’t make sense to bet too big on an individual trade. You can also see that we have both losses and profits. However, our average profits are bigger than average losses. That is the pedigree of a viable/ promising strategy: Make more money than you lose. Therefore, losses and drawdowns are also tightly controlled so that they don’t have significant effects on the account. These kinds of drawdowns are shallow, for recovery and eventual growth always happen. The markets are difficult but profitable Making consistent, regular profits from the market is hard, but success is possible. When the markets prove difficult, then we only need creative approaches. Markets will continue to prove uneasy and tough, but we will continue to make profits from them, no matter what. We target 10% profits per month, though we make more than this in most cases. 100% profits every 10 months is an enviable achievement. If 10% gains per month are compounded, the results in a few to several years will be amazing. Yes, you should be aware of the power of compounding. Join us today, in this journey of regular, monthly profits. Please see the image above, to know relevant metrics and figures of the recent results of the strategy behind the signals. You can join us here for, few free crypto signals per week: For Cryptos. Or you can hop in, and become our VIP right away, and enjoy all our crypto signals, up to 3 signals per day. Get access to the ability to make 10% or more per month. You can monitor our crypto signals trading performances here: L2T Crypto Signals on MyFxbook   Source: https://learn2.trade   
    • Yes trading currencies is much more risky than trading stocks, since they're not supported by central bank policy efforts but instead freely fluctuation in a very random fashion. Profits can create wrong impression that you learned how to trade but often it is just the product of pure luck. 
×
×
  • Create New...

Important Information

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