NexusFi: Find Your Edge


Home Menu

 





Obtain the MOST RECENT between the yesterday HIGH and LOW in a signal


Discussion in MultiCharts

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




 
Search this Thread

Obtain the MOST RECENT between the yesterday HIGH and LOW in a signal

  #1 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25

Hello everyone,

for a new strategy currently under development I need to obtain wich is the MOST RECENT price of a future between the yesterday HIGH and LOW (probably between dailyHigh[1] and dailyLow[1]).
I surfed the web and I didn't find any quick solution or reserved words to obtain the exact time when the dailyHigh[1] and dailyLow[1] so apparently there's not an easy way to calculate this (unless you know eheh please tell me).

Anyway I was thinking to create a code in my strategy that is updating the HIGH and the LOW of the day on every bar and then save the related time_s of the bar and then at the end of day it compares the time to establish wich is the most recent value in order to use it in the morning at the session open to made some calculations to obtan some price levels for my strategy.

My idea is this:

 
Code
        variables:

	YMax(0), // Yesterday MAX = daily High of yesterday
	YMin(0), // Yesterday Min = daily low of yesterday
	timeYMax(0), // Yesterday MAX = daily High of yesterday
	timeYMin(0), // Yesterday Min = daily low of yesterday
	todayMax(0),
	todayMin(0),

        MostRecentPrice(0) // 

// save the daily high time and daily low time

if dailyhigh > dailyhigh[1] then begin

	 todayMax = dailyhigh;
	 timeYMax = time_s;
	 
	 end;
if dailylow > DailyLow[1] then begin

	 todayMin = dailylow;
	 timeYMax = time_s;

end;

// calculate the MostRecentPrice for the next day at the 22:30 as the session ends 22:00
if time = 2230 then begin

	YMax = todayMax;
	Ymin = todayMin;

	if timeYMax > timeYMin then MostRecentPrice= YMax else MostRecentPrice= YMin;

end;

So basically after the session close at 22:00 I'm going to make the comparison at 22:30 to discover wich is the MOST RECENT price of the DAX future between the yesterday HIGH and LOW. Then in the morning at the session open at 01:15 I can use the MostRecentPrice to make some calculations.

So this is the idea but I'm not sure if it is the Best solution for this problem.

What do you think? Is this the easies to way to achive my purpose or is there an easier way and/or keywords reference (that I wasn't able to find at FIO or surfing the net).

thanks,

David

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
What broker to use for trading palladium futures
Commodities
 
  #2 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25

UPDATE:

My code seems to do not work correctly. I'm trying to use this code

https://www.multicharts.com/discussion/viewtopic.php?f=1&t=10154

I was able to plot high and low of the previous day.... now I have to modify it to discover what is the most recent between them.

Reply With Quote
  #3 (permalink)
Dvdkite
Trieste Italy
 
Posts: 162 since Feb 2018
Thanks Given: 131
Thanks Received: 25


Ok so I'm using this code from the link above and it works perfectly to obtain the Min and Max value reached during the previous day:

 
Code
// return the high and low of the previous  session  day

Var:
Intrabarpersist  Barcount (0),
Intrabarpersist CountStart (false),
intrabarpersist Counting (true),
Intrabarpersist BarNum (0),
Intrabarpersist Dayhigh (0),
Intrabarpersist Daylow (0);

// count the numbers of bars during a day
If counting = true then begin
   if time = 1700 and countstart = false then begin
       Barcount = 0;
       countstart = True;
       BarNum = Barnumber;
   end;
   
   If countstart = True and barnum <> Barnumber then begin
      Barcount = barcount +1;
      BarNum = Barnumber;
      If time = 1700 then begin
         Counting = false;
        Print (Barcount:0:0);
      end;
   end;
end; 

 //counting as been done and I know how many bars compose my day
 // Now, found the highest and the lowest price for the previous barcount bars.
 // This operation is done only when the day as been terminated

If counting = false and time = 1700 then begin 
   Dayhigh = highest(high,Barcount);
   DayLow = lowest(low, barcount);
   Print ( dayhigh:5:5, "  " , daylow:5:5);
end;

Then I modified the last "if" part including a FOR cicle to obtain in with number of bar occured the todayMax and todayMin :

 
Code
If counting = false and time = 2200 then begin 
   Dayhigh = highest(high,Barcount);
   DayLow = lowest(low, barcount);
   Print ( dayhigh:5:5, "  " , daylow:5:5);
               
   for ii = 1 to Barcount begin

      if  highest(high,ii) > todayMax then begin
         
         todayMax = highest(high,ii);
         barYMax = Barcount ;
          
      end;
             
      if  lowest(low, ii) < todayMin then begin
         
         todaymin = lowest(low, ii);
         barYMin = Barcount ; 

      end;
   end;         
   print(NewLine," ----------Max e Min DATE: ", FormatDate("dd-MM-yyyy", ELDateToDateTime(Date))," -- Time ",NumToStr(time,0), " ------ ");          
   print(NewLine," barYMax = ", NumToStr(barymax,0));
   print(" barYMin = ", NumToStr(barymin,0));     
   
   
end;
I can't manage to have it working as it should as the login seems correct.

I'm struggling to find a way to know wich is the most RECENT between the DayHigh and DayLow of the previous day.
I need tha latest max or min of the previous day to calculate some levels in the morning at the session open.
I thought that by using a Barcount and save it when the min or the max condition is met could be a solution but it is not actually.

This is the output in powerlanguage MC editor:

 
Code
----------Max e Min DATE: 28-03-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
11570.00000  11456.50000

 ----------Max e Min DATE: 29-03-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
11733.50000  11555.50000

 ----------Max e Min DATE: 01-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
11829.50000  11675.00000

 ----------Max e Min DATE: 02-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
11997.50000  11784.00000

 ----------Max e Min DATE: 03-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12053.00000  11931.00000

 ----------Max e Min DATE: 04-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12047.00000  11989.50000

 ----------Max e Min DATE: 05-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12028.50000  11962.00000

 ----------Max e Min DATE: 08-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12014.50000  11866.50000

 ----------Max e Min DATE: 09-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
11972.00000  11866.50000

 ----------Max e Min DATE: 10-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
11992.00000  11871.00000

 ----------Max e Min DATE: 11-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12059.00000  11916.00000

 ----------Max e Min DATE: 12-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12061.50000  12006.00000

 ----------Max e Min DATE: 15-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12143.00000  12035.50000

 ----------Max e Min DATE: 16-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12221.00000  12111.00000

 ----------Max e Min DATE: 17-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12292.00000  12124.00000

 ----------Max e Min DATE: 18-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12292.00000  12206.00000

 ----------Max e Min DATE: 23-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12379.00000  12216.50000

 ----------Max e Min DATE: 24-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12358.00000  12261.00000

 ----------Max e Min DATE: 25-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12349.50000  12275.00000

 ----------Max e Min DATE: 26-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12396.50000  12283.50000

 ----------Max e Min DATE: 29-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12395.00000  12295.00000

 ----------Max e Min DATE: 30-04-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
12420.50000  12276.50000

 ----------Max e Min DATE: 02-05-2019 -- Time 2200 ------ 

 barYMax = 247
 barYMin = 0
Clearly there's something wrong as you can see the in the output and I have several days with the same barYmax and that's almost impossible (it really uncommon that you have the max of the day at the same barnumber for three days in row).

Any ideas?

Reply With Quote




Last Updated on May 3, 2019


© 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