NexusFi: Find Your Edge


Home Menu

 





Fill Array with bar data if a condition is met


Discussion in MultiCharts

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




 
Search this Thread

Fill Array with bar data if a condition is met

  #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?
How to apply profiles
Traders Hideout
What broker to use for trading palladium futures
Commodities
MC PL editor upgrade
MultiCharts
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

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 Twitter 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,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

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 Twitter 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


© 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