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

Re: [amibroker] Re: Help with Scrip Still not working??



PureBytes Links

Trading Reference Links

First, another member suggested using Cross. That is a better method than what I showed so you only get a single Buy condition at the moment it crosses support. Your description says to me you want to Buy when the Price crosses below the Support Level so use:

Buy = Cross(S1,Low);

As to the problem, set your BuyPrice and SellPrice before the Buy signal AND I would use either BuyPrice = Open with Trade Delays = 1 (buy at open of next bar) or
BuyPrice = Close with Trade Delays = 0 (buy on the same bar at the close of that bar). If you really want to Buy at your support level (which you can't control) I think simply moving the BuyPrice = S1 before the Buy statement will do it.

Terry

Ernie Newman wrote:
Thanks Terry
 I replaced the scrip with this as you suggested

PP = Ref(Avg,-1);
R1=(PP * 2) - Ref(Low,-1);
S1= (PP * 2) - Ref(High,-1);

Buy = S1 > Low;
BuyPrice = S1;
Sell = R1 < High;
SellPrice = R1;

 It stills buys the low or the S1 value. If the S1 value does not 
exist it will buy the low.
So I still need some help.
Thanks Ernie

--- In amibroker@xxxxxxxxxxxxxxx, Terry <MagicTH@xxxx> wrote:
  

Ernie Newman wrote:
I am trying to write a backtest to BUY at the Support level S1 and sell when the Resistance level R1 is reached. The codes I have been trying will not BUY at the S1 or Sell at R1. How can I get AB to only buy at S1 when the price has actually traded in that range. I would put in an order to buy that price if touched and sell at R1 if touched. I just can't seem to be able to backtest this. 


PP = Ref(Avg,-1);
R1=(PP * 2) - Ref(Low,-1);
S1= (PP * 2) - Ref(High,-1);

if (S1[0] < Low[0]) 
Buy = 0;
else if (S1[0] > Low[0])
Buy = S1;
BuyPrice = S1;
if (R1[0] > High[0])
Sell = 0;
else if (R1[0] < High[0])
Sell = R1;
SellPrice = R1;

THANKS Ernie







 

    





------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/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/
 




  


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