NexusFi: Find Your Edge


Home Menu

 





GTC stops instead of Day orders... free code for percent targets DAY help make GTC


Discussion in EasyLanguage Programming

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




 
Search this Thread

GTC stops instead of Day orders... free code for percent targets DAY help make GTC

  #1 (permalink)
mslezak
Houston Texas
 
Posts: 1 since Jul 2013
Thanks Given: 0
Thanks Received: 0

Anyone know how to modify this code I wrote that uses EasyLanguage to place DAY orders based on percent targets to code that places Good Until Cancelled orders? It seems the function written for stops in EL doesn't allow this parameter, so another function is required. Has to be a One Cancels Other order... Don't want to have to rely on an internet connection being up, just want the stops in place as soon as the initial position is triggered. Posting free code here in exchange for some help...


Inputs: Price(Close), //use the closing price for calcs
Cts(3), //#contracts for each trade
Notional(5000), //default per contract units (5000 bushels corn/ soybeans / wheat etc.)
StopLossPct(0.02), // 2% target, change to your liking
ProfitTgtPct(0.02); // 2% target

Vars:
PrcStopLessEntryPrice(StopLossPct*Cts*Notional), PrcPrfLessEntryPrice(ProfitTgtPct*Cts*Notional), StpLoss(0), PrfTgt(0);

// YOUR CODE HERE THAT DOES SOME BUY OR SELL BASED ON SOMETHING....
StpLoss = PrcStopLessEntryPrice * Price[0];
PrfTgt= PrcPrfLessEntryPrice * Price[0];

SetStopPosition;
SetStopLoss(StpLoss);
SetProfitTarget(PrfTgt);

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
Cheap historycal L1 data for stocks
Stocks and ETFs
About a successful futures trader who didnt know anythin …
Psychology and Money Management
 
  #3 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,666 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,360



mslezak View Post
Anyone know how to modify this code I wrote that uses EasyLanguage to place DAY orders based on percent targets to code that places Good Until Cancelled orders? It seems the function written for stops in EL doesn't allow this parameter, so another function is required. Has to be a One Cancels Other order... Don't want to have to rely on an internet connection being up, just want the stops in place as soon as the initial position is triggered. Posting free code here in exchange for some help...


Inputs: Price(Close), //use the closing price for calcs
Cts(3), //#contracts for each trade
Notional(5000), //default per contract units (5000 bushels corn/ soybeans / wheat etc.)
StopLossPct(0.02), // 2% target, change to your liking
ProfitTgtPct(0.02); // 2% target

Vars:
PrcStopLessEntryPrice(StopLossPct*Cts*Notional), PrcPrfLessEntryPrice(ProfitTgtPct*Cts*Notional), StpLoss(0), PrfTgt(0);

// YOUR CODE HERE THAT DOES SOME BUY OR SELL BASED ON SOMETHING....
StpLoss = PrcStopLessEntryPrice * Price[0];
PrfTgt= PrcPrfLessEntryPrice * Price[0];

SetStopPosition;
SetStopLoss(StpLoss);
SetProfitTarget(PrfTgt);


I'm almost positive that you cannot create GTC orders using automated code with SetStopLoss, SetProfitTarget. They are just day orders for that bar, unless the next bar cancels them or reaffirms them.

A couple of possible alternatives:

Use macros in your code to send the orders

Use PSP Order Ticket object (new programming in TS 9.0)


Unfortunately, I have no experience in either of the above.

Follow me on Twitter Reply With Quote




Last Updated on August 6, 2013


© 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