Home
Discussions
Files
Register
Login
Welcome Guest! To enable all features please
Login
or
Register
.
Forum
Active Topics
Search
Help
Login
Register
Search
Notification
Error
OK
Discussions
»
Product and Service Development
»
MetaStock
»
barssince()
barssince() -
barssince()
Options
Email this topic
Watch this topic
Print this topic
» Normal
Threaded
Previous Topic
Next Topic
Flexi
#1
Posted :
Sunday, November 27, 2011 6:25:15 AM(UTC)
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135
How to exit a specific 100 bars for a trade on tradesim? try the barssince()>60 but the trades didn't exit on the period
User Profile
View All Posts by User
View Thanks
Wanna join the discussion?!
Login to your Discussions forum account
or Register a new forum account
.
jjstein
#2
Posted :
Sunday, November 27, 2011 9:37:06 AM(UTC)
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
Try something like:
ExitTrig1:=C<ref(c,-1);
ExitTrig2:=BarsSince(ExitTrig1);
ExitTrigger:=ExitTrig1 or ExitTrig2;
User Profile
View All Posts by User
View Thanks
mstt
#3
Posted :
Sunday, November 27, 2011 8:23:16 PM(UTC)
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
Hi Flexi
The question that has to be asked about a timed exit is - do you want to exit after 60 bars in the trade or do you want to exit 60 bars after the most recent entry signal? The latter option could keep you in a trade for ever if entry signals were given regularly. The former option will enter a trade and then ignore all subsequent entry signals until the current trade has terminated. For this you need to use PREV-based code.(you could try using one of the Simulation functions but good luck with that - you'll need it).
Something along these lines should work. (no responsibility taken for the site corrupting my code)
{Timed Exit Signal}
D:=60; {delay period}
N:=Fml("your entry signal or formula");
X:=0; {place an independant exit signal here if there is one}
R:=If(0>=PREV, N, X OR If(BarsSince(0>=PREV)>=D,-1,1));
Exit:=0>R;
Exit;
Roy
User Profile
View All Posts by User
View Thanks
jjstein
#4
Posted :
Monday, November 28, 2011 12:58:30 AM(UTC)
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
WHOOPS! That should be:
EntryTrig:=C>ref(C,-1);
ExitTrig1:=C<ref(C,-1);
ExitTrig2:=BarsSince(EntryTrig);
ExitTrigger:=ExitTrig1 or ExitTrig2;
User Profile
View All Posts by User
View Thanks
jjstein
#5
Posted :
Monday, November 28, 2011 1:02:00 AM(UTC)
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
Roy, I tried the following, but only got a "flatline".
{_Stochastic}
Period:=Input("Period:",1,250,14);
Length:=Input("Length:",1,250,3);
Smooth:=Input("Smooth:",1,250,3);
StochK:=(Sum(C-LLV(L,Period),Length)/Sum(HHV(H,Period)-LLV(L,Period),Length))*100;
FastD:=Mov(StochK,Smooth,S);
SlowD:=Mov(FastD,Smooth,S);
StochK;
FastD;
{_Test }
D:=60; {delay period}
N:=Cross(Fml("_Stochastic"),20);
X:=Cross(80,Fml("_Stochastic"));
R:=If(0>=PREV, N, X OR
If(BarsSince(0>=PREV)>=D,-1,1));
Exit:=0>R;
Exit;
User Profile
View All Posts by User
View Thanks
mstt
#6
Posted :
Monday, November 28, 2011 2:40:37 AM(UTC)
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
Hi Johnathan
That's the problem with me messing with code in an effort to foil the forum foibles. I'll send you the code as a PM now that it's working again. Will do the same for Flexi but won't risk posting code to the thread in case it screws up what I just corrected. My mistake, the code posted exactly as I sent it but I'd modified some good working code before posting it. Duh.
Roy
User Profile
View All Posts by User
View Thanks
jjstein
#7
Posted :
Monday, November 28, 2011 1:01:31 PM(UTC)
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
Roy -- You whip out latches like a master chef in the pastry kitchen...
User Profile
View All Posts by User
View Thanks
Users browsing this topic
Guest
(Hidden)
Similar Topics
barssince() has problems when the condition never happened
(
MetaStock
)
by
yonyon191719
12/9/2018 10:33:25 PM(UTC)
BarsSince() help
(
Formula Assistance
)
by
v.trader
5/9/2010 1:44:05 PM(UTC)
BarsSince() Question
(
Basic Coding Techniques
)
by
bostonman28
2/13/2009 8:34:58 AM(UTC)
Problem with barssince() and valuewhen()
(
Advanced Coding Techniques
)
by
FoxerFX
2/13/2009 2:46:39 AM(UTC)
Discussions
»
Product and Service Development
»
MetaStock
»
barssince()
Forum Jump
Discussions
Innovative Market Analysis
- Forum Feedback
- Online Help
--- MetaStock FAQ
--- MetaStock.com Website FAQ
- Welcome!
Product and Service Development
- Product Alerts
- Data Related Questions
- Error Messages
- Exchange Changes
- Formula Assistance
- LCI Toolkit
- MetaStock
- MetaStock Product Updates
- Product Wish List
- Testimonials
Special Interest Groups
- MetaStock Developer's Kit (MDK) Assistance
- Basic Coding Techniques
- Plugins & Addons
- Tips & Tricks
- Advanced Coding Techniques
Resource Library
- MetaStock Monitor Articles
- MetaStock U
--- Candlestick Forum
--- Tech Talk
--- Technical Guides to Energy Trading
--- TechniTrader
--- The Inside Technician
--- The Naked Trader
--- Traders State of Mind
- Press Releases
- Product Awards
--- MetaStock Data
--- MetaStock Products
--- Third Party Add-Ons
- Technical Analysis from A to Z
--- PART ONE
--- PART TWO
- Trader's Tips from TASC Magazine
--- 1999
--- 2000
--- 2001
--- 2002
--- 2003
--- 2004
--- 2005
--- 2006
--- 2007
--- 2008
--- 2009
--- 2010
--- 2011
--- 2012
--- 2013
--- 2014
--- 2015
--- 2016
--- 2017
--- 2018
--- 2019
--- 2020
--- 2021
--- 2022
--- 2023
--- 2024
- User Groups
- Video Instruction and Webinar Sessions
--- MetaStock Online User Group Archives
--- MetaStock Webinar Series
- VIP Interviews
Community Forums
- 3rd Party Advertisements
- General Chat
- MetaStock Advertisements
- Technical Chat
Administrative Forums
- MetaStock Partners
- Web Content
--- Archive
--- Beta Web Content
--- Bios
--- Events
----- MetaStock Conferences
----- Online Traders Summit
--- kb
----- Frequently Asked Questions
------- Legacy MetaStock FAQs
--------- Custom Formulas
--------- MetaStock Add-Ons
--------- MetaStock Data Feeds
----------- DataLink
----------- XENITH
--------- MetaStock Products.
----------- MetaStock RT and DC
--- MetaStock Spotlight
--- MS User Groups
----- USA
----- Caribbean
----- Australia
----- New Zealand
----- Online
--- Products
----- FAQs
--- mktg
----- summit
------- archive
------- sessions
----- home
----- Singapore
------- sessions
----- HongKong
------- sessions
----- KualaLumpur
------- sessions
----- Jakarta
------- sessions
----- Bangkok
------- sessions
----- seminar
------- sessions
----- Zurich
------- sessions
----- Amsterdam
------- sessions
--- support
----- downloads
------- mseod
------- msrt
Files
- MetaStock
--- MetaStock Files
--- Next big thing
- Programming
--- Programming Files
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.
Powered by YAF.NET
|
YAF.NET © 2003-2024, Yet Another Forum.NET