NexusFi: Find Your Edge


Home Menu

 





For "strategies", is there a way to run it ONCE & have it turn itself off?


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,434 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

For "strategies", is there a way to run it ONCE & have it turn itself off?

  #1 (permalink)
thoughtful
Klamath Falls OR
 
Posts: 60 since Apr 2020
Thanks Given: 21
Thanks Received: 80

I want to write a strategy to place a simple order (not run a full-blown algo). Here's the order: buy at market and place a limit order -- (the limit order is at a higher price, so it's a profit target). I can do that, but, does it just keep running... placing the same order over and over on every single bar? I want it to run ONCE, and then have it shut itself off (turn it's "status" off). Is there a way to do that from within the code?

(FYI I've never used strategies before, I've always used keyboard-shortcuts/'hotkeys', but I'm trying to learn how to automate orders. BTW I'm using MultiCharts-with-EasyLanguage.)

(BTW, notice how the Title of my thread told you EXACTLY what my thread was about? Whereas most thread Titles are very VAGUE, just saying.)

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
NexusFi Journal Challenge - May 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
38 thanks
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #2 (permalink)
TradingGuy
Connecticut
 
Posts: 15 since Jan 2011
Thanks Given: 1
Thanks Received: 8

Yes, there are a few ways you can do this. Check out the "Once" reserved word, you can check for real-time processing and if true, use Once. Something like the pseudo code below. Or you can create a switch, also in the pseudo code below. There are other, more sophisticated ways as well. Hopefully this gives you a couple of ideas to work on and test.


 
Code
      
if GetAppInfo( aiRealtimeCalc ) = 1 then
Once
  Begin
    // Your code here
  End;


Var:
bool OrderUnsubmitted(true);

If OrderUnSubmitted then
  Begin
    OrderUnsubmitted = false
    // Your code here
  End;

Reply With Quote
  #3 (permalink)
thoughtful
Klamath Falls OR
 
Posts: 60 since Apr 2020
Thanks Given: 21
Thanks Received: 80



TradingGuy View Post
Yes, there are a few ways you can do this. Check out the "Once" reserved word, you can check for real-time processing and if true, use Once. Something like the pseudo code below. Or you can create a switch, also in the pseudo code below. There are other, more sophisticated ways as well. Hopefully this gives you a couple of ideas to work on and test.
...
[/CODE]

Yes, thank you, that makes sense to use a flag variable, I DID think of this already, but the problems with it are:
1) The strategy is technically still running, so it consumes PC resources to keep checking the flag every bar (but I guess that's not really a big deal).
2) As I place new orders, the dead strategies (with status off) build up in the list of strategies, and I'll have to manually delete them at some point.

BUT, yeah, I can do it, I was just wondering if there was a way for the strategy to delete itself since that's the perfect way to deal with simpler orders/strategies. I'm surprised the original EasyLanguage creators didn't think of this (Omega Research back in the 1980's/1990's).

Reply With Quote
  #4 (permalink)
 pimmsno1 
Salt Lake City, Utah
 
Experience: Advanced
Platform: Tradestation
Trading: ES, EC, NQ, RTY, YM
Posts: 6 since Feb 2015
Thanks Given: 4
Thanks Received: 8

I am assuming here you want the order to persist until canceled or filled. The problem is that for systems, the program assumes you want to cancel the order if not filled in the next bar - fill or kill. That is prevent needing to cancel an order for each adjustment to its stop or limit levels on each bar, and normally save processing power and order traffic for TS. TS could have designed ordered to stand, but need cancelling every bar.

It seems what you might want is a staged order that has your target entered automatically. You can create a custom OSO order that would place your two orders - with the limit target being x% or X points over the entry. Could work for what you are wanting if that is all you want in the system.

An alternative is to have the system continue to run and just replace the limit order at the same level or adjusting the level, or to have a condition after the order entry as some of the other contribuors have suggested, that tells it to back off once an order has been entered. Perhaps you just want the entry signal and level to show up on the trade manager so you can enter manually (or not) in case something crazy is happening - trump making an unexpected corona announcement or whatever. I like doing that (Manual entry, not making corona announcements). On the other hand, my systems tend to look for an hour or five in a trade, so I have time to do that. (I will omit a discussion of why that is OK unless its a volatility breakout type sys that is designed to try and catch outlier/low probability eventsand other provisos).

Reply With Quote




Last Updated on May 16, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts