Hair Loss on a simple thing

#1
Hey all!
I'm having problems with my new trade system and although it looks like a really simple thing, I canot find the answer. I've been looking through the internet for hours now and nothing...
All I want is something like this:
(1-minute candles, for example)
Buy=cross(close,ma(close,5));

But then I want the order not to go on this bar (which crossed the MA), I want it to go on the next bar AND I want the buy price to be the bar before the cross' close plus 0.50 (for example).
So it would be like this:
bar at 13:05:59 closes at 50.43
bar at 13:06:59 closes at 51.03 (this one crossing the MA)
Just after this closing, I want it to send an order to buy at 50.93 (50.43+0.50).
If the low at bar 13:07:59 is higher than 50.93 I wouldn't be able to enter the trade.

I tried:
buyprice=ref(close,-2)+0.50
Buy=cross(close,ma(close,5)) AND low<buyprice;

tried as well:
buyprice=ref(close,-2)+0.50
Buy=cross(close,ma(close,5)) AND low<buyprice;
entryprice=valuewhen(buy,buyprice)

But none worked. In both cases Amibroker gives me the bar at 13:07:59's close as the entry price.

Please, can someone help me???
Thanks in advance!
 

casoni

Well-Known Member
#2
Hey all!
I'm having problems with my new trade system and although it looks like a really simple thing, I canot find the answer. I've been looking through the internet for hours now and nothing...
All I want is something like this:
(1-minute candles, for example)
Buy=cross(close,ma(close,5));

But then I want the order not to go on this bar (which crossed the MA), I want it to go on the next bar AND I want the buy price to be the bar before the cross' close plus 0.50 (for example).
So it would be like this:
bar at 13:05:59 closes at 50.43
bar at 13:06:59 closes at 51.03 (this one crossing the MA)
Just after this closing, I want it to send an order to buy at 50.93 (50.43+0.50).
If the low at bar 13:07:59 is higher than 50.93 I wouldn't be able to enter the trade.

I tried:
buyprice=ref(close,-2)+0.50
Buy=cross(close,ma(close,5)) AND low<buyprice;

tried as well:
buyprice=ref(close,-2)+0.50
Buy=cross(close,ma(close,5)) AND low<buyprice;
entryprice=valuewhen(buy,buyprice)

But none worked. In both cases Amibroker gives me the bar at 13:07:59's close as the entry price.

Please, can someone help me???
Thanks in advance!

hello,
if i understand your problem correctly
then this will solveyour problem,
add this below your buy condition
buy=ref(buy,-1);
so this will fire signal on next bar
hope this helps
thank you
 
#3
Try

Code:
Buy = ref(close,-1) > ref(ma(close,5),-1) and cross(H, ref(h,-2)+0.5)
on last bar C > MA and current price is more than H+0.5 of the bar previous to the bar that generated the buy signal


:) Happy
 
#4
Hey, Thanks!
It generated the buy signal but at the closing price of the last bar (because it's set on Settings->Trades-> Buy Price-> CLOSE. I can choose Close, Open, High, Low and Average, but not this custom price).
 
#5
Sorry, Casoni!
Just saw your message now. But it didn't work as well. I keep getting the closing price of the last bar as entry price and not my price (bar before cross' close+0.50)
 
#6
Add this line

Code:
Buy = ref(close,-1) > ref(ma(close,5),-1) and cross(H, ref(h,-2)+0.5);
BuyPrice = ref(h,-2)+0.5;

:) Happy
 
#7
Thanks, but it still doesn't work. It keeps giving me the CLOSE for that bar as the trading price and not (ref(h,-2)+0.5). On settings I can choose Open, Close, High and Low, but nothing in between.
 

Similar threads