Claude
Jun 7 2005, 07:54 AM
Hello Chris
I have recently asked for a formula that would cycle. An example is it would count to five. Once it reached five it would start over. The amount it counted would be variable. So if the number three would be put in the formula which count 123 123 123. I just want to let you know I did a little bit of experimenting and looked around. And came up with the answer.
Reset:=20;
Cycle:=(1+Prev)-If(PREV=Reset,Reset,0);
It was that simple. The example I posted will count to 20 and start over
alanluisa
Dec 5 2005, 12:41 AM
do you have a formula for this?
Is it for counting bars (say every 20 bars?)
If so, how is it indicated on the chart?
alan
cskidmore
Dec 5 2005, 11:11 AM
Hello,
Here's an indicator file with Claude's formula. You can visually see what the code does by attaching the indicator to the chart. Basically, it counts to 20 and then starts over. An example application would be to use it to mark high/low "cycles" in the market such as every 30 bars or whatever you determine the high/low cycle may be.
Regards,
Chris
Chris
I downloaded this indicator, but when I plot it just open the new frame and can't see the indicator
cskidmore
Apr 1 2009, 07:00 PM
Hi Ric,
Please take a look at the code. Anywhere in the code that you see PREV, try replacing it with PREV(0) (that's a zero in the ()). Then, save the indicator and test it again. Let me know if that resolves the issue.
Regards,
Chris
Thank you Chris
It works now

It would be better with a customizable starting point, and as a trading system with trends enabled it could be the indicator I need
cskidmore
Apr 2 2009, 10:12 AM
Hi Ric,
You might want to search for a similar indicator made by Bemac. I think he *might* have created something similar with a starting date/time. You may want to add my name username to that search or even "Vadim" (he was someone that worked for VT long ago that build a few indicators). Searching for "sine wave" may also yield some results.
Regards,
Chris
Thank you Chris
I did it, found something I'll check
In the process found old other indicator wich shows me an error when plotting
in formula error seems to be with this statement:
HiBarNum := valuewhen(1,Barnum-1=LastValue(EndBar),(Barnum-1)-hhvbars(High ,Ref(BarsInMonth,-1) )+1);
cursor marks "LastValue(EndBar)" just between Value and (
any idea??
cskidmore
Apr 2 2009, 11:38 AM
Hello,
QUOTE
In the process found old other indicator wich shows me an error when plotting
in formula error seems to be with this statement:
HiBarNum := valuewhen(1,Barnum-1=LastValue(EndBar),(Barnum-1)-hhvbars(High ,Ref(BarsInMonth,-1) )+1);
cursor marks "LastValue(EndBar)" just between Value and (
any idea??
Remove the "LastValue()" function. It was removed from the language because it never worked correctly and the developers couldn't figure out a way to make it work correctly under the current language interpreter.
HiBarNum := valuewhen(1,Barnum-1=EndBar,(Barnum-1)-hhvbars(High ,Ref(BarsInMonth,-1) )+1);
Regards,
Chris
Thank you Chris
getting closer
will see (blind men said)
cskidmore
Apr 2 2009, 02:13 PM
You're welcome.
Regards,
Chris
Ric
Apr 15 2009, 07:57 AM
Hello Chris
I made this indic that gives some levels to trade, and made it based on periods back
Max:= hhv(high,periods);
min:= llv(low,periods);
then with this Max and Min I made the script for levels,
lvl up:= script(Min);
Lvldwn:= script(Max);
wich gives me all levels I want (up and down)
but as time goes on periods are changing and sometimes levels too, to avoid this I added a "start time" condition,
fmDay:=If(fmDate=0,ValueWhen(1,*beep*(1)=1,DayOfMonth()),Int(fmDate/10000));
fmMonth:=If(fmDate=0,ValueWhen(1,*beep*(1)=1,Month()),Int((fmDate-fmDay*10000)/100));
fmYear:=If(fmDate=0,ValueWhen(1,*beep*(1)=1,Year()),Int(fmDate-Int(fmDate/100)*100));
fmYear:=If(fmYear<100,If(fmYear<40,fmYear+2000,fmYear+1900),fmYear);
start:=((DayOfMonth()>=fmDay AND Month()=fmMonth AND Year()=fmYear)
OR (Month()>fmMonth AND Year()=fmYear) OR Year()>fmYear) and
(Hour()>=fmhour and Minute()>=fmMinute);
lvlup:= if(starttime=1, script(Min),null);
lvldwn:= if(starttime=1, script(Max),null);
and what a want is replace hhv(high,periods) and llv(low,periods) for a line that VT recognizes if at "start time" is Min or Max, I think is possible comparing previous bar, then if it's a Min don't plot Max levels and viceversa
hope you can help me with this
Ric
cskidmore
Apr 15 2009, 09:40 AM
Hi Ric,
I apologize, but I don't quite understand what you're asking for. What is the logic for replacing 2 lines (min/max) with 1 line - how should that work? Or - have I completely missed the idea?
Regards,
Chris
Ric
Apr 15 2009, 10:12 AM
Hi Chris
Now indicator recognize high and low of a certain periods, if I put 30 it will look for the H and the L in that 30 periods and every bar forward levels will change if there is a new H or L.
If I choose 10 am bar, I want VT be able to "decide" comparing with 9am bar if its H or L and then do the maths with H if it fits or L if its the case,
I think it's a Ref function, but I don't know how to add it
Actually indic shows all levels up and down, in the way I'm willing only one way of levels will be plotted
Hope now i'm a little bit clearer
Ric
cskidmore
Apr 15 2009, 11:15 AM
Hello,
I apologize, but can you perhaps provide a 'mock up' screenshot showing the current logic and the logic that you want? I think that may help me understand what you're asking for. Thank you.
Regards,
Chris
Ric
Apr 15 2009, 12:07 PM
cskidmore
Apr 15 2009, 12:21 PM
Hello,
I apologize, but I still don't quite "get it". In any case, if you need to reference the previous bar value at a specific point in the chart (i.e. another bar) when some other condition happens you can perhaps use something like this:
YourCond:= yourCondHere;
FlagYourCondAndGetPreviousBarValueOfVariable:= valuewhen(1,YourCond,ref(YourVariable,-1));
From there, I'm not sure what to advise since I still don't fully understand what you're trying to accomplish. I apologize.
Regards,
Chris
Ric
Apr 15 2009, 12:34 PM
Chris
Why this statement givesme an error??
"Maxi:= if(high>(ref(High,-1),high);"
cskidmore
Apr 15 2009, 01:02 PM
Hi Ric,
It's an if() statement ... if -> then -> else. You don't have the "else" part included. Additionally, you've got an extra ( bracket in front of the ref function.
Maxi:= if(High>ref(High,-1), High, your-else-value-here);
Regards,
Chris
Ric
Apr 15 2009, 01:13 PM
Yes, thank you Chris
I'm cooking this, in some minutes a new question
Ric
Apr 15 2009, 01:53 PM
QUOTE(cskidmore @ Apr 15 2009, 02:21 PM)

Hello,
I apologize, but I still don't quite "get it". In any case, if you need to reference the previous bar value at a specific point in the chart (i.e. another bar) when some other condition happens you can perhaps use something like this:
YourCond:= yourCondHere;
FlagYourCondAndGetPreviousBarValueOfVariable:= valuewhen(1,YourCond,ref(YourVariable,-1));
From there, I'm not sure what to advise since I still don't fully understand what you're trying to accomplish. I apologize.
Regards,
Chris
Sorry I don't understant this
I'll try to explain in a better way
as you see in chart indic draws some support and resistance level, I want them "fixed", usin Mini and Maxi with "periods" back, levels change
Mini refers a low in order to calculate resistances and Maxi refers a high in order to calculate supports
so levels 1, 2 , 3 etc are calculated with an equation and each one plotted as output (you can see in chart)
I want to eliminate "periods" and choose with "starttime" a specific candle and recognize if its high is a hhv or if its low is a llv, how do I recognize that? with "ref" (i think)
Maxi:= if(high>=ref(High,-1),High,null);
Mini:= if(low <=ref(low,-1),low,null);
now I need a new variable to compare wich (Mini or Maxi) is true, lets call it "base"
if I have a higher high of previous high and low isn't lower, "base" will be High and viceversa
"base" will be a high or a low and it will be used in calculation of levels
as you see in pic both lines (sup and res) are drawn, this is because equation runs with mini and maxi at same time (one calculation for each level up or down), how do I avoid calculations of resitances if "base" its a high? (I just need supports in this case) and viceversa, may be with an error statement?
lvlup:= if(starttime=1, script(base),null);
lvldwn:= if(starttime=1, script(base),null);
Ric
cskidmore
Apr 15 2009, 02:33 PM
Hello,
Ok. I'm going to try summarize what I think you want so that I can try to wrap my head around it without being able to look at all of your code, etc.
Basically, you have already identified the bar you want. You call this StartTime. You require no help with this. It's already done.
At StartTime, you want to check if that bar's high is the highest high when compared against n-bars' previous highs. You also need to check if the bar's low is the lowest low when compared against n-bars' previous lows.
If either of those conditions are true, you need to display some line(s).
Is this correct? If so, how many previous bars are we using in the comparison against the StartTime's bar value - only the previous value or some series of previous bars? What happens when neither condition or both conditions are met at the StartTime bar?
While you may be able to 'hide' the output you don't want, there's likely no benefit in trying to code around evaluating both conditions and then determining which line to show and which line to hide.
Regards,
Chris
Ric
Apr 15 2009, 03:32 PM
This is all my code
At starttime, the comparison is for not to have to write an "input", and it's only with the previous bar, only one bar.
I pick one peak or trough for do the math
example
price starts to going up, I choose last candle with lower low and apply the indic, I "manually" choose the lower low, but how VT knows that have to use that low for calculations? i don't want to write it like "input": low=float.
Knowing that value (low in example) Vt has to draw several "straight" (float) lines that will be resistance values, mathematic equation it's the same allways at each level, just need the right variables ( the high or the low), this levels will remanin untill I pick another candle and apply indicator again
using periods for identify H or L causes that lines weren't stratight,they move as H andL are changing in selected periods
Ric
Ric
Apr 15 2009, 05:04 PM
I'll explain in other words
let's asume that 9 am bar is L= 1.35 and H= 1.37, 8am bar is L=1.34 H=1.36 and 7am bar is L=1.33 and H=1.35
I choose 7am bar since is the lowest low
all I want is
low(1.33)*1.5= 1.995
low(1.33)*1.75= 2.33 etc etc (obviously this is not the right calculation, its an example)
those are resistance level (1.995 and 2.33) I want lines at those levels, untill I change the setting of indicator
and the same in case I picked the High
Question is:
how Vt recognizes it has to use low (1.33) or high if its the case
cskidmore
Apr 15 2009, 05:34 PM
Hello,
QUOTE
Question is:
how Vt recognizes it has to use low (1.33) or high if its the case
The simplest solution is that you tell it to use that price by entering it as an input variable in the properties window. Aside from that, Assuming 9AM is the "Start Bar", you'd then have to look back n-periods (in this case 2, starting with the previous bar) and then compare those values to the current "Start Bar" value.
Maybe something like this:
StartBar:= you-identify-bar-already;
StartBarHHVPrice:= valuewhen(1,StartBar,HHV(H,3)); {includes current bar}
StartBarLLVPrice:= valuewhen(1,StartBar,LLV(L,3)); {includes current bar}
Beyond that, I don't understand how you're trying to choose between when to use the High price or Low price. Each time your "Start Bar" comes around (assuming your just using a time each day and not a specific mm/dd/year time), the HHV and LLV values will be recalculated.
Regards,
Chris
Ric
Apr 15 2009, 06:45 PM
Ok, Chris
I'm using ddmmyy
now we have 2 variables
StartBarHHVPrice (high) and StartBarLLVPrice (low), but only one is true, because if price is rising there is no HHV at start bar
pic its an example only for been more explicit
Click to view attachmentso we need to write them in a way that just one (the true) value will be calculated
done that we'll have the true value (h or L) multplied (let's say) n times for resistance and divided n times for supports, but if the true output its a Low, I don't need the division part (suports) drawn in chart
Click to view attachment
cskidmore
Apr 15 2009, 07:33 PM
Hello,
This is where I'm getting stuck; I don't understand what you're trying to accomplish at this point. It is possible that 1 of the 2 bars you're comparing can have both a higher high and a lower low. What do you do in that case? In effect, you're comparing 1 bar's prices to the previous bar's prices. In the case of inside bars or outside bars, for example, 1 bar can be both higher and lower than the other bar. Unless I'm still completely misunderstanding...

Regards,
Chris
Ric
Apr 15 2009, 08:03 PM
Chris, I'm aware of that, but if pick manually wich bar to calculate that is not a problem
Or if you have some other idea to define either high or low, let me know
I just need one low or one high at the time I choose, or without using starttime, use the low or the high of the selected bar, VT has to "know" wich one to use (high or low) and calculate correspondant resistances or supports
Ric
Apr 16 2009, 03:20 AM
Hi Chriss
SUCCESS!!!!!
I made it....
Just needed a couple hours of sleep (and extra care from my wife, you know

)
It were easier than we talk, I just put a new float input: "Price" , where I write my high or low, that's it!! works nice.
Above I wrote formula of start time, i want, as in VT isn`t possible draw vertical lines with indicator builder,
to plot a dot (as in fractals) under or above the starting candle, for now is just for visual, but i'm thinking in next step of this indicator and those dots will be usefull
I try "starttime" as output, but didn't work, i don't know how to define the output at that time
Regards
Ric
cskidmore
Apr 16 2009, 09:39 AM
Hi Ric,
I'm glad you were able to get it working. Creating the new input variable and entering the price manually was what I suggested back in post #25. I'm glad that worked for you.
Regards,
Chris
Ric
Apr 16 2009, 09:53 AM
Ohh Chriss
I didn't understand at that time, sorry
I'm slower than you
What about my last question? "the Dots"
I use
Begin:= valuewhen(1,start,price);
and as output the dotted bounced line,
and I got a srtaight line of dots starting at the right candle, but I want only one dot as in Cahos Fractals
how can i do this?
Ric
Apr 17 2009, 08:29 AM
Hi Chriss
I have this indicator I downloaded it from this forum (Claude's made)
I counts a user defined periods
Click to view attachmentCan you change it, for instead showing MA in a new window, show a dot above or below the candle (doesn't matter this)?? (like in Chaos Fractals)
Or any other solution, just I need its a bars counter to add my levels indicator
Ric
cskidmore
Apr 17 2009, 09:08 AM
Hi Ric,
Can you post a mocked screenshot of exactly what you require from the "dot" or "dots" that you need placed on your charts with maybe a slightly better description of the logic you need? Do you need to just identify the start bar OR do you need to identify the start bar and then certain other bars going forward in the chart?
Regards,
Chris
Ric
Apr 17 2009, 09:32 AM
I need just a simple bar counter, to identify start point I already have my "starttime" formula so this part is already done
Logic: I want a mark (vertical line isnīt possible) so a dot will work, at every "n" bars, let's say I want count 20 bars, then every 20 bars=1Dot at the bar
cskidmore
Apr 17 2009, 10:22 AM
Hello,
Please take a look at this sample indicator.
Regards,
Chris
Ric
Apr 17 2009, 11:31 AM
Hello Chris
Something is wrong, can't see dots
after several attempts, only once dots were showed
seems to be exactly what I want, but I need the dots
Click to view attachment
cskidmore
Apr 17 2009, 12:19 PM
Hello,
Did you modify the indicator after importing it into VT Trader? It works OK on my PC and shows 'dots'. Obviously you'll need to edit the code a bit to fit it into your logic, but the one I provided should have worked OK.
Regards,
Chris
Ric
Apr 17 2009, 12:57 PM
Hey Chris
I don't know what happened, but now its running ok
I deleted it and downloaded it again
Just one more issue, if you change default periods it doesn't work, it's needed to match the number in formula, can you review that??
Despite that its perfect, thank you
cskidmore
Apr 17 2009, 01:11 PM
Whoops! I left the "20" coded into the 'display' output (Cycle=20) instead of using the input variable. It's an easy fix. A modified version is attached.
Regards,
Chris
Ric
Apr 17 2009, 01:37 PM
Excellent!!!!
Now we're running
You'll have to consider to implement vertical lines as indicator/Trad Sys output
Thank you very much for your efforts and patience
Ric
cskidmore
Apr 17 2009, 01:48 PM
You're welcome.
Regards,
Chris
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.