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?

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

What it would do is create a high and a low horizontal trendline for the next hour... and it would keep doing that moving forward

so each prior rounder prior hour would have a high and a low price, and then it would create a trend line for the next hour's worth of bars so u can see if it is breaking the high or the low of the prior hour.. That way I would have the power of using hour bars to determine entry prices and i can use 1 minute bars to determine exit strategy.

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

@KhaosTrader,

1. The 1-min workaround is another story. I think that we first need to solve what happens with the 1-hour bar.

2. "I cant decipher the time". I do not understand. Could you show me an example of what is printed?
On my side, it is rather clear:

Quoting 
At 1120817 1600 CurrentShares = 300.00

3. "Is it possible to put the # of shares held Below the bar itself?"
Yes.
 
Code
Value1 = Text_New(Date, Time, Low-TickSize, NumToStr(CurrentShares, 0));
EDIT: This works for MultiCharts. I do not know for TradeStation.

4. "I need the " BarStatus(1) = 2" because I want to enter on the next bar on the break of the prior bar high..."
I am lost.
In the first message, I have the feeling that you wanted exactly the contrary: enter within a bar.
If you want to enter right at the opening of the next bar when a condition is met, you shall not use [intrabarordergeneration = true]
Please clarify.

Nicolas

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


1) ok I understand

2) 1120817 , how is this translated into time?

3) ok i put that in the code, and i have enclosed screenshot

4) i want to enter in the next bar, once it breaks the high of the prior bar , but I want to be able to exit if my target is met on the same bar that I entered....


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

ah the date format i get now.. 1120817 1600 , 1600 is the hour, and the other part is the date, got it

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

For the date, do not forget that 112 means 2012 in Easy Language (add 1900).

The text printing on the chart is OK. We see the "0". When the trade lasts on several bars, you should see 300, 200, 100. If you want to change the color or the size:
 
Code
Value1 = Text_New(Date, Time, Low-TickSize, NumToStr(CurrentShares, 0));
Text_SetColor(Value1, blue);
Text_SetSize(Value1, 14);
I have to make a break. I will come back later.

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

Ok thanks Nicolas, I am here whenever you are ready .

Thanks again for your help

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

@KhaosTrader,

Could you confirm your condition to enter long ? Is it what follows?

If "Low >= Low[1] and High >= High[1]" then enter at any moment within the next bar when the price reaches the High of the current bar.

Nicolas

Visit my NexusFi Trade Journal Reply With Quote
  #38 (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

@KhaosTrader,

If I have correctly understood what you are trying to do, this is not straight-forward.
I have myself struggled with it for a long time.
So thanks for your question, since it allows me clarifying things in my mind.
But the negative side is... I may be wrong!

You want the exits (stop-loss or profit target) to possibly occur on the same bar as the entry.
I think this requires [intrabarordergeneration = true].

But [IntrabarOrderGeneration = true] has a negative side effect: the condition for the entry is checked at any moment within the current bar. But you want the condition to be checked only at bar close. So there is your BarStatus = 2.

So... I'm OK with your code.

It remains that you have some problem.

I advise that you simplify your code to the simplest. For me, the simplest form is 10 lines:
 
Code
Variables:
	TickSize	( MinMove / PriceScale );

[IntrabarOrderGeneration = true]

if MarketPosition = 0 and BarStatus = 2 and Low >= Low[1] and High >= High[1] then begin
	Buy ("Enter Long") 300 Shares Next Bar At high stop;
end;

if MarketPosition = 1 then begin
	Sell("Profit Target") 300 Shares next Bar at (EntryPrice + 0.0003) Limit;
	Sell("Stop Loss") 300 Shares next Bar at (EntryPrice - 0.0003) Stop;
end;
Does it work? If yes, add the sophistications one by one until the problem appears.

Nicolas

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #39 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690


Nicolas11 View Post
If I have correctly understood what you are trying to do, this is not straight-forward.
I have myself struggled with it for a long time.
So thanks for your question, since it allows me clarifying things in my mind.
But the negative side is... I may be wrong!

You want the exits (stop-loss or profit target) to possibly occur on the same bar as the entry.
I think this requires [intrabarordergeneration = true].

But [IntrabarOrderGeneration = true] has a negative side effect: the condition for the entry is checked at any moment within the current bar. But you want the condition to be checked only at bar close. So there is your BarStatus = 2.

I think you're right.

If one uses BarStatus = 2 with 'buy next bar', the order will be executed on the first tick of the next bar (assuming it's a market order, otherwise it will be cancelled). With IntrabarOrderGeneration set on, the stop-loss for the same bar can be send on the second tick of the bar.

I can't say I understand the whole thread, but if I understand it correctly the enter stop orders need to be submitted for the whole duration of the next bar? If so, you'll need to use a true/false value to keep continue submitting the stop order for the next bar.

Because with IntrabarOrderGeneration next bar actually means next tick, the enter stop needs to be resubmitted. Otherwise, if the enter stop conditions aren't triggered on the first tick of the next bar, the order is cancelled.

Such a thing could look like:

 
Code
[intrabarordergeneration = true]

// On bar close
if (BarStatus(1) = 2) then begin 

	// Calculate long/short entries
	enterLong = ... 
	enterShort = ...
	
	// Calculate stop here (if needed)
	stop1 = ...
	
end;


// On every tick, submit entry stop
if (MarketPosition = 0) then begin

	if (enterLong = true) then
		// submit order for next bar (= next tick)
			
	if (enterShort = true) then 
		// submit order for next bar
	
end;
	
// Manage stop-losses
if (MarketPosition = 1) then begin

	// Submit Long stop here

end

else if (MarketPosition = -1) then begin 

	// Submit Short stop here

end;

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


Ok,

I implemented the code you are suggesting.. I agree its a good idea to make it as simple as possible to figure out the problem.

Here is the chart with circled red where it should have entered on the bars with red underlines in the circle, code is below also...

I am showing with 5 min bar charts and 60 Min bar chart

5 MIN BARS




60 MIN BARS





I used 1 dollar hardcoded for entrypice and exit price, since i am trading aapl.





variables:
TickSize (MinMove/PriceScale);



[IntrabarOrderGeneration = true]


// open new positions


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



Value1 = Text_New(Date, Time, Low-TickSize, NumToStr(CurrentShares, 0));

// manage open orders

if MarketPosition = 1 then begin
Sell("Profit Target") 300 Shares Next Bar at (EntryPrice + 1) Limit;
Sell("Stop Loss") 300 Shares Next Bar at (EntryPrice-1) Stop;
end;

Started this thread 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