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

Re: [amibroker] Help with Scrip



PureBytes Links

Trading Reference Links

You are mixing loop code with array code. That won't work. You have to 
use one or the other.
For example, replace this:

    if (S1[0] < Low[0]) //This only tests the first bar, everytime for every bar so no signals.
    Buy = 0;
    else if (S1[0] > Low[0]) //Same here
    Buy = S1;

With this:

    Buy = S1 > Low; //This sets all bars at once

Same idea for Sell.

Terry

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
>
>
>
>
>
>
>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
>
>
>
> 
>
>
>
>
>  
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/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/