Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Updated August 22, 2012
Top Posters
looks_one
KhaosTrader
with 40 posts (4 thanks)
looks_two
Nicolas11
with 27 posts (24 thanks)
looks_3
Bimi
with 2 posts (2 thanks)
looks_4
Quick Summary
with 1 posts (0 thanks)
Best Posters
looks_one
Jura
with 3 thanks per post
looks_two
Bimi
with 1 thanks per post
looks_3
Nicolas11
with 0.9 thanks per post
looks_4
KhaosTrader
with 0.1 thanks per post
trending_up
30,999 views
thumb_up
33 thanks given
group
3 followers
forum
68 posts
attach_file
16 attachments
August 22nd, 2012, 03:46 AM
near Paris, France
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769
@Bimi , could you kindly elaborate a little? Sounds interesting but I have not caught it.
@KhaosTrader , you can use a flag. For instance a boolean AlreadyTradedThisBar that you would set to false at each new bar (BarStatus).
Nicolas
Envoyé depuis mon GT-I9100 avec Tapatalk
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
August 22nd, 2012, 04:40 AM
San Jose
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21
Nicolas,
I implemented your suggestion by setting the flag, EnterTrade = false.. But now it wont enter all trades it should.. Here is the screenshot ....
here is the code snippet..
Code
if ( BarStatus(1) = 2 ) then begin
EnterTrade = ( Low >= Low[1] and High >= High[1] );
LongEntryPrice = High;
ShortEntryPrice = Low;
end;
if MarketPosition = 0 and EnterTrade then begin
Buy ("Enter Long") 300 Shares next Bar at LongEntryPrice stop;
EnterTrade = false;
//SellShort("Enter Short") 300 Shares Next Bar at (ShortEntryPrice) stop;
end;
Here is full code:
Code
Inputs:
Target1 (50),
Target2(100),
Target3(200),
StopSize(75),
BuyGap(.20),
BE2(1) , // 0=false, 1 = true
BE3(1); // 0=false, 1 = true
Variables:
EnterTrade ( false ),
LongEntryPrice ( 0 ),
ShortEntryPrice ( 0 ),
TickSize (MinMove/PriceScale),
t1 (target1*TickSize),
t2 (target2*TickSize),
t3 (target3*TickSize),
st1 (0),
st2 (0),
st3 (0);
[IntrabarOrderGeneration = true]
if ( BarStatus(1) = 2 ) then begin
EnterTrade = ( Low >= Low[1] and High >= High[1] );
LongEntryPrice = High;
ShortEntryPrice = Low;
end;
if MarketPosition = 0 and EnterTrade then begin
Buy ("Enter Long") 300 Shares next Bar at LongEntryPrice stop;
EnterTrade = false;
//SellShort("Enter Short") 300 Shares Next Bar at (ShortEntryPrice) stop;
end;
//Label # Shares below each bar
Value1 = Text_New(Date, Time, Low-(2), NumToStr(CurrentShares/100, 0));
Text_SetColor(Value1, Blue);
Text_SetSize(Value1, 9);
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
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;
August 22nd, 2012, 04:43 AM
San Jose
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21
Oh on the Strategy, I set the following:
* Allow unlimited entries per bar
* Backtesting Precision : Use Bar Magnifier [checked], Intraday=1 minutes, Skip ticks with identical prices [checked]
August 22nd, 2012, 04:48 AM
near Paris, France
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769
Seems logical...
I copy your code:
Quoting
if ( BarStatus(1) = 2 ) then begin
EnterTrade = ( Low >= Low[1] and High >= High[1] );
LongEntryPrice = High;
ShortEntryPrice = Low;
end;
if MarketPosition = 0 and EnterTrade then begin
Buy ("Enter Long") 300 Shares next Bar at LongEntryPrice stop;
EnterTrade = false;
//SellShort("Enter Short") 300 Shares Next Bar at (ShortEntryPrice) stop;
end;
Let's suppose that, at the last tick of the bar (BarStatus = 2), EnterTrade is set to true (first part of the code)
With the 2nd part of the code, you ask to buy at the next tick (first tick of the next bar) at a given price.
But you also set EnterTrade to false.
So, if the given price is not reached on the first tick of the next bar, the code will not enter trade later within the bar.
Nicolas
August 22nd, 2012, 04:56 AM
San Jose
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21
I see your point....
I then moved the "EnterTrade = false;" to the "if marketposition =1 then begin...
Code
if MarketPosition = 1 then begin
EnterTrade = false;
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;
but now again, it enters multiple times each bar... So I am pretty much at a loss on what to do...
August 22nd, 2012, 05:52 AM
near Paris, France
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769
@KhaosTrader ,
Could you test the 2 following modifications?
(1) In the Variables declaration, add one intrabarpersist:
Code
intrabarpersist EnterLong ( false ),
(2) At the beginning of "if MarketPosition = 1", add one line:
Code
if MarketPosition = 1 then begin
EnterLong = false;
[...]
--> Seems OK on my side (one entry per bar).
If it "doesn't work" on your side, please post again the whole code and a snapshot showing the problem.
I have to be frank: due to time constraints, I am not sure I will be able to continue here.
Nicolas
August 22nd, 2012, 10:32 AM
San Jose
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21
I think its working
I will test it more...
How did you discover the intrabarpersist ?
Thanks Nicolas!
August 22nd, 2012, 10:34 AM
near Paris, France
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769
I'm happy it seems to work.
"How did you discover the intrabarpersist ? "
It is a secret.
Nicolas
August 22nd, 2012, 10:38 AM
San Jose
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21
LOL well, you are really good at easylanguage , I doubt I would have found that.
Thanks
Last Updated on August 22, 2012