Easylanguage Intrabarordergeneration Problem (Signal too late) - futures io
futures io



Easylanguage Intrabarordergeneration Problem (Signal too late)


Discussion in EasyLanguage Programming

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




Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Easylanguage Intrabarordergeneration Problem (Signal too late)

(login for full post details)
  #1 (permalink)
luki
Berlin, Germany
 
 
Posts: 1 since Jan 2022
Thanks: 0 given, 0 received

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 futures io?
help with take profit several targets
TradeStation
Big Mo Indicator for NT8
NinjaTrader
Multi Time Frame High/Low/Median levels
NinjaTrader
How do I create Strategy with the Second Entry indicator
NinjaTrader
Market on Close data within IB
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Is anyone actually making money?
123 thanks
ApexTraderFunding.com experience and review
11 thanks
Artificial Intelligence (AI) and Chat GPT
7 thanks
Dax market profile (FDAX, TPO)
7 thanks
Want your NinjaTrader indicator created, free?
7 thanks
 
(login for full post details)
  #2 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,360 since Apr 2013
Thanks: 426 given, 1,578 received

Hello luki,

welcome to futures.io. 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 Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Easylanguage Intrabarordergeneration Problem (Signal too late)


Last Updated on February 1, 2022


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2023 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
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.
no new posts