NexusFi: Find Your Edge


Home Menu

 





Accessing Bars in Multicharts Easy Language


Discussion in MultiCharts

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




 
Search this Thread

Accessing Bars in Multicharts Easy Language

  #1 (permalink)
aga17
Vancouver Canada
 
Posts: 3 since Jun 2012
Thanks Given: 0
Thanks Received: 0

So I'm building a indicator that needs to check whether a lower high or higher was initiated first on a double switched bar. I was able to get this working for real time data but for the historical data (non real time) I am unable to access the individual ticks (from what I understand).

So i have decided to use a second data stream at a higher resolution (more bars) to determine what was triggered first on the double switch. However, when I compile my code it seems to get the barnumber of the first double switch right so I can simply step back resolution2/resolution1 bars back and see how the price changes to determined what was triggered first. However, it seems to show me the wrong barnumbers for the remaining double switches (it is off by 10 bars when using data1=30 days and data2=6 days). Here is the code I'm currently running. Any help would be greatly appreciated thanks.



//------------------------------------------------------------------------------------ //Double Switch statements (Historical)
if (GetAppInfo(aiRealTimeCalc)= 0) then begin
if ((High of Data1 >= (High [1] of Data1 + HigherHigh)) of Data1 and (Low of Data1 <= (Low[1] of Data1 - LowerLow)) of Data1) then begin // Check if a higher high and lower low are hit on the same bar (double switch)
BarTime = Time of Data1;
PrevTime = Time[1] of Data1;

Resolution2 = barinterval Data2;
Resolution1 = barinterval Data1;

BarCount = Resolution1/Resolution2; ;
D2_Bar = (BarNumber* BarCount);

Print ("D2_Bar: ", D2_Bar);
for x=BarCount downto 1 begin
D2_High = High[x] of Data2;
D2_Low = Low[x] of Data2;

Print ("NewBar: :", (D2_Bar - X));

if ((D2_High>= (High[1] + HigherHigh)) and (D2_Low > (Low[1]- LowerLow) and new_High = False and new_Low = False)) then begin //New High
new_High = True;
RefHigh = High;
Print ("New High: ", D2_High:1:5);
end;

if(D2_Low <= (Low[1] - LowerLow)) and (D2_High < (High[1]+ HigherHigh) and new_Low = False and new_High = False) then begin // New Low
new_Low = True;
RefLow = Low;
Print ("New Low: ", D2_Low:1:5);
end;
//------------------------------------------------------------------------------Double Switch
if ((D2_Low <= (Low[1] - LowerLow) and new_High = True) and newLH=False and newHL= False) then begin //New Low after High
newHL = True;
Print (" New HL: ");
end;

if ( ((D2_High >= (High[1] + HigherHigh))and new_Low = True) and newHL=False and newLH=False) then begin //New High after Low
newLH = True;
Print (" New LH: ");
end;

end;
end;
end;


Also, the code seems to run multiple times for the same bar. It seems as if it runs the same thing for the number of bars from data2 between the current bar of data1 and the previous bar on it.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
 
  #2 (permalink)
aga17
Vancouver Canada
 
Posts: 3 since Jun 2012
Thanks Given: 0
Thanks Received: 0

So I have been able to pinpoint the issue to using multiple time frames. I am using a for loop to check the HLC values on the higher resolution chart (data2). I've noticed that the code executes for the number of bars that are between 2 bars on data1 (i.e. for data1 = 30 days and data2= 2 days, the code will be executed 15 times for the one bar). This throws all of the barnumbers off, and hence gives me incorrect values. Any help would be appreciated.

thanks

Reply With Quote
  #3 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690



aga17 View Post
So I have been able to pinpoint the issue to using multiple time frames. I am using a for loop to check the HLC values on the higher resolution chart (data2). I've noticed that the code executes for the number of bars that are between 2 bars on data1 (i.e. for data1 = 30 days and data2= 2 days, the code will be executed 15 times for the one bar). This throws all of the barnumbers off, and hence gives me incorrect values. Any help would be appreciated.

I know some PowerLanguage but have no idea what you're talking about. I don't even get your very first line:


aga17 View Post
So I'm building a indicator that needs to check whether a lower high or higher was initiated first on a double switched bar.

What is "initiated first on a double switched bar"? If this is your goal of this indicator, I don't know what you're trying to accomplish.


aga17 View Post
Also, the code seems to run multiple times for the same bar. It seems as if it runs the same thing for the number of bars from data2 between the current bar of data1 and the previous bar on it.

This might be due to your loop?


Can you tell what your goal is?
Also, try using the [ code ] and [ / code ] tags next time when posting code - that makes it a lot better readable (click on the # in the post editor).

Reply With Quote
  #4 (permalink)
aga17
Vancouver Canada
 
Posts: 3 since Jun 2012
Thanks Given: 0
Thanks Received: 0

I've been able to pinpoint the issue to the For loop. This is a small part of a larger indicator that I am trying to implement. So when I get a new bar that has a higher high and lower low than the previous bar the indicator is triggered in order to determine which event occurred first.

For example, if High[1] = 20 and Low[1] =18, and High=21 and low=17 the indicator is triggered. (Note: this is only for historical data on the chart, not for real time data). Thus i can only see the new higher high and lower low on the bar but can't see which one happened first. To overcome this I am using a second data stream with a higher resolution (i.e. more bars) to determine which event occurred first.

So for example if I use a resolution of 2mins on data2 and 30 mins for data1, I will have 15 bars inbetween the data interval of data1 to trace through the higher resolution bars to determine if a higher high or lower low was triggered on a bar that has both.

Thanks

Reply With Quote




Last Updated on June 30, 2012


© 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