NexusFi: Find Your Edge


Home Menu

 





Fill Array with bar data if a condition is met


Discussion in MultiCharts

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




 
Search this Thread
  #1 (permalink)
eros1973ms
florence
 
Posts: 27 since Oct 2011
Thanks Given: 3
Thanks Received: 6

Hi all,

I am facing a bit of difficulty in understanding how to manage arrays...hope you can help.
I would like to store in an array the data of the bar where a variable was true (the last 10 times).
I mean, suppose a var is true if I find a divergence... I would like to store in the array the (Date, time, Open, High, Low, Close) of that bar...and do that for the 10 most recent bars where "myvar" was true.

So I would set up an array with 10 rows and 6 colums...but I am not able to write the routing to fill the data in the array.

can you please help?

thanks a lot!
ciao


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
April CPI Preview: +3.7% YoY Expected at 8:30 AM ET -- C …
Traders Hideout
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
Beijing Summit Closes: Xi Pledges Hormuz Help -- $1.14B …
Prediction Markets & Event Contracts
$500M Riding on World Cup 2026: France/Spain Co-Favored …
Prediction Markets & Event Contracts
Iran Airspace Collapses 18 Points to 15.5% While Hormuz …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
16 thanks
Darmok and Jalad at Tanagra
3 thanks
CME Expands 24/7 Trading to WTI Crude Oil and Gold -- We …
1 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643

Hi eros1973ms,

it might be simpler to start out with one dimensional arrays at fist and once you have the logic correct, you can always convert it to a multi dimensional array.

You will most likely have to use a FIFO approach i.e. keep track of how many values you have in your array already and start overwriting the oldest value in case a new one should be stored (once your array is fully populated).

Regards,

ABCTG


Follow me on X Reply With Quote
  #3 (permalink)
eros1973ms
florence
 
Posts: 27 since Oct 2011
Thanks Given: 3
Thanks Received: 6



ABCTG View Post
Hi eros1973ms,

it might be simpler to start out with one dimensional arrays at fist and once you have the logic correct, you can always convert it to a multi dimensional array.

You will most likely have to use a FIFO approach i.e. keep track of how many values you have in your array already and start overwriting the oldest value in case a new one should be stored (once your array is fully populated).

Regards,

ABCTG

thanks ABCTG for your advice. re-thinking to my question, I think that my problem actually is not with the arrays (...not yet ) but regarding how to get the values when my condition was true.
how do you get the high of the bar where myVar was true last time? and the time before?

thanks


Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,643

Hi eros1973ms,

as code in Multicharts is executed bar by bar starting with the first bar on the chart (as determined by the max bars setting for the study), you can simply store the values on each bar when your condition is true. This is much more effective (performance wise) than looking back for the last times your conditions have been true.

Regards,

ABCTG


eros1973ms View Post
thanks ABCTG for your advice. re-thinking to my question, I think that my problem actually is not with the arrays (...not yet ) but regarding how to get the values when my condition was true.
how do you get the high of the bar where myVar was true last time? and the time before?

thanks


Follow me on X Reply With Quote
  #5 (permalink)
eros1973ms
florence
 
Posts: 27 since Oct 2011
Thanks Given: 3
Thanks Received: 6


ABCTG View Post
Hi eros1973ms,

as code in Multicharts is executed bar by bar starting with the first bar on the chart (as determined by the max bars setting for the study), you can simply store the values on each bar when your condition is true. This is much more effective (performance wise) than looking back for the last times your conditions have been true.

Regards,

ABCTG

thanks ABCTG!


Reply With Quote




Last Updated on July 18, 2018


© 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