NexusFi: Find Your Edge


Home Menu

 





Cross Over Cross Under


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Joe50 with 4 posts (0 thanks)
    2. looks_two Quick Summary with 1 posts (0 thanks)
    3. looks_3 SMCJB with 1 posts (0 thanks)
    4. looks_4 ABCTG with 1 posts (1 thanks)
    1. trending_up 4,022 views
    2. thumb_up 2 thanks given
    3. group 5 followers
    1. forum 8 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
Joe50
HONOLULU
 
Posts: 23 since Feb 2019
Thanks Given: 6
Thanks Received: 3

Hello to all and thankyou for reading this;

I am trying to get this code to work using 5 minute bars:

If Low Crosses below Value1 and High Crosses above Value 2 then
Buy Next Bar at stop;

My problem is that the Low cross and the High cross do not occur at the same time

What I do not know how to do is to say is is the high crosses Value 2 , lets say at 10:55 then sell next bar if Low crosses below Value 1. So , let's say Value 2 occurs at 10:55 and value 1 occurs at 11:45; how is this coded ?

The key is that Value 2 must occur before value 1 is activated.

Thankyou


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The Ceasefire Curve: 2pct Peace by Next Week, 60pct by S …
Prediction Markets & Event Contracts
Khamenei Vetoes Uranium Transfer as Peace Odds Surge to …
Prediction Markets & Event Contracts
Day 96 Missiles Hit Kuwait and Bahrain: June 15 Peace at …
Prediction Markets & Event Contracts
Memorandum Watch: How the 60-Day MOU Framework Makes May …
Prediction Markets & Event Contracts
Zytrade: Devin Brady, CEO - Ask Me Anything (AMA)
Brokers
 
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)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT Stellar & Tradestation
Broker: Primarily Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals, U308 and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,241 since Dec 2013
Thanks Given: 4,584
Thanks Received: 10,523



Joe50 View Post
Hello to all and thankyou for reading this;

I am trying to get this code to work using 5 minute bars:

If Low Crosses below Value1 and High Crosses above Value 2 then
Buy Next Bar at stop;

My problem is that the Low cross and the High cross do not occur at the same time

What I do not know how to do is to say is is the high crosses Value 2 , lets say at 10:55 then sell next bar if Low crosses below Value 1. So , let's say Value 2 occurs at 10:55 and value 1 occurs at 11:45; how is this coded ?

The key is that Value 2 must occur before value 1 is activated.

Thankyou

Calculations are performed every bar, so if the two conditions don't occur on the same bar they will never trigger. So you need to keep a track of this occurring on previous bars. There's many different ways you can do this depending upon how recently/close together you want the two conditions to happen. One way would be to use the mro function for example
Value3 = MRO(Low crosses below value1, 10, 1);
Value4 = MRO(High crosses above value2, 10, 1);

If value3 > -1 and value4 > -1 then buy next bar at market;
will issue a buy if order if both conditions have been met in the last 10 bars.


Reply With Quote
  #4 (permalink)
 SidewalkAerobics 
Los Angels
 
Experience: Intermediate
Platform: MultiChart
Trading: Emini ES
Posts: 115 since Aug 2018
Thanks Given: 173
Thanks Received: 72


Joe50 View Post
Hello to all and thankyou for reading this;

I am trying to get this code to work using 5 minute bars:

If Low Crosses below Value1 and High Crosses above Value 2 then
Buy Next Bar at stop;

My problem is that the Low cross and the High cross do not occur at the same time

What I do not know how to do is to say is is the high crosses Value 2 , lets say at 10:55 then sell next bar if Low crosses below Value 1. So , let's say Value 2 occurs at 10:55 and value 1 occurs at 11:45; how is this coded ?

The key is that Value 2 must occur before value 1 is activated.

Thankyou

You can create a variable, Keep2, to store a value. Clear it before 1055, then set it at 1055 if your condition occurs. At 1145, you will know if the condition occurred at 1055. Perhaps this could be done with less lines of code, but it will work.

Var: Keep2(0);

if time=1050 then Keep2=0; //reset Keep2

if time=1055 and high[0] crosses over Value2
then Keep2 =1; //set Keep2 if condition 1 occurs

if time=1145 and low[0] crosses Value1 and Keep2=1
then Buy 1 contract next bar at market;// enter if condition 1 and condition 2 both occurred


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

Hi Joe50,

as the other posts indicate you will likely have to split your condition into separate checks. One idea could be to store the value of CurrentBar each time the High crosses Value2. At the moment the low crosses Value1 you can check the value of CurrentBar agains the value stored in that variable and allow the entry if the cross occurred within X bars ago.

Regards,

ABCTG


Joe50 View Post
Hello to all and thankyou for reading this;

I am trying to get this code to work using 5 minute bars:

If Low Crosses below Value1 and High Crosses above Value 2 then
Buy Next Bar at stop;

My problem is that the Low cross and the High cross do not occur at the same time

What I do not know how to do is to say is is the high crosses Value 2 , lets say at 10:55 then sell next bar if Low crosses below Value 1. So , let's say Value 2 occurs at 10:55 and value 1 occurs at 11:45; how is this coded ?

The key is that Value 2 must occur before value 1 is activated.

Thankyou


Follow me on X Reply With Quote
Thanked by:
  #6 (permalink)
Joe50
HONOLULU
 
Posts: 23 since Feb 2019
Thanks Given: 6
Thanks Received: 3


ABCTG View Post
Hi Joe50,

as the other posts indicate you will likely have to split your condition into separate checks. One idea could be to store the value of CurrentBar each time the High crosses Value2. At the moment the low crosses Value1 you can check the value of CurrentBar agains the value stored in that variable and allow the entry if the cross occurred within X bars ago.

Regards,

ABCTG


Thankyou for you input, it is greatly appreciated I am still reviewing it.


Reply With Quote
  #7 (permalink)
Joe50
HONOLULU
 
Posts: 23 since Feb 2019
Thanks Given: 6
Thanks Received: 3

Still looking at it.

Thankyou for everyone's reply.


Reply With Quote
  #8 (permalink)
Joe50
HONOLULU
 
Posts: 23 since Feb 2019
Thanks Given: 6
Thanks Received: 3

It works after a few minor adjustments on my end. The code is perfect.

Thankyou !


Reply With Quote
  #9 (permalink)
Feazy
Zug, Switzerland
 
Posts: 4 since Jul 2020
Thanks Given: 0
Thanks Received: 0

Hi Joe,

how did u manage to solve your problem at the end? Would be interesting to see how u managed to adjust to code

F


Reply With Quote




Last Updated on August 31, 2020


© 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