[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EquisMetaStock Group] Re: Need guidance in Building formula



PureBytes Links

Trading Reference Links

Sat,

The code that I gave you had some errors in it but was posted to give 
some ideas.

Your original question was..."how to restricted display with 
specified priode of future date instead of back time priode."

Then your logic says: 
"1. check a month ,if month below 12(december) ,then check the year"
"2. check the year ,if the year below 2008 ,then run the indicator" 

The logic behind a restricted display is to simply display an 
indicator during a specific period of time. The indicator is 
calculated during the complete period of available data. It is 
displayed only when the appropriate period/s of time are available. 
This is not something you would use to trade from.

Let's look at your logic:

checkmonth:=If(Month()>12),-1),1,0));
checkyear:=If(year()>2008),-1),1,0));
run the indicator if value 1, else delete/hide/stop calc the 
indicator when value 0


Let's Rewrite this to:

{zero value version}
checkmonth:=If(Month()<=12,1,0);
checkyear:=If(Year()>2004,1,0);
If(checkmonth + checkyear = 2,MACD(),0);

or we could write this:

{NA value version}
checkmonth:=If(Month()<=12,1,0);
checkyear:=If(Year()>2004,1,0);
X:=checkmonth + Checkyear =2;
ValueWhen(1,x,MACD());


The first formula gives a zero value until it can calculate. The 
second gives a NA...meaning not enough information to calculate. 
There may also be a difference in the display and that is due to 
delay by the valuewhen(first,...,...).

Also notice that the checkmonth argument is changed to Month()<=12.
The explanation is that there are only 12 months to a year. So we 
could only have 12 or less.

You will need to change the date to whatever is appropriate for your 
use. I used 2004 so that I could see the display.
 
Can we get metastock to "show this messegge("This Indicator run error 
priode of this month")? You could if you are using the formula in an 
expert but not as a drop down indicator.

Finally, I am curious as to what your intended use will be for this 
indicator?


Hope this helps,

Preston


  

 




--- In equismetastock@xxxxxxxxxxxxxxx, "Sathya" <prassathya@xxx> 
wrote:
>
> 
> Preston,
> i think you are close to what is on my mind.
> please see the FLOW i wrote with my logic
> 
> checkmonth:=If(Month()>12),-1),1,0));
> checkyear:=If(year()>2008),-1),1,0));
> run the indicator if value 1, else delete/hide/stop calc the 
> indicator when value 0
> 
> the flow as below :
> 1. check a month , if month below 12(december) , then check the year
> 2. check the year , if the year below 2008 , then run the 
indicator , 
> else "show this messegge("This Indicator run error priode of this 
> month")
> 
> that's exacty i wont to do in MS,,, pls solve preston
> perhaps you may make more good then my strategy.
> 
> Regards
> SAT 
> 
> --- In equismetastock@xxxxxxxxxxxxxxx, pumrysh <no_reply@> wrote:
> >
> > Sat,
> > 
> > Seems simple enough, we should be able to simply display an 
> indicator 
> > sometime in the future. Problem is that using an if statement 
means 
> > we would need something else in its place while we are waiting on 
> the 
> > date. The Gann Hi-Lo was an example of how this was done using 
one 
> > display or another.
> > 
> > The restricted display indicators that I wrote displays after the 
> > fact and only for a designated period of time. There are now 
three 
> > versions of the indicator. One based on regular or standard date, 
> > numerical date, and period of time. So what happens when there is 
> no 
> > display? You get a NA for a value, which means there was not 
enough 
> > data to calculate.
> > 
> > Here is a date version:
> > 
> > {Restricted Display by Date v2.0}
> > {Written by Preston Umrysh}
> > {Displays an indicator within specified dates}
> > {Uses standard date inputs}
> > 
> > {Indicator} {Place your indicator/s here}
> > Ind:=MACD(); 
> > Ind2:=Mov(MACD(),9,E);
> > 
> > Sd:=Input("Start Day" ,1,31,1);
> > Sm:=Input("Start Month",1,12,1);
> > Sy:=Input("Start Year" ,1980,2015,2003);
> > Ed:=Input("End Day" ,1,31,31);
> > Em:=Input("End Month" ,1,12,12);
> > Ey:=Input("End Year" ,1980,2015,2004);
> > 
> > startdate:=Year()>SY OR 
> > (Year()=SY AND Month()>SM OR
> > Month()=SM AND DayOfMonth()>=SD);
> > enddate:=Year()<EY OR 
> > (Year()=EY AND Month()< EM OR
> > Month()=EM AND DayOfMonth()<=ED);
> > 
> > start:=startdate AND Alert(startdate=0,2);
> > end:=enddate=0 AND Alert(enddate=1,2);
> > 
> > {Restricted Display}
> > DisPds:=LastValue(Cum(1) - ValueWhen(1,Start,Cum(1)));
> > BackPds:=LastValue(Cum(1) - ValueWhen(1,End,Cum(1)));
> > Dispds:=Dispds-BackPds;
> > ResPds:= Alert(BarsSince(Cum(1)=LastValue(Cum(1)-
> > (DisPds+BackPds))=1),1);
> > Plot:=ValueWhen(1,ResPds,Ref(Ref(Ind,-BackPds),BackPds));
> > Plot2:=ValueWhen(1,ResPds,Ref(Ref(Ind2,-BackPds),BackPds));
> > 
> > Plot; Plot2; 
> > {end}
> > 
> > 
> > Everything that you need to produce your indicator is there. I 
> won't 
> > restrict the display but will ask the indicator to display some 
> time 
> > in the future.
> > 
> > Let's try something like this:
> > 
> > {Indicator} 
> > Ind:=MACD();{Place your indicator/s here} 
> > 
> > Sd:=Input("Start Day" ,1,31,1);
> > Sm:=Input("Start Month",1,12,1);
> > Sy:=Input("Start Year" ,1980,2015,2009);
> > 
> > startdate:=Year()>SY OR 
> > (Year()=SY AND Month()>SM OR
> > Month()=SM AND DayOfMonth()>=SD);
> > 
> > start:=startdate AND Alert(startdate=0,2);
> > 
> > DisPlay:= ValueWhen(1,Start,Ind);
> > Display;
> > {end}
> > 
> > 
> > If you compare the indicators you should be able to see the parts 
> of 
> > the original that I used. Let me know if this is what you had in 
> mind.
> > 
> > Preston
> > 
> > 
> >  
> > 
> > 
> > 
> > --- In equismetastock@xxxxxxxxxxxxxxx, "Sathya" <prassathya@> 
> > wrote:
> > >
> > > Preston,
> > > how to restricted display with specified priode of future date 
> > > instead of back time priode. 
> > > 
> > > Rgds
> > > Sat
> > > --- In equismetastock@xxxxxxxxxxxxxxx, pumrysh <no_reply@> 
wrote:
> > > >
> > > > Vishal,
> > > > 
> > > > Try this one and see if its anything close to what you are 
> > looking 
> > > > for.
> > > >  
> > > > This is how it works. 
> > > > You would like to show the MACD and its trigger for 30 days 
but 
> > > > restrict that to a period of 10 days ago.
> > > > 
> > > > 
> > > > {Restricted Display v2.0}
> > > > {Written by Preston Umrysh}
> > > > {Correctly Displays an indicator for a specified period of 
time}
> > > >  
> > > > DisPds:=Input("Select Display Periods",1,1111,30);
> > > > BackPds:=Input("Select Setback Periods",0,1111,10);
> > > > 
> > > > {Indicator} {Place your indicator/s here}
> > > > Ind:=MACD(); 
> > > > Ind2:=Mov(Macd(),9,E);
> > > > 
> > > > {Restricted Display}
> > > > ResPds:= Alert(BarsSince(Cum(1)=LastValue(Cum(1)-
> > > > (DisPds+BackPds))=1),1);
> > > > Plot:=ValueWhen(1,ResPds,Ref(Ref(Ind,-BackPds),BackPds));
> > > > Plot2:=ValueWhen(1,ResPds,Ref(Ref(Ind2,-BackPds),BackPds));
> > > > 
> > > > Plot; Plot2; {end}
> > > > 
> > > > 
> > > > 
> > > > Hope this helps,
> > > > 
> > > > 
> > > > Preston
> > > > 
> > > >  
> > > >
> > >
> >
>



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/