Pyramiding - futures io
futures io



Pyramiding


Discussion in EasyLanguage Programming

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




Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Pyramiding

(login for full post details)
  #1 (permalink)
soacm
Bucharest, Romania
 
 
Posts: 5 since Mar 2022
Thanks: 5 given, 1 received

Hi everyone, I am trying to implement pyramiding in a strategy but every time my last position's stop gets touched, all the previous positions are liquidated at the same level.
I tried the reserved word Total but still it did not fix it, below I will paste the entry code, please let me know.

vars: StopPrice(0),
MP(0),
CC(0);
MP = Marketposition;
CC = Currentcontracts;

////////////////////////////////////////////////////////////////////////////

// LE1
If MP = 0 and CC = 0 and
{type of entry} then
begin
Buy ("LE1") next bar 1 Contract at Open;
StopPrice = Low[1]; // Stop below previous candle
end;
Sell ("LE1Loss") 1 Contract Total next bar at StopPrice on Stop;

////////////////////////////////////////////////////////////////////////////

// LE2
If MP = 1 and CC = 1 and
{type of entry} then
begin
Buy ("LE2") next bar 1 Contract at Open;
StopPrice = Low[1]; // Stop below previous candle
end;
Sell ("LE2Loss") 1 Contract Total next bar at StopPrice on Stop;


Note: every time the stop of LE2 gets touched, LE1 is automatically closed at that same level (the same happens for LE3 or LE4 which I did not include in the code).

Reply With Quote

Can you help answer these questions
from other members on futures io?
Tips for directional bias during Asian Session?
Traders Hideout
need help with easy language OR breakout code:)
Traders Hideout
mahDualCandlePattern
NinjaTrader
value chart indicator by sim22
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Spoo-nalysis ES e-mini futures S&P 500
44 thanks
How many day traders are profitable?
27 thanks
Why you should move from futures to forex
15 thanks
Attached Orders
13 thanks
fx "traders" hate real profitable traders
8 thanks
 
(login for full post details)
  #2 (permalink)
 SMCJB 
Legendary Market Wizard
Houston, TX
 
Experience: Advanced
Platform: Trading Technologies
Broker: Primary Advantage Futures. Also ED&F and Tradestation
Trading: Primarily Energy but also a little GE, SI, Bitcoin & Ether
 
Posts: 4,517 since Dec 2013
Thanks: 3,852 given, 9,105 received

I worked on a pyramiding system about 5 years ago and couldn't get it to work. I reached out to somebody my knowledgeable than me and they sent me this...

Tying an Exit to an Entry
It is possible to tie an exit instruction to a specific entry. This can be achieved only if you named the long entry, and the long entry is in the same strategy as the exit order. Consider the following strategy:
Buy ("MyBuy") 10 Shares Next Bar at Market;
Buy 20 Shares Next Bar at High + 1 Point Stop ;
Sell From Entry ("MyBuy") Next Bar at High + 3 Points Stop;
In the above example, the strategy may buy 30 shares total; your long position is 30 shares. However, the Sell instruction only closes out the 10 shares bought using the MyBuy entry order. It ignores any other order, and does not close out the other 20 shares. Therefore, this strategy leaves you long 20 shares.
You can also close part of an entry order. For example, if your entry, which you named "MyBuy" buys 10 shares, you can specify that you want to exit from entry "MyBuy" but only close out 5 shares, not the entire 10:
Sell From Entry ("MyBuy") 5 Shares Next Bar at High + 3 Points Stop;
Important The entry name is case sensitive. Be sure to use consistent capitalization. Also, it is important to remember that exit orders do not pyramid; therefore, if an exit does not close out an entire position, you will need another exit order (or reversal order) in order to close out the position.

Number of Shares/Contracts
To specify how many shares/contracts to close out, use a numeric expression followed by the word shares or contracts after the trading verb Sell. Some Examples:
Sell 100 Shares This Bar on Close;
Sell From Entry ("MovAvg") 10 Shares Next Bar at High + 1 Point Stop ;
The words shares and contracts are synonymous.
If you do not specify the number of shares or contracts in the Sell instruction, the exit order closes out the entire long position, rendering your position flat.
When you specify the number of shares/contracts, the Sell instruction exits the specified number of shares/contracts from every open entry.
Therefore, if the Strategy allows for pyramiding, and has bought 500 shares twice (for a total of 1,000 shares), and an order to Sell 100 Shares is placed by the Strategy, the instruction will exit a total of 200 shares: 100 shares from each of the two entries.
However, if you want to exit a total of 100 shares, you can use the word Total in the Sell instruction. Using the word Total instructs the Strategy to exit 100 shares from the first open entry (first in, first out).
For Examples:
Sell 100 Shares Total This Bar on Close;
Sell From Entry ("MovAvg") 10 Shares Total Next Bar at High + 1 Point Stop ;


Looking at the email chain, I was using multiple entries and multiple exits that were not tied to each other. The important part to get this to work for me was the part highlighted in red part. Specifically the use of the word "TOTAL"

Reply With Quote
The following 2 users say Thank You to SMCJB for this post:
 
(login for full post details)
  #3 (permalink)
soacm
Bucharest, Romania
 
 
Posts: 5 since Mar 2022
Thanks: 5 given, 1 received



SMCJB View Post
I worked on a pyramiding system about 5 years ago and couldn't get it to work. I reached out to somebody my knowledgeable than me and they sent me this...

Tying an Exit to an Entry
It is possible to tie an exit instruction to a specific entry. This can be achieved only if you named the long entry, and the long entry is in the same strategy as the exit order. Consider the following strategy:
Buy ("MyBuy") 10 Shares Next Bar at Market;
Buy 20 Shares Next Bar at High + 1 Point Stop ;
Sell From Entry ("MyBuy") Next Bar at High + 3 Points Stop;
In the above example, the strategy may buy 30 shares total; your long position is 30 shares. However, the Sell instruction only closes out the 10 shares bought using the MyBuy entry order. It ignores any other order, and does not close out the other 20 shares. Therefore, this strategy leaves you long 20 shares.
You can also close part of an entry order. For example, if your entry, which you named "MyBuy" buys 10 shares, you can specify that you want to exit from entry "MyBuy" but only close out 5 shares, not the entire 10:
Sell From Entry ("MyBuy") 5 Shares Next Bar at High + 3 Points Stop;
Important The entry name is case sensitive. Be sure to use consistent capitalization. Also, it is important to remember that exit orders do not pyramid; therefore, if an exit does not close out an entire position, you will need another exit order (or reversal order) in order to close out the position.

Number of Shares/Contracts
To specify how many shares/contracts to close out, use a numeric expression followed by the word shares or contracts after the trading verb Sell. Some Examples:
Sell 100 Shares This Bar on Close;
Sell From Entry ("MovAvg") 10 Shares Next Bar at High + 1 Point Stop ;
The words shares and contracts are synonymous.
If you do not specify the number of shares or contracts in the Sell instruction, the exit order closes out the entire long position, rendering your position flat.
When you specify the number of shares/contracts, the Sell instruction exits the specified number of shares/contracts from every open entry.
Therefore, if the Strategy allows for pyramiding, and has bought 500 shares twice (for a total of 1,000 shares), and an order to Sell 100 Shares is placed by the Strategy, the instruction will exit a total of 200 shares: 100 shares from each of the two entries.
However, if you want to exit a total of 100 shares, you can use the word Total in the Sell instruction. Using the word Total instructs the Strategy to exit 100 shares from the first open entry (first in, first out).
For Examples:
Sell 100 Shares Total This Bar on Close;
Sell From Entry ("MovAvg") 10 Shares Total Next Bar at High + 1 Point Stop ;


Looking at the email chain, I was using multiple entries and multiple exits that were not tied to each other. The important part to get this to work for me was the part highlighted in red part. Specifically the use of the word "TOTAL"

Thank you for your reply,
I tried to implement both Total and from entry but nothing changes. Below I will upload an example with 3 consecutive entries (LE1, LE2,LE3). As you can see when LE3's stop loss gets touched, the code sells all of the previous entries at that same level. In the image I also outlined the previous stop losses levels, let me know if it's not clear.
Changes applied to the code:
vars: StopPrice(0),
MP(0),
CC(0);
MP = Marketposition;
CC = Currentcontracts;

////////////////////////////////////////////////////////////////////////////

// LE1
If MP = 0 and CC = 0 and
{type of entry} then
begin
Buy ("LE1") next bar 1 Contract at Open;
StopPrice = Low[1]; // Stop below previous candle
end;
Sell from entry ("LE1") 1 Contract Total next bar at StopPrice on Stop;

////////////////////////////////////////////////////////////////////////////

// LE2
If MP = 1 and CC = 1 and
{type of entry} then
begin
Buy ("LE2") next bar 1 Contract at Open;
StopPrice = Low[1]; // Stop below previous candle
end;
Sell from entry ("LE2") 1 Contract Total next bar at StopPrice on Stop;

////////////////////////////////////////////////////////////////////////////

// LE3
If MP = 1 and CC = 2 and
{type of entry} then
begin
Buy ("LE3") next bar 1 Contract at Open;
StopPrice = Low[1]; // Stop below previous candle
end;
Sell from entry ("LE3") 1 Contract Total next bar at StopPrice on Stop;

Note: I wonder if StopPrice can be the issue (?)

Attached Thumbnails
Click image for larger version

Name:	NQtest.png
Views:	15
Size:	113.3 KB
ID:	324191  
Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Pyramiding


Last Updated on May 2, 2022


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2022 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
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.
no new posts