NexusFi: Find Your Edge


Home Menu

 





MA into array


Discussion in MultiCharts

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




 
Search this Thread

MA into array

  #1 (permalink)
no erocla
turin italy
 
Posts: 96 since May 2013
Thanks Given: 43
Thanks Received: 4

Hi all, i need help to develop e simple indicator in power language.

I would like to build a For Cycle that return the lowest value between many moving average, i build something like it:

 
Code
                            
var: min(0);
array: 
val[20](0);

For 
value88 1 To 20  begin

value4 
value4+5;
val[value88] = Average(c,value4 );
if (
val[value88]<minthen
min 
val[value88];

End;
plot1(min); 
It should plot just the lowest value between Average(c,5) , average(c,10), average(c,15) etc... but it doesnt work and cycle continue without an end.

Some help about ? thank you very much anyway !

Regards

No Erocla

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Trade idea based off three indicators.
Traders Hideout
Cheap historycal L1 data for stocks
Stocks and ETFs
How to apply profiles
Traders Hideout
 
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,436 since Apr 2013
Thanks Given: 482
Thanks Received: 1,629

no erocla,

you could save a lot of time in your programming (especially when you have to debug code) if you'd use proper
variable names and comments. This makes code much easier to read and is a huge help in case you share code with others (post it on forums for example) or come back to a code after a couple of years.
The code below would do what you requested, but doesn't use an array:


 
Code
Variables:
	ii			(0),
	CurrentMA		(0),
	MALength		(0),
	LowestMAValue		(0);
	
//reset the values before the loop	
LowestMAValue = 999999;
MALength = 0;

//loop through 20 MAs and find the lowest one	
for ii = 1 to 20
begin
	MALength = MALength + 5;
	
	CurrentMA = Average(Close, MALength);
	
	if CurrentMA < LowestMAValue then
		LowestMAValue = CurrentMA;
end;

Plot1(LowestMAValue, "LowestMAValue");
Regards,

ABCTG

Follow me on Twitter Reply With Quote




Last Updated on December 19, 2013


© 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