NexusFi: Find Your Edge


Home Menu

 





Question about MC "Sell" and "BuyToClose" syntax


Discussion in MultiCharts

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




 
Search this Thread
  #1 (permalink)
 
Sinatra Fan's Avatar
 Sinatra Fan 
Orlando FL
 
Experience: Intermediate
Platform: MultiCharts, Ninja
Trading: Emini ES
Posts: 101 since May 2019
Thanks Given: 8
Thanks Received: 12

So I've been programming with EASY/POWERlanguage for about 13 years now. And I'm not too proud to say that I'm not a "know-it-all" nor do I pretend to know everything there is to know. With that said, I'm in the process of coding a strategy that adds contracts and takes off contracts during a trade. While thinking of how to do this, I decided to actually look up the keyword "SELL" in the reference guide. In there, I found the following example:

Completely exit from the long position established by the entry labeled "Original
Entry", at Market price on open of next bar:


Sell From Entry("Original Entry")Next Bar At Open;

Sell 10 shares of the long position established by the entry labeled "Original
Entry", at Market price on open of next bar:


Sell Entry("Original Entry")10 Shares Next Bar At Market;

I found this useful but perplexing at the same time. So I must ask the community for clarity. Let's say I put in code that will Buy 20 contracts once the signal tests are met and I call that trade "Original Entry" Then, while that position is open, the strat identifies another condition and buys another 10 contracts that is labeled "Second Position". So now there is a total of 30 contracts open (20 under the label "Original Entry" and 10 under the label "Second Position".) Is MC's example in the reference guide saying that if I want to close all or some of only the contracts in the "Original Entry" position, it will do it with the examples shown? Please confirm.

Also, if the strategy has used this label in prior positions but are now closed out, is this a problem? In other words, can I assume it will only consider the open trades and nothing already closed out?

Thanks for the help.


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
April CPI Preview: +3.7% YoY Expected at 8:30 AM ET -- C …
Traders Hideout
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
Beijing Summit Closes: Xi Pledges Hormuz Help -- $1.14B …
Prediction Markets & Event Contracts
$500M Riding on World Cup 2026: France/Spain Co-Favored …
Prediction Markets & Event Contracts
Iran Airspace Collapses 18 Points to 15.5% While Hormuz …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
16 thanks
Darmok and Jalad at Tanagra
3 thanks
CME Expands 24/7 Trading to WTI Crude Oil and Gold -- We …
1 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643

Hello Sinatra Fan,

an exit tied to a specific entry name will only close shares/lots/contracts from entries with that name. If nothing is left to close from that entry it would not affect differently named entries.
In case you have multiple entries open that share the same name an exit like you wrote below would be applied to all entries with the same name. Using the "Total" reserved word in an exit allows you to change that default behavior.

This is a good topic for testing various scenarios on a chart as this should clarify all your questions and show you how you can control the behavior of exits.

Regards,

ABCTG




Sinatra Fan View Post
So I've been programming with EASY/POWERlanguage for about 13 years now. And I'm not too proud to say that I'm not a "know-it-all" nor do I pretend to know everything there is to know. With that said, I'm in the process of coding a strategy that adds contracts and takes off contracts during a trade. While thinking of how to do this, I decided to actually look up the keyword "SELL" in the reference guide. In there, I found the following example:

Completely exit from the long position established by the entry labeled "Original
Entry", at Market price on open of next bar:


Sell From Entry("Original Entry")Next Bar At Open;

Sell 10 shares of the long position established by the entry labeled "Original
Entry", at Market price on open of next bar:


Sell Entry("Original Entry")10 Shares Next Bar At Market;

I found this useful but perplexing at the same time. So I must ask the community for clarity. Let's say I put in code that will Buy 20 contracts once the signal tests are met and I call that trade "Original Entry" Then, while that position is open, the strat identifies another condition and buys another 10 contracts that is labeled "Second Position". So now there is a total of 30 contracts open (20 under the label "Original Entry" and 10 under the label "Second Position".) Is MC's example in the reference guide saying that if I want to close all or some of only the contracts in the "Original Entry" position, it will do it with the examples shown? Please confirm.

Also, if the strategy has used this label in prior positions but are now closed out, is this a problem? In other words, can I assume it will only consider the open trades and nothing already closed out?

Thanks for the help.


Follow me on X Reply With Quote
  #3 (permalink)
 
Sinatra Fan's Avatar
 Sinatra Fan 
Orlando FL
 
Experience: Intermediate
Platform: MultiCharts, Ninja
Trading: Emini ES
Posts: 101 since May 2019
Thanks Given: 8
Thanks Received: 12


OK, so now I have a new scenario.

Lets say I go long with 10 contracts. along the way, I want to close 9, leaving 1 open. What would my sell code look like?


Started this thread Reply With Quote




Last Updated on March 18, 2021


© 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