NexusFi: Find Your Edge


Home Menu

 





Loop to Record Average Change in Bars


Discussion in MultiCharts

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




 
Search this Thread
  #1 (permalink)
 JHall65 
Denver Colorado
 
Experience: Intermediate
Platform: Multicharts
Trading: Forex
Posts: 23 since Apr 2013
Thanks Given: 3
Thanks Received: 2

I am trying to record the average difference in the highs of the last few bars. This is the code I have:

For Counter = BarsToAvg DownTo 1 Begin
BarDevi = (High[Counter] - High[Counter+1]);
TotalDevi = HighDevi + HighDevi[1];
Print(TotalDevi:6:6)
Print(Counter);
End;

Print(High[1]-High[2]:6:6);
Print(High[2]-High[3]:6:6);
Print(High[3]-High[4]:6:6);
Print(High[4]-High[5]:6:6);



The output I get for this is:
0.000000
4.00
0.000000
3.00
0.000000
2.00
0.000000
1.00
0.002500
0.000500
0.000700
0.000700

Why don't my numbers match up? Any help is greatly appreciated!


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trump Lands in Beijing on CPI Day: Iran Peace Expires To …
Prediction Markets & Event Contracts
CME Group CEO Calls CFTC-Approved Crypto Perps Dangerous …
Traders Hideout
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
The Backwardation Signal: How the CL Futures Curve Tells …
Commodities
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
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
Big Mike in Ecuador
2 thanks
CME Expands 24/7 Trading to WTI Crude Oil and Gold -- We …
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
kl610
London UK
 
Posts: 1 since Oct 2013
Thanks Given: 0
Thanks Received: 0

BarDevi = (High[Counter] - High[Counter+1]);
TotalDevi = HighDevi + HighDevi[1];

You was using BarDevi, then using HighDevi.
Should they be same? Otherwise BarDevi would be meaningless in this indicator.


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


You are printing TotalDevi, which in your code piece is always 0.
I guess the summation for TotalDevi should look something like in this code.
Set it to 0 before the loop and then with each loop add BarDevi to it.

 
Code
		TotalDevi = 0;
		For Counter = BarsToAvg DownTo 1 Begin
			BarDevi = (High[Counter] - High[Counter+1]);
			TotalDevi = TotalDevi + BarDevi;
			
			Print("High["+NumToStr(Counter, 0)+"]-High["+NumToStr(Counter+1, 0)+"]: ", BarDevi:6:6);
			Print("TotalDevi: ", TotalDevi:6:6);
		End;

		Print("High[1]-High[2]: ", High[1]-High[2]:6:6);
		Print("High[2]-High[3]: ", High[2]-High[3]:6:6);
		Print("High[3]-High[4]: ", High[3]-High[4]:6:6);
		Print("High[4]-High[5]: ", High[4]-High[5]:6:6);
Regards,
ABCTG


Follow me on X Reply With Quote




Last Updated on October 25, 2013


© 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