NexusFi: Find Your Edge


Home Menu

 





Easylanguage Intrabarordergeneration Problem (Signal too late)


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,622 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
luki
Berlin, Germany
 
Posts: 1 since Jan 2022
Thanks Given: 0
Thanks Received: 0

Hello,
i am new to the forum and this is my first post.
I want to write a simple strategy in EL but i am having some problems.
The entry comes 1 bar too late, so either the intrabarordergeneration or my bar referencing is causing problems.


As this is my first post i can not send a screenshot unfortunately.


Entry rules for short:

When a bar closes above the previous bars high, i want to go short as soon as the low of the bar that closed higher breaks during the next candle. I dont want to make the trade if the trigger candle is an outside candle or if the open of the trigger candle is outside of the previous candle.

So actually it is a 3 bar pattern:

Bar 1: doesnt really matter
Bar 2: close of bar 2 has to be greater than the high of bar 1
Bar 3: This is the trigger candle. I want this candle to break the low of bar 2. Thats when i want to sell short. However, the high of bar 3 has to be lower than the high of bar 2 and the open of bar 2 has to be inside of bar 2īs range.

The logic is the exact opposite for long trades.

Seems like i am having some trouble with the EL logic about referencing the bars. I am sometimes not sure at what point in time Tradestation reads my code so i am having problems referencing the correct bar. Maybe someone can help me out.

This is the code:

 
Code
 
[Intrabarordergeneration = true]


Variables:
bool shortCondition								(false),
bool longCondition 								(false),
intrabarpersist double TriggerPriceShort		(0),
intrabarpersist double TriggerPriceLong			(0),
double oneTick 									(0);


shortCondition = Close[1] > High[2] and Open < High[1] and Open > Low[1] and High < High[2] ;
longCondition = Close[1] < Low[2] and Open < High[1] and Open > Low[1] and Low > Low[1]  ;


once 
begin 
	oneTick = MinMove / PriceScale ;
end ;


//checking if the previous bar has closed and finding the trigger prices

if BarStatus( 1 ) = 2 then 
begin

	TriggerPriceShort = Low[1] - oneTick;
	TriggerPriceLong = High[1] + oneTick;

	// entry
	if Marketposition = 0 then begin

		if shortCondition and Close <= TriggerPriceShort then
			Sell Short ( "Smash Day Short" ) 2000 shares next bar at market 
		else 
		if longCondition and Close >= TriggerPriceLong then 
			Buy ( "Smash Day Long" ) 2000 shares next bar at market;
	end;
end;


// profit target
if Marketposition <> 0 then Begin
	Setprofittarget (800);
	Setexitonclose;
end;

Thanks for your help


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Iran Update May 8: Still Reviewing MOU, Demands Reparati …
Traders Hideout
ATFX Suspends Prop Trading Unit ATFunded -- Full Review …
Funded Trading Evaluation Firms
Election Sunday Resolves: Peru Heads to Runoff at 42pct, …
Prediction Markets & Event Contracts
Powell in 48 Hours: Word Markets Give 78% on Inflation, …
Prediction Markets & Event Contracts
UMA Votes Tonight: Polymarkets $80M Strategy Bitcoin Bat …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
196 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

Hello luki,

welcome to NexusFi. You only evaluate your order conditions at the end of a bar, since you placed them inside the "if BarStatus( 1 ) = 2 then" conditional branch.
The order would then get filled at the open of the next bar, if the conditions for an entry are present.

Regards,

ABCTG


luki View Post
Hello,
i am new to the forum and this is my first post.
I want to write a simple strategy in EL but i am having some problems.
The entry comes 1 bar too late, so either the intrabarordergeneration or my bar referencing is causing problems.


As this is my first post i can not send a screenshot unfortunately.


Entry rules for short:

When a bar closes above the previous bars high, i want to go short as soon as the low of the bar that closed higher breaks during the next candle. I dont want to make the trade if the trigger candle is an outside candle or if the open of the trigger candle is outside of the previous candle.

So actually it is a 3 bar pattern:

Bar 1: doesnt really matter
Bar 2: close of bar 2 has to be greater than the high of bar 1
Bar 3: This is the trigger candle. I want this candle to break the low of bar 2. Thats when i want to sell short. However, the high of bar 3 has to be lower than the high of bar 2 and the open of bar 2 has to be inside of bar 2īs range.

The logic is the exact opposite for long trades.

Seems like i am having some trouble with the EL logic about referencing the bars. I am sometimes not sure at what point in time Tradestation reads my code so i am having problems referencing the correct bar. Maybe someone can help me out.

This is the code:

 
Code
 
[Intrabarordergeneration = true]


Variables:
bool shortCondition								(false),
bool longCondition 								(false),
intrabarpersist double TriggerPriceShort		(0),
intrabarpersist double TriggerPriceLong			(0),
double oneTick 									(0);


shortCondition = Close[1] > High[2] and Open < High[1] and Open > Low[1] and High < High[2] ;
longCondition = Close[1] < Low[2] and Open < High[1] and Open > Low[1] and Low > Low[1]  ;


once 
begin 
	oneTick = MinMove / PriceScale ;
end ;


//checking if the previous bar has closed and finding the trigger prices

if BarStatus( 1 ) = 2 then 
begin

	TriggerPriceShort = Low[1] - oneTick;
	TriggerPriceLong = High[1] + oneTick;

	// entry
	if Marketposition = 0 then begin

		if shortCondition and Close <= TriggerPriceShort then
			Sell Short ( "Smash Day Short" ) 2000 shares next bar at market 
		else 
		if longCondition and Close >= TriggerPriceLong then 
			Buy ( "Smash Day Long" ) 2000 shares next bar at market;
	end;
end;


// profit target
if Marketposition <> 0 then Begin
	Setprofittarget (800);
	Setexitonclose;
end;

Thanks for your help


Follow me on X Reply With Quote
Thanked by:




Last Updated on February 1, 2022


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