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 26,097 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?

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

Thanks, that made the entries all occur on 1 bar, but.... lol, its so funny, now ALL entries are on the bar, even if i put my target 3 to a huge amount and my stop to a huge amount, it should have some exits on other bars.....

I am really appreciative of your help...

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Strategy stop orders partially filled
EasyLanguage Programming
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
24 thanks
What is Markets Chat (markets.chat) real-time trading ro …
19 thanks
ApexTraderFunding.com experience and review
18 thanks
GFIs1 1 DAX trade per day journal
13 thanks
EG Indicators
11 thanks
  #12 (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

"now ALL entries are on the bar"

You mean: all exits?
Is it still the same code as above?
Could you post a chart showing the problem?

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


Yes, ok here is the code, and below is the chart...



inputs:
target1 (50),
target2(100),
target3(500),
stopsize(120),
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+buypoint) stop;
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));

//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

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
  #14 (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

I have the feeling that the code does exactly what you ask it to do.

 
Code
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;
Nicolas

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

LOL, ooops... Sorry .. Yep that was the problem.

How do I make allow unlimited entries and exits per bar as default? is there a script command for that?

Thanks so much Nicholas!

Started this thread Reply With Quote
  #16 (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

Without having checked, I would say that it is not possible to change the default setting, and that you have to check each time you add a strategy. But I may be wrong.

Nicolas

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

Ok. I will set it manually...

I am backtesting and am seeing sometimes it doesnt enter when it should here is the chart and the (sorta fixed) code




inputs:
target1 (50),
target2(100),
target3(300),
stopsize(75),
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+buypoint) stop;
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));

//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

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 + 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;

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
  #18 (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

I think that the previous trade is not closed.
You are still long 100 contracts.

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

your right, but i dont get it , i should have been stopped out... stop is 75 cents below entry or b/e

Started this thread Reply With Quote
  #20 (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


When you ask the code to print TickSize, which value of TickSize does it print?

Visit my NexusFi Trade Journal Reply With Quote




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