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!
|