NexusFi: Find Your Edge


Home Menu

 





sell this bar, not next bar, is that possible?


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one KhaosTrader with 40 posts (4 thanks)
    2. looks_two Nicolas11 with 27 posts (24 thanks)
    3. looks_3 Bimi with 2 posts (2 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
      Best Posters
    1. looks_one Jura with 3 thanks per post
    2. looks_two Bimi with 1 thanks per post
    3. looks_3 Nicolas11 with 0.9 thanks per post
    4. looks_4 KhaosTrader with 0.1 thanks per post
    1. trending_up 25,884 views
    2. thumb_up 33 thanks given
    3. group 3 followers
    1. forum 68 posts
    2. attach_file 16 attachments




 
Search this Thread

sell this bar, not next bar, is that possible?

  #1 (permalink)
 KhaosTrader 
San Jose
 
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21

Hi,

In Mikes Easylanguage video, he shows the following code:

if CurrentShares = 100 then begin
Sell("Exit L300-CS100 Target") 100 Shares next Bar at (EntryPrice + t3) Limit;
Sell("Exit L300-CS100 Stop") 100 Shares next Bar at St3 Stop;
end;

But the problem is, that it cant execute the sales on the current bar. So how can I make it so it uses "this bar" instead of "next bar"?

Thanks in advance.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
31 thanks
Just another trading journal: PA, Wyckoff & Trends
26 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #3 (permalink)
Bimi
London
 
Posts: 118 since Mar 2010
Thanks Given: 42
Thanks Received: 58



KhaosTrader View Post
Hi,

In Mikes Easylanguage video, he shows the following code:

if CurrentShares = 100 then begin
Sell("Exit L300-CS100 Target") 100 Shares next Bar at (EntryPrice + t3) Limit;
Sell("Exit L300-CS100 Stop") 100 Shares next Bar at St3 Stop;
end;

But the problem is, that it cant execute the sales on the current bar. So how can I make it so it uses "this bar" instead of "next bar"?

Thanks in advance.

you have to declare [intrabarordergeneration = true] at the beginning of your code

Reply With Quote
  #4 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

It is obvious for @Bimi, but I prefer to add this comment for the OP.

With the above instruction, the trade will be triggered the first time the condition is met within the bar. Possibly in the middle of the bar or even at the first tick.

It is not a "buy at close".

Nicolas

Envoyé depuis mon GT-I9100 avec Tapatalk

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
 KhaosTrader 
San Jose
 
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21

Ok I did that, but i still have a problem, I want to enter using next bar, but possibly exit this bar. So I changed the code, and noticed that buy 100 shares next bar at the high of the current bar wont trigger a buy ever....

Here is the code

[intrabarordergeneration = true]

If Low > Low[1] and High > High[1] then begin
if barstatus(1) = 2 then Buy ("Enter Long") 300 Shares Next Bar At (High) stop;

end;

....
....
....

if CurrentShares = 100 then begin
Sell("Exit L300-CS100 Target") 100 Shares next Bar at (EntryPrice) Limit;
Sell("Exit L300-CS100 Stop") 100 Shares next Bar at st3 Stop;
end;

Started this thread Reply With Quote
  #6 (permalink)
 KhaosTrader 
San Jose
 
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21

oops, sorry after running the code, here is the problem..

It seems that it can enter on the next bar, but then it only exits 100 shares max per bar, i am not sure why...

example code:



[IntrabarOrderGeneration = true]
if MarketPosition = 0 and barstatus(1) = 2 and Low > Low[1] and High > High[1] then begin

Print("This is the closing tick of the bar.");
print ("this is buyTrigger = "+ NumToStr(buyTrigger ,0));
print ("timea = " + NumToStr(Time,0));


Buy ("Enter Long") 300 Shares Next Bar At high stop;


end;





// manage open orders

if MarketPosition = 1 then begin


st1 = EntryPrice - (stopsize * TickSize);
st2 = iff(BE2 = 1, EntryPrice, EntryPrice-(stopsize * TickSize));
st3 = iff(BE3 = 1, EntryPrice, EntryPrice-(stopsize * TickSize));

print ("this is ticksize = "+ NumToStr(ticksize ,2));
print ("this is enter = "+ NumToStr(entryprice ,2));
print ("this is stop = "+ NumToStr(st1 ,2));
print ("this is stopsize = "+ NumToStr(stopsize ,2));

if CurrentShares = 100 then begin
Sell("Exit L300-CS100 Target") 100 Shares next Bar at (EntryPrice + t3) Limit;
Sell("Exit L300-CS100 Stop") 100 Shares next Bar at st3 Stop;
end;


if CurrentShares = 200 then begin
Sell("Exit L200-CS200 Target") 100 Shares Next Bar at (EntryPrice + t2) Limit;
Sell("Exit L200-CS200 Stop") 100 Shares Next Bar at st2 Stop;
Sell("Exit L300-CS200 Target") 100 Shares Next Bar at (EntryPrice + t3) Limit;
Sell("Exit L300-CS200 Stop") 100 Shares Next Bar at st3 Stop;
end;

if CurrentShares = 300 then begin
Sell("Exit L100-CS300 Target") 100 Shares Next Bar at (EntryPrice + t1) Limit;
Sell("Exit L100-CS300 Stop") 100 Shares Next Bar at st1 Stop;
Sell("Exit L200-CS300 Target") 100 Shares Next Bar at (EntryPrice + t2) Limit;
Sell("Exit L200-CS300 Stop") 100 Shares Next Bar at st2 Stop;
Sell("Exit L300-CS300 Target") 100 Shares Next Bar at (EntryPrice + t3) Limit;
Sell("Exit L300-CS300 Stop") 100 Shares Next Bar at st3 Stop;
end;

end;

Started this thread Reply With Quote
  #7 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

In your the code posted above, we cannot see how t1, t2 and t3 are calculated. Are they inputs or calculated one way or another?

Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 KhaosTrader 
San Jose
 
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21

Here are the trades on the chart...




// here is how t1,t2, and t3 is calculated...

inputs:

target1 (10),
target2(20),
target3(30),
stopsize(200),
buyCushion (.20),
BE2(0) , // 0=false, 1 = true
BE3(0); // 0=false, 1 = true

vars:
TickSize (MinMove/PriceScale),
smav (0),
emav (0),
hmav(0),
t1 (target1*TickSize),
t2 (target2*TickSize),
t3 (target3*TickSize),
st1 (0),
st2 (0),
st3 (0),
buyTrigger(0);

Started this thread Reply With Quote
  #9 (permalink)
 KhaosTrader 
San Jose
 
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21

Here is the code, in its entirety. I commented out shorting because I am wanting to get the long to work first...

inputs:
target1 (10),
target2(20),
target3(30),
stopsize(200),
buyCushion (.20),
BE2(0) , // 0=false, 1 = true
BE3(0); // 0=false, 1 = true

vars:
TickSize (MinMove/PriceScale),
smav (0),
emav (0),
hmav(0),
t1 (target1*TickSize),
t2 (target2*TickSize),
t3 (target3*TickSize),
st1 (0),
st2 (0),
st3 (0),
buyTrigger(0);


[IntrabarOrderGeneration = true]


// open new positions


if MarketPosition = 0 and barstatus(1) = 2 and Low > Low[1] and High > High[1] then begin
//and time>1000 and (time <1600)
Print("This is the closing tick of the bar.");
print ("this is buyTrigger = "+ NumToStr(buyTrigger ,0));
print ("timea = " + NumToStr(Time,0));


Buy ("Enter Long") 300 Shares Next Bar At high stop;

//SellShort("Enter Short") 300 Shares Next Bar at (Low-buypoint) stop;




end;





// manage open orders

if MarketPosition = 1 then begin


st1 = EntryPrice - (stopsize * TickSize);
st2 = iff(BE2 = 1, EntryPrice, EntryPrice-(stopsize * TickSize));
st3 = iff(BE3 = 1, EntryPrice, EntryPrice-(stopsize * TickSize));


if CurrentShares = 100 then begin
Sell("Exit L300-CS100 Target") 100 Shares next Bar at (EntryPrice + t3) Limit;
Sell("Exit L300-CS100 Stop") 100 Shares next Bar at st3 Stop;
end;


if CurrentShares = 200 then begin
Sell("Exit L200-CS200 Target") 100 Shares Next Bar at (EntryPrice + t2) Limit;
Sell("Exit L200-CS200 Stop") 100 Shares Next Bar at st2 Stop;
Sell("Exit L300-CS200 Target") 100 Shares Next Bar at (EntryPrice + t3) Limit;
Sell("Exit L300-CS200 Stop") 100 Shares Next Bar at st3 Stop;
end;

if CurrentShares = 300 then begin

print ("*********barstatus at exit commands = " + NumToStr(barstatus(1),0));

Sell("Exit L100-CS300 Target") 100 Shares Next Bar at (EntryPrice + t1) Limit;
Sell("Exit L100-CS300 Stop") 100 Shares Next Bar at st1 Stop;
Sell("Exit L200-CS300 Target") 100 Shares Next Bar at (EntryPrice + t1) Limit;
Sell("Exit L200-CS300 Stop") 100 Shares Next Bar at st2 Stop;
Sell("Exit L300-CS300 Target") 100 Shares Next Bar at (EntryPrice + t1) Limit;
Sell("Exit L300-CS300 Stop") 100 Shares Next Bar at st3 Stop;
end;

end;

if MarketPosition = -1 then begin

st1 = EntryPrice + (stopsize * TickSize);
st2 = iff(BE2 = 1, EntryPrice, EntryPrice+(stopsize * TickSize));
st3 = iff(BE3 = 1, EntryPrice, EntryPrice+(stopsize * TickSize));

if CurrentShares = 100 then begin
BuyToCover("Exit S300-CS100 Target") 100 Shares Next Bar at (EntryPrice - t3) Limit;
BuyToCover("Exit S300-CS100 Stop") 100 Shares Next Bar at st3 Stop;
end;


if CurrentShares = 200 then begin
BuyToCover("Exit S200-CS200 Target") 100 Shares Next Bar at (EntryPrice - t2) Limit;
BuyToCover("Exit S200-CS200 Stop") 100 Shares Next Bar at st2 Stop;
BuyToCover("Exit S300-CS200 Target") 100 Shares Next Bar at (EntryPrice - t3) Limit;
BuyToCover("Exit S300-CS200 Stop") 100 Shares Next Bar at st3 Stop;
end;

if CurrentShares = 300 then begin
BuyToCover("Exit S100-CS300 Target") 100 Shares Next Bar at (EntryPrice - t1) Limit;
BuyToCover("Exit S100-CS300 Stop") 100 Shares Next Bar at st1 Stop;
BuyToCover("Exit S200-CS300 Target") 100 Shares Next Bar at (EntryPrice - t2) Limit;
BuyToCover("Exit S200-CS300 Stop") 100 Shares Next Bar at st2 Stop;
BuyToCover("Exit S300-CS300 Target") 100 Shares Next Bar at (EntryPrice - t3) Limit;
BuyToCover("Exit S300-CS300 Stop") 100 Shares Next Bar at st3 Stop;
end;


end;

Started this thread Reply With Quote
  #10 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769


Could you check the parameters below in the "Format" of your signal?


Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on August 22, 2012


© 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