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

Re: [amibroker] Loop help please!



PureBytes Links

Trading Reference Links

Thanks. The iff /if etc errors where only caused by me typing directly the email, instead 
of copy paste from AB. I'm aware that the array was being copied in where a numeric or 
Boolean was required. And that's the whole crux of the problem. I need to be able to get 
the result given by the Arrays Open, profit etc, but for the life of me can't figure how 
to assign them so that they the fill a variable that will pass the numeric/Boolean 
requirement. The pseudo code was for illustration of where I'm stuck.

An my comment still stands, this is overly complicated for such a simple & basic 
requirement of being able to compare, while the current Buy is valid , succeeding prices 
against the OHLC of the entry bar *without* new buy signals skewing the backtests.

Perhaps I should ask for help on creating a triple T3 with DEMA X-over & lowered momentum 
with twin SAR foxtails and nitro MACD's.......

----- Original Message ----- 
From: "Paul Chivers" <pchivers@xxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Sunday, November 07, 2004 5:46 PM
Subject: [trading] Re: [amibroker] Loop help please!


>
> Beachie,
>
> I'm not going to debug this for you but the following will see you well on
> your way.
>
> The error message is correct and is telling you what you are doing wrong.
>
> Have a look at the "Reserved variable names" table in "Back-testing your
> trading ideas" in the User Guide.  All of these are arrays.
>
> So, where your code says "if( BuyPrice == 0 && Buy[ i ] )" you are
> attempting to compare the ENTIRE BuyPrice array to 0.  This is one instance
> of what that error message is complaining about.  I would suggest trying
> "if( BuyPrice[i] == 0 && Buy[ i ] )".
>
> And so on for the other arrays inside the for loop.
>
> Where you write "BuyPrice = O; //Buyprice set to open" you are copying the
> ENTIRE Open array into the (entire) BuyPrice array *every* time around the
> for loop.  I'm sure this is not what you want.
>
> Where you write "Sellstop = Low - filter;"  you are (or AB is) creating an
> intermediate/temporary array filled with the calculation for "Low - filter"
> for each bar and copying that entire array into the Sellstop array *every
> time around the for loop*.
>
> And so on for all the other arrays.
>
> I suggest you read "Understanding how AFL works" in the "AmiBroker Formula
> Language" section of the Tutorials in the AmiBroker User's Guide.
>
> You also don't appear to understand the difference between "if" and "iif".
> Again, this is covered in the User's Guide.  e.g. You write "iif(Close <
> Sellstop)".  This is combining multiple mistakes.
>
> There are other errors but until you fix the basics there's no point
> covering them.
>
> HTH
>
> Paul
>
> ----- Original Message ----- 
> From: "Beachie" <beachie41@xxxxxxxxxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Sunday, 7 November 2004 2:04 PM
> Subject: Re: [amibroker] Loop help please!
>
>
>
> OK, I've posting one more time, in case *someone* out there can at least
> show me how to do
> this using loops. Otherwise I'll use the rem.dll. that someone was kind
> enough to point
> out to me off list.
> Why is it so difficult to implement the simplest of trading rules i.e sell
> if a succeeding
> close is below the low of the entry bar? Does everyone mainly use the canned
> stops?
> I can't really explain what I'm trying to do any simpler than what I have
> in the previous
> posts.
> The code below won't work because  I get  the "Condition in IF, WHILE, FOR
> statements has
> to be Numeric or Boolean type.You can not use array here, please use []
> (array subscript
> operator) to access array elements" error msg.
> I *do not know* how to work around this?!?!?
>
> BuyPrice= 0;
>
> Sellstop = 0;
>
> Buy = Ref(trig,-1); // buy condition triggered prev bar allowing me to set
> buyprice to
> open which is equivalent to Buy on Open Delay 1
>
> BuyPrice = Open;
>
> for( i = 0; i < BarCount; i++ )
>
> {
>
> if( BuyPrice == 0 && Buy[ i ] )
>
> BuyPrice = O; //Buyprice set to open
>
> Sellstop = Low - filter; // Low of entry bar minus x.xxx points. This is the
> filter. If a
> succeeding close drops below this level the trade is stopped out
>
> }
>
>
>
> iif(Close < Sellstop) //test to see if close less than stop. If not, then
> drop down to
> next iif statement
>
> {
>
> Sell [i] =1;
>
> SellPrice[i] = Sellstop;
>
> Sellstop = 0;
>
> BuyPrice = 0;
>
> }
>
> if( ApplyStop(stopTypeProfit,stopModePoint,0.005, 1) == 1 ) //test to see if
> Profit stop
> hit.
> {
>
> Sell[i] = 1;
>
> SellPrice[i] = ApplyStop(stopTypeProfit,stopModePoint,0.005, 1);
>
> Sellstop = 0;
>
> BuyPrice = 0;
>
> }
>
> else
>
> Sell[i] = 0;
>
> }
>
>
>
>
> Check AmiBroker web page at:
> http://www.amibroker.com/
>
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> Yahoo! Groups Links
>
>
>
>
>
>
>
> 




------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.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/