- Joined
- 26 February 2007
- Posts
- 358
- Reactions
- 0
Also having a lot of trouble getting my buy price formula working.
I want to buy on the day after my signal, 2 price units under the close of the signal bar.
I've tried combinations of BuyPrice and EntryPrice but no luck.
SetTradeDelays(1,1,0,0);
Buy = Cross(MACD(), Signal());
BuyPrice = Ref(C, -1) - 0.02;
Sell = Cross(Signal(), MACD());
Well Synergy if you want to buy the day after the signal then SetTradeDelays(1,1,0,0); does that.I want to buy on the day after my signal, 2 price units under the close of the signal bar.
Cheers Wysi, easy in theory, but I can't get mine to work!
I've tried what you've posted, but the buy can't be ref -1, or it works off the day before the signal. The signal day is ref 0 I assume.
Here is what I'm using:
BuyPrice = Close - (3 * PriceUnit);
IIf (BuyPrice >= Ref(Open, 1), BuyPrice == Ref(Open, 1), BuyPrice);
Cond15 = BuyPrice >= Ref(Low, 1);
Generally it works, but it doesn't work every time. And when it doesn't work I can't see any logical reason why it isn't working. The buy price appears to be random. I know theres something wrong, and I've tried a lot of things. For some reason the == there gives better results than =. I don't know enough yet to know where I'm going wrong.
Here is what I'm using:
BuyPrice = Close - (3 * PriceUnit);
IIf (BuyPrice >= Ref(Open, 1), BuyPrice == Ref(Open, 1), BuyPrice);
Cond15 = BuyPrice >= Ref(Low, 1);
Hi Synergy,
Does this solve the problem ("PriceUnit" calculation code assumes you are using ASX equities)?
//"SetTradeDelays" function is used for back-testing.
SetTradeDelays(1,1,0,0);
PriceUnit:=
IIf(Close <= 0.10,0.001,
IIf(Close <= 2,00.005,0.01));
EntryTrigger:=
YourEntryConditions;
Buy=EntryTrigger;
EntryPrice:=Ref(Close - MinTick*2,-1);
BuyPrice:=IIF(Open<EntryPrice,Open,EntryPrice);
SetTradeDelays( 0, 0, 1, 1 );
PriceUnit = IIf(Ref(C,-1) < .1, 0.001, .005);
EntryPrice = Ref(C, -1) - 3 * PriceUnit;
Cond14 = EntryPrice >= Low;
Buy = *buy conditions* AND Cond14;
BuyPrice = IIf (entryprice >= Open, Open, EntryPrice);
How do I code a filter for:
Todays close has increased 20%+ from yesterday's close.
Thanks
How do I code a filter for:
Todays close has increased 20%+ from yesterday's close.
Thanks
I'm trying to set up a manual EMA.
The first bar of data for the EMA is just a simple average of the first x bars.
After that the EMA relies on the EMA for the previous day.
I'd like to know how to identify the first day of data, to calculate the initial average.
And i've got no idea how to reference the previous days EMA.
Cheers
EMAprd = 10;
ExEMA = EMA(Close,EMAprd);
Count = Cum(1);
SMA = Cum(Close)/Count;
MyEMA = IIf(IsNull(ExEMA),SMA,ExEMA);
Plot(MyEMA,"My EMA",colorRed);
//get last 20 highs
wh1 = Ref( H, -1 );
wh2 = Ref( H, -2 );
wh3 = Ref( H, -3 );
wh4 = Ref( H, -4 );
wh5 = Ref( H, -5 );
wh6 = Ref( H, -6 );
wh7 = Ref( H, -7 );
wh8 = Ref( H, -8 );
wh9 = Ref( H, -9 );
wh10 = Ref( H, -10 );
wh11 = Ref( H, -11 );
wh12 = Ref( H, -12 );
wh13 = Ref( H, -13 );
wh14 = Ref( H, -14 );
wh15 = Ref( H, -15 );
wh16 = Ref( H, -16 );
wh17 = Ref( H, -17 );
wh18 = Ref( H, -18 );
wh19 = Ref( H, -19 );
wh20 = Ref( H, -20 );
//get last 20 lows
wl1 = Ref( L, -1 );
wl2 = Ref( L, -2 );
wl3 = Ref( L, -3 );
wl4 = Ref( L, -4 );
wl5 = Ref( L, -5 );
wl6 = Ref( L, -6 );
wl7 = Ref( L, -7 );
wl8 = Ref( L, -8 );
wl9 = Ref( L, -9 );
wl10 = Ref( L, -10 );
wl11 = Ref( L, -11 );
wl12 = Ref( L, -12 );
wl13 = Ref( L, -13 );
wl14 = Ref( L, -14 );
wl15 = Ref( L, -15 );
wl16 = Ref( L, -16 );
wl17 = Ref( L, -17 );
wl18 = Ref( L, -18 );
wl19 = Ref( L, -19 );
wl20 = Ref( L, -20 );
adr1 = (wh1+wh2+wh3+wh4+wh5+wh6+wh7+wh8+wh9+wh10+wh11+wh12+wh13+wh14+wh15+wh16+wh17+wh18+wh19+wh20)-(wl1+wl2+wl3+wl4+wl5+wl6+wl7+wl8+wl9+wl10+wl11+wl12+wl13+wl14+wl15+wl16+wl17+wl18+wl19+wl20);
//20 period average
tadr = ((adr1)/20);
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?