NexusFi: Find Your Edge


Home Menu

 





How get the time of a past bar in powerlanguage?


Discussion in EasyLanguage Programming

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




 
Search this Thread

How get the time of a past bar in powerlanguage?

  #1 (permalink)
 fjgaspar 
Sevilla + Spain
 
Experience: Beginner
Platform: Multicharts
Trading: SP
Posts: 21 since May 2016
Thanks Given: 3
Thanks Received: 3

Hi,

I'm developing an indicator for Multucharts.NET with Powrlanguage. I have a 5 minutes chart, and I need to do the following in calcbar() method.

Lets say it is 9:00 AM. The time of current bar is 9:00 AM. I need to sum the close price of all 9:00AM bars of last 10 days.

I have the following code:

Sum = 0
for (count = 1; count < 2880; count++){

if (bars.time[count] == bars.time[0]){
Sum = Sum + bar.close[count]
}
}

Then I want to plot SUM. But it plots 0. Doesn't work. The logical condition under the if appears not to be true ever.

How could I make it work?

Note: 2280 because each day has (24 * 12) 5 minute bars, and I want 10 days back, which gives 2880 bars to analyze.

Thanks

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Tao te Trade: way of the WLD
22 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


fjgaspar,

you start with count = 1, so your condition if (bars.time[count] == bars.time[0]) can never become true.
You might want to check (using the Output for example) what values Bars.Time[0] holds.

Regards,

ABCTG

Follow me on Twitter Reply With Quote




Last Updated on November 7, 2016


© 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