NexusFi: Find Your Edge


Home Menu

 





Close a position in Range Bar at specific time


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #1 (permalink)
ewind
Hong Kong
 
Posts: 4 since Aug 2015
Thanks Given: 0
Thanks Received: 0

My strategy is based on range bar chart. How can I close a position at a specific time, such as 10 minutes before market close, in which the range bar may not completed at that specific time? I have tried turning on the intrabarordergeneration and added a time chart as subchart as data 2, but still no luck.

Appreciate with your help.

Thanks


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Al Arabiya: US-Iran Draft Deal Within Hours Contains Hor …
Prediction Markets & Event Contracts
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
Kalshi Sets $4.13B All-Time Weekly Record as Polymarket …
Prediction Markets & Event Contracts
I Have a Thing Called Iran -- Trump Stays in DC as Airsp …
Prediction Markets & Event Contracts
CFTC Requests Tag 50 Trader Identity Data From CME and I …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Hello Im new here
5 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639


ewind,

you don't need a second datastream, but it does require intrabar order generation. For historical exits you can use the bar tick by tick timestamp that you can access, but for realtime exits you'll have to use your computer clock.

Regards,
ABCTG


ewind View Post
My strategy is based on range bar chart. How can I close a position at a specific time, such as 10 minutes before market close, in which the range bar may not completed at that specific time? I have tried turning on the intrabarordergeneration and added a time chart as subchart as data 2, but still no luck.

Appreciate with your help.

Thanks


Follow me on X Reply With Quote
  #4 (permalink)
ewind
Hong Kong
 
Posts: 4 since Aug 2015
Thanks Given: 0
Thanks Received: 0

Dear ABCTG,

I am new to easy language therefore I hope you don't mind my stupid questions.

Historical Exits: -> Would you elaborate how to access the tick timestamp?
Realtime Exits: -> I guess I can use currentTime instead of time in my coding. However, is that mean I have to switch currentTime/Time between backtest/SA?

Here is how the code look like for single datastream:

condition1 = Time >= CalcTime(SessionEndTime, MinBeforeClose ) and Time < SessionEndTime;

if condition1 then
if marketposition(0) = -1 then
buytocover next bar at market
else if marketposition(0) = 1 then
sell next bar at market;


Thank you very much.


Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

ewind,

check out this link:
https://www.multicharts.com/trading-software/index.php/Bar_Magnifier

You can let the code detect if it's currently historical data or realtime data. Check out LastbarOnchart and airealtimecalc for example to accomplish this.

Regards,

ABCTG


Follow me on X Reply With Quote
  #6 (permalink)
ewind
Hong Kong
 
Posts: 4 since Aug 2015
Thanks Given: 0
Thanks Received: 0

Thanks ABCTG. After further study, I find that my original code works for real time exit, but the actually exit time is different from what it shown in performance report.

For historical exit, I turned on the "Enable access to intra-bar time...", it seems returning what I expected (sometime still close session in next day, very strange), although it take much much longer to complete the back-test.

Thank you very much


Reply With Quote




Last Updated on January 26, 2016


© 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