NexusFi: Find Your Edge


Home Menu

 





Close a position in Range Bar at specific time


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,722 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?
The June 15 Resolution Trap: Irans Agreed Text Still Pri …
Prediction Markets & Event Contracts
MyForexFunds Begins Returning Frozen Funds After CFTC Ca …
Funded Trading Evaluation Firms
Rubios Good News Within Hours and the 30-Day Math: Why H …
Prediction Markets & Event Contracts
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
Trump Truth Social Fires Hormuz From 10% to 59% -- Arsen …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
197 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642


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,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

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