logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
kkrishna79  
#1 Posted : Tuesday, April 4, 2023 7:40:03 AM(UTC)
kkrishna79

Rank: Member

Groups: Registered, Registered Users, Unverified Users
Joined: 1/31/2009(UTC)
Posts: 18
Location: Mumbai

Thanks: 2 times

I am trying to make and indicator based on time from one start date to a specifice number ahead. 

For example 1 Jan 2023 is start date + 29 days = 30 Jan 2023 (should plot on chart)

This indicator i have made

sd:=Input("DATE",1,31,1); sm:=Input("MONTH",1,12,01); sy:=Input("YEAR",1980,2100,2023);

start:= sd=DayOfMonth() AND sm=Month() AND sy=Year();

x:=BarsSince(start);

If(x=0,1,0); If(x=29,1,0);

Now this is plotting Bar count instead of Date count. 

I request all friends please help me to rectify my code if i am making any mistake in it.

Thank you all

krishna

MS Support  
#2 Posted : Thursday, April 6, 2023 2:45:28 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,953

Thanks: 91 times
Was thanked: 155 time(s) in 150 post(s)
Originally Posted by: kkrishna79 Go to Quoted Post

I am trying to make and indicator based on time from one start date to a specifice number ahead. 

For example 1 Jan 2023 is start date + 29 days = 30 Jan 2023 (should plot on chart)

This indicator i have made

sd:=Input("DATE",1,31,1); sm:=Input("MONTH",1,12,01); sy:=Input("YEAR",1980,2100,2023);

start:= sd=DayOfMonth() AND sm=Month() AND sy=Year();

x:=BarsSince(start);

If(x=0,1,0); If(x=29,1,0);

Now this is plotting Bar count instead of Date count. 

I request all friends please help me to rectify my code if i am making any mistake in it.

Thank you all

krishna

Hello,

The code looks to be correct based on number of bars. One thing to keep in mind is that the start date must be a valid trading date. For example, in the US January 1st is not a valid trading day, so if you use this as the Start Date it will not plot anything. If you use January 3rd 2023 then your indicator should plot.

kkrishna79  
#3 Posted : Wednesday, April 12, 2023 7:35:49 AM(UTC)
kkrishna79

Rank: Member

Groups: Registered, Registered Users, Unverified Users
Joined: 1/31/2009(UTC)
Posts: 18
Location: Mumbai

Thanks: 2 times

Respected Sir/Madam,

Yes it work on Number of Bars , but i want to plot on Number of Days. How can i do it . Number of days count is there in trading view, so trying it out in metastock.

Kindly help .

Regards,

Krishna

Originally Posted by: MS Support Go to Quoted Post
Originally Posted by: kkrishna79 Go to Quoted Post

I am trying to make and indicator based on time from one start date to a specifice number ahead. 

For example 1 Jan 2023 is start date + 29 days = 30 Jan 2023 (should plot on chart)

This indicator i have made

sd:=Input("DATE",1,31,1); sm:=Input("MONTH",1,12,01); sy:=Input("YEAR",1980,2100,2023);

start:= sd=DayOfMonth() AND sm=Month() AND sy=Year();

x:=BarsSince(start);

If(x=0,1,0); If(x=29,1,0);

Now this is plotting Bar count instead of Date count. 

I request all friends please help me to rectify my code if i am making any mistake in it.

Thank you all

krishna

Hello,

The code looks to be correct based on number of bars. One thing to keep in mind is that the start date must be a valid trading date. For example, in the US January 1st is not a valid trading day, so if you use this as the Start Date it will not plot anything. If you use January 3rd 2023 then your indicator should plot.

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.