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

[amibroker] Parabolic Stop Help request.



PureBytes Links

Trading Reference Links

Dear Forum:

I am having some problems coding a Parabolic Stop. This is not a 
Parabolic Stop and Reverse (PSAR), just a parabolic stop which gets 
instantiated when a long or a short trade entry trigger is made. It 
will be for intraday data (15 Minutes), and I am only focusing on 
Long trades now.

I have two main problems that I can't figure out:
1.   How can I set the "Extreme Price" ? Please see code notes below 
for a description. The psuedo code would be : The High of the bar 
that the trade began, and thereafter, the Highest High since the 
trade began.
2.   How can I set the calculated parabolic stop price referencing 
the next bar into future?

Here is what I have so far:

///////////////////////////////////////////////////////////
// Set up the Parabolic Stop.
// The standard formula for the parabolic stop is:
// Parabolic Stop price for the NEXT bar = the current Parabolic 
Stop OR the 
// Initial Stop Loss price 
// (LLV of last 6 bars minus 20 pips) if this is the very first bar 
of the 
// trade) + 
// (Acceleration Factor * (Extreme Price - Parabolic Stop (current 
bar)))

// The Acceleration Factor; the default value begins at 0.02 and 
increments by 
// 0.02 on each subsequent bar,  to a maximum value of 0.20.

// The "Extreme Price" since the trade was initiated is equal to the 
Highest 
// High since the trade began.

// Variable initialization:

// Initialize the Extreme Price from todays High if Buy conditions 
are met.
fInitExtrmPr = ValueWhen (Buy, High, 0); 

// fExtremePrice = ??? Psuedo Code. The High of the first bar of the 
trade or the Highest High since the trade began.

Question: How can I keep this variable from taking on new values 
each time the Buy logic is satisfied AND I am already in a trade? 
Can Exrem or ExRemSpan be incorporated?

// Initial Acceleration Factor.
fInitAccFact = Optimize ("Init Accl Fct", 0.02, 0.01, 0.10, 0.01);

// Subsequent additional acceleration if there is a new higher high 
during the trade.
fSubsqAccFact = Optimize ("Subsq Accl Fct", 0.02, 0.01, 0.10, 0.01);

// Maximum Parabolic Stop acceleration factor.
fMaxAccFact = Optimize ("Max Accl Fct", 0.02, 0.01, 0.40, 0.01);

// Set the initial Stoploss to the Lowest Low Value of the last 6 
bars if Buy // is true, minus 20 pips (FOREX).
fInitStpLss = ValueWhen (Buy, (LLV(Low, 6),0) - 0.0020;

// Initialize a Boolean Flag that we are in a trade.
bInLngTrd = 0; 

// Attempt to set a Boolean flag that we are in a trade if Buy logic 
becomes 
// true.
CondNewBuySignal =  (Ref (Buy, 0) == 1) AND (Ref (Buy, -1) ==0);

IIf (CondNewBuySignal == 1, bInTrdLng = 1, Null);

// fPrBolicStpLss = Stuck here... Psuedo Code: 
The initial stop is the lowest low of the last 6 bars since the Buy 
Logic became true minus 0.0020.
There after the parabolic stop is equal to The Current Bars Stop

// Apply a Trailing Stop that utilizes the Parabolic Stop and 
increments by points.
ApplyStop (stopTypeTrailing, stopModePoint, fPrBolicStpLss, 
ExitAtStop = 2, True, 0);

_______________________________________________

That's what I have so far. Any help or concepts I'm not getting 
appreciated.

Thanks,


Denton





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Put more honey in your pocket. (money matters made easy).
http://us.click.yahoo.com/r7D80C/dlQLAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

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

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

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