Long Entry Logic and EasyLanguage Code for Pyramiding Algorithm

Sorry for the delay in getting this up on the web.  Here is the flip side of the pyramiding day trade scheme from the buy side perspective.  I simply flipped the rules.  In some cases, to keep the programming a little cleaner I like to keep the buy and sellShort logic in two separate strategies.  So with this chart make sure you insert both strategies.

And here is the code:

vars: mp(0),lastTradePrice(0),canBuy(true);

mp = marketPosition * currentContracts;

if date[0] <> date[1] then
begin
canBuy = true;
end;

if mp = 1 then canBuy = false;
if time > 1430 then canBuy = false;

if mp = 0 and canBuy = true then buy next bar at OpenD(0) + 3 stop;
if mp = 1 then buy next bar at OpenD(0) + 6 stop;
if mp = 2 then buy next bar at OpenD(0) + 9 stop;

if mp = 1 then lastTradePrice = OpenD(0) + 3;
if mp = 2 then lastTradePrice = OpenD(0) + 6;
if mp = 3 then lastTradePrice = OpenD(0) + 9;


if mp <> 0 then sell next bar at lastTradePrice - 3 stop;

if mp = 3 and barsSinceEntry > 0 and highD(0) > lastTradePrice + 3 then sell next bar at highD(0) - 3 stop;

setExitOnClose;
Pyramiding 3 Handles Up and Trailing Stop

Discover more from George Pruitt

Subscribe to get the latest posts sent to your email.

2 thoughts on “Long Entry Logic and EasyLanguage Code for Pyramiding Algorithm”

  1. HI, can we get to know or save the price of every entries that occurs when pyramiding is on.
    If there are four entries traded in four bar simultaneously, how to print all four prices of each bar.
    pls help me out.
    warm regards

    1. Hello Nirmal – Let me make sure I understand. In my pyramiding scheme you would like to know all three entry prices not just the last one. Is that correct? If that’s the case I will code this up using an array to store the values. Do you want only 1 entry per bar? Or will be a chance for multiple entries on a single bar? Just let me know and thanks for visiting my Blog – Geo

Leave a Reply