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,327 views
thumb_up
33 thanks given
group
3 followers
forum
68 posts
attach_file
16 attachments
August 20th, 2012, 04:34 AM
San Jose
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21
Thank you @Jura for your help on this! Much appreciated!
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
August 20th, 2012, 04:50 AM
near Paris, France
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769
So...
Within all 10-min bars of a given hour (10:10-11:00), you want to see a trendline showing the High and Low of the previous hour (09:10-10:00).
Correct?
August 20th, 2012, 04:56 AM
San Jose
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21
August 20th, 2012, 04:58 AM
San Jose
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21
The way I envision it is that the code will determine how many bars in the given time frame make up an hour, and then it will iterate through the bars to find the highest high and lowest low. That way the hourly code can work in different time scales, be it 1 min, 5 min, 10 min or 15 min...
August 20th, 2012, 05:02 AM
near Paris, France
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769
This is not related any more to the initial subject of this thread ("sell this bar").
So I suggest that you post this new request in the thread
I also suggest that, in the other thread, you use a brief description as your request. Not too far from:
Quoting
Within all 10-min bars of a given hour (10:10-11:00), I would like to see a trendline showing the High and Low of the previous hour (09:10-10:00).
Nicolas
August 20th, 2012, 05:08 AM
San Jose
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21
Ok sounds good. I will make the new post.
August 21st, 2012, 09:16 PM
San Jose
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21
Hi, I discovered a problem with the current implementation.
It is possible for there to be more than one entry in a given bar, that means that if in a given hourly bar, the code enters a trade and exits the trade at target, and its still moving up, it can enter the trade again. I would like the code to enter trades max 1 time per bar.
Should we add another condition to the if statement below in the code, where it can only execute an entry if price is within a certain range also?
Code
if MarketPosition = 0 and EnterLong then begin
Buy ("Enter Long") 300 Shares next Bar at LongEntryPrice stop;
end;
August 21st, 2012, 09:33 PM
San Jose
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21
Another idea might be to identify the current bar time, and make sure it wont enter again on the same bar?
August 21st, 2012, 10:26 PM
San Jose
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21
Here is the chart where I point out the problem, and the code...
(I commented out the short entries because I want to make sure longs work first)
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:
EnterLong ( 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
EnterLong = ( Low >= Low[1] and High >= High[1] );
LongEntryPrice = High;
ShortEntryPrice = Low;
end;
if MarketPosition = 0 and EnterLong then begin
Buy ("Enter Long") 300 Shares next Bar at LongEntryPrice stop;
//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 21st, 2012, 10:39 PM
London
Posts: 118 since Mar 2010
Thanks Given: 42
Thanks Received: 58
you need to create a time-line, and step your code through the time-line to make sure all the angles are covered .
Last Updated on August 22, 2012