NexusFi: Find Your Edge


Home Menu

 





Place order from indicator in TradeStation Easylanguage


Discussion in TradeStation

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




 
Search this Thread

Place order from indicator in TradeStation Easylanguage

  #1 (permalink)
loi5139
NewYork, NY
 
Posts: 7 since May 2016
Thanks Given: 1
Thanks Received: 2

Hi experts,

I'm very new to EZL, so sorry for the stupid question.

I created an indicator that signal buy/sell and plot. The signal is working fine. But, when i get the signal I want to place an order from the indicator itself.

I first tried the function Buy/Sell, EZL tells me that's not allowed in indicator. I tried the macro .PlaceOrder, EZL didn't like it when verified.

Now I used the command LimitOrder, but it returns me as invalid order. Thisi is my code. After much reading and research on the net, i'm still a bit confused as to which command/function can be used in indicator.

Any help is much appreciated.

price_trigger = (High + Low) /2 ;
Plot2 (buy_signal, "Buy");
Plot3 (Price_Trigger, "Price_Entry");

PositionQty = Getnumpositions ("SIM8625555M");
OrderQty = UserQty - PositionQty;

//.PlaceOrder "Action='Buy', OrderType = 'Limit', Quantity = OrderQty, QuantityType = 'Shares', Route = 'Intelligent', Symbol = EquitySymbol, SymbolCategory = 'Equity'"; // TRIED THIS, DIDN'T WORK

OrderValid = LimitOrder ("OncePerBar", "SIM8625555M", "Buy", "Equity", EquitySymbol, OrderQty, "1min", "", Price_trigger);

PauseSellTime = Currenttime + 1.5;
PauseBuyTime = Currenttime + 1.5;
//Playsound ("c:\AirHorn.wav");

If OrderValid = 0 then PauseBuyTime = 1;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
MC PL editor upgrade
MultiCharts
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #2 (permalink)
 
furytrader's Avatar
 furytrader 
Lake Forest, IL USA
 
Experience: Intermediate
Platform: MultiCharts + CTS T4
Broker: Advantage Futures, IQFeed.net
Trading: YM, ES, EU, US, S
Posts: 153 since Jun 2011
Thanks Given: 109
Thanks Received: 147

As far as I recall, you can't place an order from an indicator. You have to use a signal. Copy and paste the indicator logic into a signal and generate the order from there. If your indicator uses parameters, you need to make sure you update parameters in both the indicator and signal for them to remain consistent.

Reply With Quote
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628


loi5139,

you are probably better off following furytrader's suggestion and build a signal with similar conditions.

You can send orders out of indicators nowadays using macros and Object Oriented Easylanguage. The latter will likely give you much more control than you have with macros. The downside is both methods will only work realtime and at least OOEL will require advanced coding skills and therefore it's much harder to track down any problems (especially when starting out).

From your code it's hard to tell - I am not sure if "1min" is a valid duration for the order. You might want to try "GTC" or "DAY" in your testing.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #4 (permalink)
loi5139
NewYork, NY
 
Posts: 7 since May 2016
Thanks Given: 1
Thanks Received: 2

Hi All,

Thanks for the answers. This is what i found and i hope it helps some future noobs like me.

So, i did some research and like you said it turns out that you can't use that macro command or any other buy/sell commands from an indicator, it can be used on strategies only. No matter what other people says on the net. I tested all the options at long and large.

I realized that macro commands and such are not prefered methods by TS. They encourage to use the Providers Object/Class. Which can/must be added to the code from the toolbox in TS Development Envi.

This works really well in indicator, must add the providers class and init them:

PositionQty = GetPositionQuantity (UserSymbol,UserAccount);
OrderQty = UserQty - PositionQty;
OrderTicket1.Symbol = UserSymbol;
OrderTicket1.LimitPrice = Price_Trigger;
OrderTicket1.Quantity = OrderQty;
OrderTicket1.Type = 1; //Limit=1, Market =2
OrderTicket1.Action = 1; //Buy=1 , Sell=2
OrderTicket1.send ();

I use the GetPositionQty command to get the position qty. There is a better way to do that with the providers class PositionsProvider. Supposedly it is a better method.

However, I was not able to make that work with the the OrderTicket class. When using both, it crashes my TS. I can only use either or.

Hope the information noobs like me to save some time in the future.

Reply With Quote
Thanked by:




Last Updated on June 15, 2016


© 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