NexusFi: Find Your Edge


Home Menu

 





Executing order on a real-time bar break


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one timothymhanna with 4 posts (0 thanks)
    2. looks_two teamaker with 3 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Arash with 1 posts (0 thanks)
    1. trending_up 2,568 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 8 posts
    2. attach_file 1 attachments




 
Search this Thread

Executing order on a real-time bar break

  #1 (permalink)
timothymhanna
Detroit, MI
 
Posts: 15 since Oct 2010
Thanks Given: 0
Thanks Received: 3

I'm using EasyLanguage in ApexTrader and have the following code example:

Inputs: StopAmt(20), ProfitAmt(50), TradeSize(2);
//Buy Order
[IntraBarOrderGeneration=True]
If High > High[1]
and Low > Low[1]
and Low[1] < Low[2]
and Low[2] < Low[3] then
Buy TradeSize Shares next bar at Market;
SetStopContract;
//Stop Loss
SetStopLoss(StopAmt);
//Profit Target
SetProfitTarget(ProfitAmt);

Is there any way to have a buy order execute once the current bar breaks the prior bar's high at the price of the prior bar's high? You can't do Buy this bar at Market.. And at close of this bar is not what I need. Is there maybe a way to say buy this bar at high of prior bar? Or maybe lagging the buy signal?

Thanks!

Tim

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Deepmoney LLM
Elite Quantitative GenAI/LLM
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
Better Renko Gaps
The Elite Circle
NexusFi Journal Challenge - April 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
36 thanks
NexusFi site changelog and issues/problem reporting
25 thanks
The Program
20 thanks
GFIs1 1 DAX trade per day journal
19 thanks
  #3 (permalink)
teamaker
Singapore+Singapore
 
Posts: 10 since Jun 2015
Thanks Given: 1
Thanks Received: 0


have you tried:

buy this bar on close

Reply With Quote
  #4 (permalink)
timothymhanna
Detroit, MI
 
Posts: 15 since Oct 2010
Thanks Given: 0
Thanks Received: 3


teamaker View Post
have you tried:

buy this bar on close

Buy this bar on close would not work because if the trigger was the break of the prior bar high (entry signal) and "this bar" closes 20 points above the trigger/signal/break of prior bar high, the order does not reflect the actual execution methodology. Basically, I see that a lot of times when I tested this bar on close, the trade was missed and not recording how it should actually be trading.

The prior instructions would be buy this bar on break of prior bar high if signal condition is true.

Any thoughts?

Reply With Quote
  #5 (permalink)
teamaker
Singapore+Singapore
 
Posts: 10 since Jun 2015
Thanks Given: 1
Thanks Received: 0

"Buy this bar on close would not work because if the trigger was the break of the prior bar high (entry signal) and "this bar" closes 20 points above the trigger/signal/break of prior bar high"

In other automated trading system, CLOSE OF THIS BAR should representing the existing real time price. Every new tick from market will form the new CLOSE OF THIS BAR. as soon as it break your trigger, the program should take action to buy/sell.

If it is not working for TS. another work around is use another strategy running on high frequency chart, like 1M to take the instruction from master strategy and open the order on next bar - which will be on min later.

Reply With Quote
  #6 (permalink)
timothymhanna
Detroit, MI
 
Posts: 15 since Oct 2010
Thanks Given: 0
Thanks Received: 3


teamaker View Post
"Buy this bar on close would not work because if the trigger was the break of the prior bar high (entry signal) and "this bar" closes 20 points above the trigger/signal/break of prior bar high"

In other automated trading system, CLOSE OF THIS BAR should representing the existing real time price. Every new tick from market will form the new CLOSE OF THIS BAR. as soon as it break your trigger, the program should take action to buy/sell.

If it is not working for TS. another work around is use another strategy running on high frequency chart, like 1M to take the instruction from master strategy and open the order on next bar - which will be on min later.

So just to confirm, "Close of this bar" when looking at a 1 hour chart, does not actually mean on the close of the 1 hour signal bar; it means on that bar but at the price on the break of the prior bar's high? My signals plot correctly, but the backtest plots at the actual close of the signal bar.

Reply With Quote
  #7 (permalink)
 Arash 
Los Angeles Ca USA
 
Experience: Intermediate
Platform: TradeStation
Trading: ES, ETF
Posts: 1 since Sep 2014
Thanks Given: 0
Thanks Received: 0

BuyPrice = High[1];
Buy this bar at BuyPrice +1 ticks stop;


BuyPrice = High[1];
Buy this bar at BuyPrice +1 points stop;


BuyPrice = High[1];
Buy this bar at BuyPrice or higher;

Reply With Quote
  #8 (permalink)
timothymhanna
Detroit, MI
 
Posts: 15 since Oct 2010
Thanks Given: 0
Thanks Received: 3


Arash View Post
BuyPrice = High[1];
Buy this bar at BuyPrice +1 ticks stop;


BuyPrice = High[1];
Buy this bar at BuyPrice +1 points stop;


BuyPrice = High[1];
Buy this bar at BuyPrice or higher;

ApexTrader (which uses tradestation programming) does not let me use exactly what you did above. I referenced the concept into the order though. Below is the code. Also, this chart includes the signals and the order executions from the backtest. I wrote notes on what it's doing and what it should be doing. Any idea how to make this work properly? Thanks!




//FL1 Clean INSIDE bar signal with clean pre bars
if High > High[1]
and Low >= Low[1]
and Low[1] < Low[2]
and High[1] <= High[2]
and Low[2] >= Low[3]
and High[2] >= High[3]
then
Buy next bar at High[1] stop;
SetBreakEven(50);
if Low < Low[1]
then
Sell next bar at Low[1] stop;
SetStopLoss(100);

//FH1 Clean INSIDE bar signal with clean pre bars
if Low < Low[1]
and High <= High[1]
and High[1] > High[2]
and Low[1] >= Low[2]
and High[2] <= High[3]
and Low[2] <= Low[3]
then
SellShort next bar at Low[1] stop;
SetBreakEven(50);
if High > High[1]
then
BuyToCover this bar on close;
SetStopLoss(100);

Reply With Quote
  #9 (permalink)
teamaker
Singapore+Singapore
 
Posts: 10 since Jun 2015
Thanks Given: 1
Thanks Received: 0

Please check help material of TS platform. please search:

Intrabar Order Generation.

The trader should enable that to allow trading strategy open order within a bar. there is also a setup for backtesting.

please have a try.

Reply With Quote




Last Updated on July 4, 2015


© 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