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

Re: [amibroker] Code skipping buy & sell signals



PureBytes Links

Trading Reference Links

Yes I see. I have been busy and had not plotted these yet, but this is great advice you have given me to see what it going on. It looks like moving the PHighPrice and PLowPrice back one bar will solve the problem, but  I'll have to make sure that doesn't cause other problems. Thanks very much for your help.


----- Original Message ----
From: Edward Pottasch <empottasch@xxxxxxxxx>
To: amibroker@xxxxxxxxxxxxxxx
Sent: Thursday, July 31, 2008 1:45:47 AM
Subject: Re: [amibroker] Code skipping buy & sell signals

James,
 
I looked at it and added a chart to see what is happening. On 7/22/08 you miss a buy signal. But the buy signal is defined as Buy = Cross(H, PhighPrice);
 
But this cross does not occur. The High is already above PhighPrice. Same for the other signals, see chart, rgds, Ed
 
 
 
 
 
 
----- Original Message -----
From: James
Sent: Thursday, July 31, 2008 1:13 AM
Subject: Re: [amibroker] Code skipping buy & sell signals

Ed,

 

Will do. I had them in the interpretation window, but plotting them is a good idea. In the meantime I sent a screenshot.

 

BTW, this is not a system, just an entry technique. I save these as building blocks, an idea I got from someone on this list (thanks to whomever it was)and then use them when needed. But they need to work first.

 
James

----- Original Message ----
From: Edward Pottasch <empottasch@xxxxxxx be>
To: amibroker@xxxxxxxxx ps.com
Sent: Wednesday, July 30, 2008 4:46:31 PM
Subject: Re: [amibroker] Code skipping buy & sell signals

hi James,
 
I do not see it missing any signals. Why not add some lines to see what is happening like:
 
Plot(PhighPrice, "PHighPrice" ,colorDarkGrey, styleLine) ;
Plot(PLowPrice, "PLowPrice" ,colorDarkBlue, styleLine) ;
your code seems to be working fine. I am testing with similar systems. They do pretty good in a backtest but in the practice the slippage will kill you. Should test these type of systems entering at the high and selling at the low since this is close to what you will get in reality.
 
regards, Ed
 
 
 
SetBarsRequired(10000,10000);
SetTradeDelays(0,0,0,0
);

SetOption("CommissionMode", 3
);
SetOption("CommissionAmount", 2.75
);
SetOption("FuturesMode",True
);
NumContracts =
1
;
PositionSize = NumContracts * MarginDeposit
;

//SetOption( "MaxOpenPosition s", 100 );

//SetOption( "PriceBoundCheck ing", False);
//PositionSize = 35000;

starttime =
153000
;
endtime =
215900
;
timearray =
TimeNum() >= starttime AND TimeNum
() <= endtime;

PHigh = (
Ref (H, -2) > Ref (H, -3) AND Ref (H, -2) > Ref (H, -1
) );
PHighPrice =
ValueWhen(Phigh, Ref(H,-2),1
);
PLow = (
Ref (L, -2) < Ref (L, -3) AND Ref (L, -2) < Ref (L, -1
) );
PLowPrice =
ValueWhen(PLow, Ref(L,-2),1
);

Plot(PhighPrice,"PHighPrice",colorDarkGrey,styleLine
);
Plot(PLowPrice,"PLowPrice",colorDarkBlue,styleLine
);

Buy = Cross(H
, PhighPrice) * timearray;
Sell = Cross (PLowPrice, L
) * timearray;
Short = Cross (PLowPrice, L
) * timearray;
Cover = Cross (H
, PHighPrice) * timearray;

BuyPrice = Max (PHighPrice, Open
);
ShortPrice = Min (PLowPrice, Open
);
SellPrice = Min (PLowPrice, Open
);
CoverPrice = Max (PHighPrice, Open
);

//Buy=ExRem( Buy,Sell) ;

//Sell=ExRem( Sell, Buy);
//Short=ExRem( Short,Cover) ;
//Cover=ExRem( Cover,Short) ;

SetChartOptions(0, chartShowDates);
Plot(C,"Last=",colorBlack,64
);

PlotShapes (IIf(Buy,shapeUpArrow,shapeNone), colorGreen,0,Low
);
PlotShapes(IIf(Buy,shapeSmallCircle,shapeNone),colorWhite,0,BuyPrice,0
);

PlotShapes (IIf(Sell,shapeHollowDownArro w,shapeNone), colorRed,0,High
);
PlotShapes(IIf(Sell,shapeSmallCircle,shapeNone),colorPink,0,SellPrice,0
);

PlotShapes (IIf(Short,shapeDownArrow,shapeNone), colorRed,0,High
);
PlotShapes(IIf(Short,shapeHollowCircle,shapeNone),colorYellow,0,ShortPrice,0
);

PlotShapes (IIf(Cover,shapeHollowUpArrow,shapeNone), colorGreen,0,Low
);
PlotShapes(IIf(Cover,shapeHollowCircle,shapeNone),colorAqua,0,CoverPrice,0
);


"PHigh: " + NumToStr( PHigh, 1.2
);
"PLow: " + NumToStr( PLow, 1.2
);
"PHighPrice: " + NumToStr( PHighPrice, 1.2
);
"PLowPrice: " + NumToStr( PLowPrice, 1.2
);
"Buy: " +  NumToStr( Buy, 1.2
);
 
 
 
 
 
 
----- Original Message -----
From: James
Sent: Wednesday, July 30, 2008 3:17 PM
Subject: Re: [amibroker] Code skipping buy & sell signals

Can anyone help me on this most simple code skipping buy and sell signals?
 
James 

----- Original Message ----
From: James <jamesmemphis@ yahoo.com>
To: amibroker@xxxxxxxxx ps.com
Sent: Tuesday, July 29, 2008 11:32:29 AM
Subject: [amibroker] Code skipping buy & sell signals

I'm hoping someone can help me figure out why the following code seems to be missing buy and sell signals. If you overlay this code on a 30 minute bar chart of ESU8 using day session only data, you will see it missed a buy signal at 10:30 am today. Missed a sell yesterday at 11:30 am. Both of these were signals that would have been ignored if the exrem statements were left in, because it was already positioned in the direction of the signal. However, if you go back to 7/22 you will se where it missed an initial buy at 1:30pm, the bar immediately after the sell at 1:00pm. All times Central. I have found many missed signals and cannot determine what is causing it.
 
Should be buying when it crosses the most recent peak high and selling when crossing the most recent peak low. I would think this is about as simple as it gets and I still can't make it work properly.
 
TIA,
James
 
SetFormulaName ("Pivot Point Entry");

/*
Building block
Entry based on price crossing a peak high or peak low.
*/


PHigh = (
Ref (H, -2) > Ref (H, -3) AND Ref (H, -2) > Ref (H, -1
) );
PHighPrice =
ValueWhen(Phigh, Ref(H,-2), 1
);
PLow = (
Ref (L, -2) < Ref (L, -3) AND Ref (L, -2) < Ref (L, -1
) );
PLowPrice =
ValueWhen(PLow, Ref(L,-2), 1
);

Buy = Cross(H
, PhighPrice);
Sell = Cross (PLowPrice, L
);
Short = Cross (PLowPrice, L
);
Cover = Cross (H
, PHighPrice);

BuyPrice = Max (PHighPrice, Open
);
ShortPrice = Min (PLowPrice, Open
);
SellPrice = Min (PLowPrice, Open
);
CoverPrice = Max (PHighPrice, Open
);

//Buy=ExRem( Buy,Sell) ;

//Sell=ExRem( Sell, Buy);

//Short=ExRem( Short,Cover) ;

//Cover=ExRem( Cover,Short) ;


PlotShapes (IIf(Buy,shapeUpArrow,shapeNone), colorGreen,0,Low
);
PlotShapes (IIf(Sell,shapeHollowDownArro w,shapeNone), colorRed,0,High
);
PlotShapes (IIf(Short,shapeDownArrow,shapeNone), colorRed,0,High
);
PlotShapes (IIf(Cover,shapeHollowUpArrow,shapeNone), colorGreen,0,Low
);

"PHigh: " + NumToStr( PHigh, 1.2
);
"PLow: " + NumToStr( PLow, 1.2
);
"PHighPrice: " + NumToStr( PHighPrice, 1.2
);
"PLowPrice: " + NumToStr( PLowPrice, 1.2
);
"Buy: " +  NumToStr( Buy, 1.2
);
"Short: " + NumToStr( Short, 1.2
);

PositionSize = MarginDeposit
;