Print Page | Close Window

newbie programming questions

Printed From: BullCharts Forum
Category: BullCharts
Forum Name: BullScript
Forum Discription: Technical discussion related specifically to the BullScript programming language.
URL: http://www.bullcharts.com.au/forum/forum_posts.asp?TID=294
Printed Date: 23 Apr 2025 at 8:58pm
Software Version: Web Wiz Forums 9.69 - http://www.webwizforums.com


Topic: newbie programming questions
Posted By: ukipeter
Subject: newbie programming questions
Date Posted: 15 Sep 2005 at 8:11am
I'm just starting with BullScript.  I've been looking through some of the scripts trying to understand how things work.
 
1) prev statement.   I am a bit puzzled how the prev statement works.
 
I have copied some code from the JB Volatility Stop Loss. 
 
I can work most of it out, but I am lost as to what the prev does in the following lines.  Any clues?
 
 
[citation="'Share Traders Handbook', Jim Berg;
'A Winning Combination for Traders', Jim Berg, Leverage July 2004 Issue 32 p15-17
http://www.leveragemag.com.au - www.leveragemag.com.au "]
[target=Price; author=Berg, Jim; category=Stop Loss|Volatility]
 
In this inMarket statement, what does the 'prev' do in the second if statement?
 
inMarket :=
if (entry, true,
if (takeprofit or stopped, false, prev));
 
jbmode := if (C>r1, 1, if (C<r2, -1, prev) );
 
 
2) From the MACD Tradesim example

{Generated BullScript for "TradeSim Sample Scan" scan}
 
{Condition: return all securities }
filter := true;
filter;
 

{-- Trading System : "Sample MACD System" --}
_var1 := formula("MACD", 12, 26, 9);
_var2 := formula("MACD[2]", 12, 26, 9);
EntryTrigger := (cross(_var1, _var2));
EntryPrice := Open;
ExitTrigger := (cross(_var2, _var1));
ExitPrice := Open;
InitialStop := Low-2*ATR(10);
 
[visible=no]
ExtFml("TradeSim.Initialize");
ExtFml("TradeSim.EnableProtectiveStop",0);
ExtFml("TradeSim.EnableDelayOfEntryByOneBar");
ExtFml("TradeSim.EnableDelayOfAllExitsByOneBar");
ExtFml("TradeSim.EnablePriceFilter");
ExtFml("TradeSim.SetVolumeInfoType",LOWEST);
 
[name="Sample MACD System Trades"; dp=0; visible=yes]
ExtFml("TradeSim.RecordTrades",
 "TradeSim Sample Scan",
 LONG,
 EntryTrigger,
 EntryPrice,
 InitialStop,
 ExitTrigger,
 ExitPrice,
 START);
 
What would you put if you wanted to exit if the opening price went a fixed percentage above your entry price (e.g. 5%)?
 
3) I am looking at comparing the prices with the price at a particular date, so, before that date the indicate would plot 0, after that date, it would plot the ratio of the bar to the bar at a particular date.  For example, I would like to plot
 
Close/ Close("25/03/05")
 
How could I do this?
 
Peter Bloomfield
 
 
 


-------------
just starting!



Replies:
Posted By: zorro
Date Posted: 19 Sep 2005 at 10:49pm
prev just returns the same result as the previous bar.
eg:
inMarket :=
if (entry, true,
if (takeprofit or stopped, false, prev));

in this case, 'inMarket' is set to true whenever 'entry' is true (entering the market). it is set to false if either takeprofit or stopped is true (exiting the market). and if none of the three signals are true then the result is unchanged from the previous (if you're in, you stay in; if you're out, you stay out).



Posted By: ukipeter
Date Posted: 20 Sep 2005 at 9:18am

Thanks for that - now it all makes sense.



-------------
just starting!


Posted By: zorro
Date Posted: 21 Sep 2005 at 8:37pm
for #3, the relative performance indicator does something like this



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums® version 9.69 - http://www.webwizforums.com
Copyright ©2001-2010 Web Wiz - http://www.webwiz.co.uk