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 3,297 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #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?
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
TradingView Deploys AI to Monitor SEC Filings in Real Ti …
TradingView
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Iran Forward Curve: June 30 at 56% vs June 15 at 28% -- …
Prediction Markets & Event Contracts
Orban at 29pct as Hungary Votes Tomorrow -- McIlroy Surg …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
197 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #3 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,737 since Jul 2012
Thanks Given: 1,917
Thanks Received: 7,476



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 X Reply With Quote




Last Updated on August 6, 2013


© 2026 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 - Downloads - Top
no new posts