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.

einja

Run the Strategy Only Once in Tradestation

Recommended Posts

hi everyone,

 

i am new to this Tradestation and EasyLanguage scripting.

 

i am looking for a simple script that places an order once and maybe close it at a certain price. closing is not crucial.

 

Ex. if EURUSD is trading at 1.3356, and the trend is downwards, i want to pass the parameter 1.334 and the order for sell short should be executed. once its executed, the script should become non operational otherwise, it will keep shorting since the condition, if Price <= 1.334 will be triggered many times.

 

thanks for the people who are reading this and trying to help people like me who are beginners.

Share this post


Link to post
Share on other sites

Try something like:

 

If marketposition=0 then
sellshort next bar at 1.334;

 

When you have an existing short position then marketposition=-1 and when you have an open long position then marketposition=1. This is regardless of the number of shares/contracts you hold. When you are flat market position=0.

 

Note that both this method and UrmaBlume's will permit a new position to be initiated if the prior position has been exited and then price trades back down to 1.334.

 

You may want to limit yourself to one entry per day at this level, in which case your code might look like this:

 

If entriestoday=0 then
sellshort next bar at 1.334;

 

There is no need to state a condition for marketposition because if there have been no entries you must already be flat (unless you're holding positions overnight). If you allow a specified number of positions each day - say four - then you'd need:

 

If marketposition=0 and entriestoday=4 then
sellshort next bar at 1.334;

 

I see no reason for the "begin . . . end" loop in Urma's code, a specific price would normally be specified, and "this bar" can be used instead of "at market", so this could be edited to something like:

 

If current shares=0 and close<=1.334 then 
buy this bar;

 

Most likely the difference may be because Urma is using the MultiCharts version of EasyLanguage.

 

Hope that helps.

 

Kind regards,

 

BlueHorseshoe

Share this post


Link to post
Share on other sites

UrmaBlume and BlueHorse,

 

Your guys are amazing. Thank you and i read your replies before too on other posts. Keep up the good work.

 

This is what i was looking for. I see a trend on the chart and it could be a 3rd run or 15th run in that day. once i jump in, it needs to execute once and then get out.

 

This is the psuedo code.

 

1. see the chart pattern (eyeballing and manual).

2. Execute the strategy:

{

Short Sell at specific price.

After some time buy back the same stock

} >> This brasis code should be run once and the strategy should be exited or dys-functional.

Share this post


Link to post
Share on other sites

I think you already have your answer above, don't you?

 

Not sure why you even need an automated strategy for this though - why not just place a resting order at the price level you want, as it sounds like you're going to be around to watch the whole process unfold?

 

BlueHorseshoe

Share this post


Link to post
Share on other sites

i have a long position.

 

i get "not Executed 0.00" printed in the output window.

 

marketposition does not return 1 when i have a long position.

 

 

if MarketPosition = 1 then

BEGIN

Sell All Contracts Next Bar At Market;

 

Print( "yes Executed" );

END

Else

BEGIN

Print( "not Executed", marketposition );

END

Share this post


Link to post
Share on other sites

i am using a simulated account of tradestation.

 

do u know if i can place orders in sim. acct using the code u sent. nothing happens when i run the strategy. i am wondering if the script can be used for just back testing or can we use it for placing orders real time also.

Share this post


Link to post
Share on other sites

You can use place orders in SIM, but only for instruments of the same type as the account. In other words, if you have a TS Forex account, you can't live SIM trade a futures contract. This is because the data-feed is not live, and you're getting delayed data. There is no way around this (TS will not allow you a live Futures feed to a Forex or Securities account, as far as I am aware).

 

Does this sound applicable?

 

Regards,

 

BlueHorseshoe

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

    • I trust my broker but not the market 😃
    • Cheap or expensive doesn't matter, good or not does matter.
    • Anyone has a video of PSG with HotForex sponsor logo ? I really want to watch it.
    • Metro Line2 Vaccines: Worldwide already literally thousands dropping dead within hours of taking the vaccines?  What ever happened to “if we can save just one life”? Lockdowns: Listen to the scientists. Unless, of course, the scientists are anti-lockdown. This study, https://onlinelibrary.wiley.com/doi/10.1111/eci.13484 ,  compared less restrictive countries like Sweden and South Korea, to countries which issued strict lockdowns, like England, France, Germany, Iran, and Italy.   It found “no clear, significant beneficial effect” in using strict lockdowns to control the spread of COVID. In fact in some cases, such as France, COVID cases increased in the wake of strict interventions... hello - because at home is where the vast majority of people ‘catch’ the virus...  Looks like governments destroyed your civil liberties and businesses for no reason, since the study concluded: “Similar reductions in case growth may be achievable with less restrictive interventions.”   ... and you are fine with that?   ...   Washington Metro Red Line A fun parable https://blog.nomorefakenews.com/2021/01/22/how-is-joe-biden-like-a-ham-sandwich/ warning:  the store owner sounds a little bit jewish
    • Date : 25th January 2021. Events to Look Out for This Week. A gigantic week is coming with 2 of the FAANGs, Tesla and Microsoft, reporting their Q4 earnings, along with the FOMC conference in focus as it could provide key information on fiscal support talks. Focus will also be on GDP data from the biggest economies in the world, including the US and Europe, but also on UK Job numbers that will show the impact of the original furlough deadline. Monday – 25 January 2021 German IFO (EUR, GMT 09:00) – German IFO business confidence is expected to slip slightly to 90.0 in January after the jump seen in December to 92.1. BoJ Monetary Policy Meeting Minutes (JPY, GMT 23:50) – The BoJ minutes should provide further guidance for 2021. Tuesday – 26 January 2021 Average Earnings Index & ILO rate (GBP, GMT 07:00) – UK Earnings with the bonus-included figure are expected to slow down to 2.3% y/y in the three months to November. UK ILO unemployment is expected higher at 5.1% in the three months to November. Consumer Confidence (USD, GMT 15:00) – The US Consumer confidence is expected to slip to 88.0 from 88.6 in December, versus a 6-year low of 85.7 in April. The confidence measures have shown divergent swings since mid-2020 that have a downward tilt into January, likely due to the surge in virus cases, more stringent lockdowns, and the bizarre political events of recent weeks. We should be seeing some lift from stimulus passage and vaccine distributions, however, which may be more evident in February. Wednesday – 27 January 2021 Consumer Price Index (AUD, GMT 00:30) – Australian inflation data in Q4 is expected to decline at 1.5% q/q while headline remains in line with Q3 at 0.7% y/y. Durable Goods (USD, GMT 12:30) – Durable goods orders are expected to rise 3.0% in December with an 8.3% climb in transportation orders. A defense orders gain is pegged at 3.0%, following a 3.7% November bounce. Boeing orders jumped to 90 in December with the lifting of the 737 MAX grounding, from 27 in November and zero in the two months before that. Durable shipments should rise 1.0%, and inventories should rise 0.5%. Interest Rate Decision and Conference (USD, GMT 19:00) – The FOMC is due to meet (Tuesday, Wednesday) but no changes are expected. The FOMC didn’t make any big changes in its policy stance at the December 16 meeting. However, it did tweak its statement to emphasize its uber-accommodative posture, which was underscored several times by Chair Powell in his press conference. The forecasts indicate that current rates will remain in place through 2023. Thursday – 28 January 2021 Harmonized Index of Consumer Prices (EUR, GMT 13:00) – The German prel. HICP inflation for January is anticipated to be released at -0.6% y/y from -0.7% y/y. Germany’s temporary VAT cut is partly to blame as are base effects from oil prices, but it is also clear that a lack of demand and the closure of the hospitality sector continue to keep a lid on headline inflation numbers. Gross Domestic Product (USD, GMT 12:30) – The prelim. Gross Domestic Product should advance at 4.1% in Q4 and 3.2% in Q1, after 33.4% growth in Q3. We expect a Q4 moderation in consumption growth to 2.2% from 41.0% in Q3 as heightened coronavirus restrictions impacted spending, while government purchases contract at an estimated -5% rate, and nonresidential investment in structures fall at a -9% pace. We saw in Q3 a continued boom in housing activity and equipment spending. Friday – 29 January 2021 Gross Domestic Product (EUR, GMT 09:00) – Eurozone’s GDP contracted -5.0% last year, according to the first estimate for economic activity last year. That compared to a modest rise of 0.6% in 2019 and while it was somewhat better than median expectations, the numbers refer to unadjusted data. Adjusted for calendar effects, GDP was actually down -5.3%. There is no data for the last quarter yet, but it is pretty clear that after the recession in the first quarter and the rebound over the summer, virus developments weighed on growth again in the last quarter of 2020, although less than feared at one point. Personal Income/Consumption (USD, GMT 12:30) – A 0.1% increase in headline rise for personal income in December is anticipated after a -1.1% drop in November, alongside a -0.7% drop in consumption after a -0.4% November decline. 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. Andria Pichidi 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 raeliable 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.
×
×
  • Create New...

Important Information

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