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

Re: [amibroker] Re: Stops implementation



PureBytes Links

Trading Reference Links

I could read it and here it is.


//---------------------------------------------------------------------
Filter = 1;
NumColumns = 5;
Column0 = O; Column0Name = "O"; Column0Format = 1.2;
Column1 = H; Column1Name = "H"; Column1Format = 1.2;
Column2 = L; Column2Name = "L"; Column2Format = 1.2;
Column3 = C; Column3Name = "C"; Column3Format = 1.2;
Column4 = V; Column4Name = "V"; Column4Format = 1.0;

//
****************************************************************************************
// 2. MACD

// Control Variables
USE_Buy_2 = 1; // 1 - active, 0 - inactive
USE_Short_2 = 1; // 1 - active, 0 - inactive

// Optimization Variables
opt2_1B = 12;// fast ave. period for Buy
opt2_1S = 12;// fast ave. period for Short
opt2_2B = 26;// slow ave. period for Buy
opt2_2S = 26;// slow ave. period for Short
opt2_3B = 9;// signal ave. period for Buy
opt2_3S = 9;// signal ave. period for Short

// Indicator formula for Buy
MACD_Buy = MACD(opt2_1B, opt2_2B);
Signal_Buy = Signal(opt2_1B, opt2_2B, opt2_3B);

// Indicator formula for Short
MACD_Short = MACD(opt2_1S, opt2_2S);
Signal_Short = Signal(opt2_1S, opt2_2S, opt2_3S);

// Buy condition
Buy_2 = Cross(MACD_Buy, Signal_Buy) OR (NOT USE_Buy_2);

// Short condition for 
Short_2 = Cross(Signal_Short, MACD_Short) OR (NOT USE_Short_2);

// Exploration in Amibroker
AddColumn(MACD_Buy, "MACD_Buy", format=1.2);
AddColumn(Signal_Buy, "Signal_Buy", format=1.2);
AddColumn(Buy_2, "BuySig_MACD", format=1.0);
AddColumn(MACD_Short, "MACD_Short", format=1.2);
AddColumn(Signal_Short, "Signal_Short", format=1.2);
AddColumn(Short_2, "ShortSig_MACD", format=1.0);

Buy = Buy_2;
Short = Short_2;

Sell = 0 OR Short; //stops signals here
Cover = 0 OR Buy; //stop signals here

// Exploration in Amibroker
AddColumn(Buy, "Buy", format=1.0);
AddColumn(Short, "Short", format=1.0);
AddColumn(Sell, "Sell", format=1.0);
AddColumn(Cover, "Cover", format=1.0);
AddColumn(BuyPrice, "BuyPrice", format=1.2);
AddColumn(ShortPrice, "ShortPrice", format=1.2);
AddColumn(SellPrice, "SellPrice", format=1.2);
AddColumn(CoverPrice, "CoverPrice", format=1.2);


Stephane Carrasset wrote:
> 
> the afl is empty:
> 
> could anyone read it or it is a bug in my ami installation??
> 
> stephane
> > I swear I have tried to solve it myself ;-)
> >
> > I'm working on non-reversal system that (let simplify for long only
> > trades):
> > 1. Long signals are produced by indicators (e.g.. MACD crossing
> AND ...)
> > 2. Sell signals SHOULD be produced by stops:
> > a/ StopLoss - mkt price is lower by 10 points than buyprice.
> > b/ ProfitTakingStop - when mkt price (highest since buy) is higher
> by 8
> > points than buyprice then set the ProfitTakingStop at buyprice + 3
> > points
> > c/ TrailingStop - when mkt price (highest since buy) is higher by 16
> > points than buyprice then set trailing stop at buyprice + 61.8%x
> (Highest
> > since buy - buyprice+3)
> >
> > I've tried with Settings and ApplyStop - I see something is
> triggered by
> > I can't control what is going on and I can't see arrows on chart.
> > Could it be implemented directly in AFL, I mean it is obvious it
> could
> > be :-) but how?
> >
> > Thanks
> > Marek
> >
> > PS. Please find attached part of my not-working :-) afl code.
> 
> Yahoo! Groups Sponsor
> ADVERTISEMENT
> 
> 
> 
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.