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 30,327 views
    2. thumb_up 33 thanks given
    3. group 3 followers
    1. forum 68 posts
    2. attach_file 16 attachments




 
Search this Thread
  #51 (permalink)
 KhaosTrader 
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!

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
How to: Multi Time-Frame Volume Profile?
NinjaTrader
What a Cool Draw/Markup Tool!
Traders Hideout
Cycle Through Ninjatrader Open Windows
NinjaTrader
Has anyone taken The Mentor Program from The Trading Gam …
Trading Reviews and Vendors
RSI Values Scale
NinjaTrader
 
  #52 (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

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?

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


Yes that is correct.

Started this thread Reply With Quote
  #54 (permalink)
 KhaosTrader 
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...

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

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

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #56 (permalink)
 KhaosTrader 
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.

Started this thread Reply With Quote
  #57 (permalink)
 KhaosTrader 
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;

Started this thread Reply With Quote
  #58 (permalink)
 KhaosTrader 
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?

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

Started this thread Reply With Quote
  #60 (permalink)
Bimi
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.

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 - Sitemap - Downloads - Top
no new posts