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

Re:[amibroker] Loop help please!



PureBytes Links

Trading Reference Links

OK, 

have kept at it, but just can't get my head around it. Below is the pseudo code as my logic sees it. Obviously it doesn't work. Help appreciated.

trig= Ref(H,-2) > Ref(H,-3) AND Ref(H,-3) > Ref(H,-4) ;//AND Ref(L,-2) >= Ref(L,-3) AND Ref(L,-3) >= Ref(L,-4)

sl = Optimize("sl", 0.006, 0.001, 0.015, 0.0005);

profit = ApplyStop(stopTypeProfit, stopModePoint,Optimize( "max. profit stop level", 0.002, 0.001, 0.015, 0.0005 ), 1,True );

profit = 0;

BuyPrice= 0;

Sellstop = 0;

Buy = trig;

for( i = 0; i < BarCount; i++ )

{

if( BuyPrice == 0 && Buy[ i ] == 1 ) // A buy is signalled

BuyPrice = ValueWhen(Buy[i+1],O); // read *next* value of array after buy signal to get the "Buy on open, delay 1 " value

Low_of_entrybar = ValueWhen(Buy [i+1], L) - sl; //entry bar low value minus the 0.00x filter

Sellstop = Cross(Low-Of_entrybar,C); //sell if close less then Low_of_entrybar value


if(Sellstop == 1 OR profit == 1) // test to see if either a seelstop or profit stop value true

{

Sell [i] =1;

SellPrice[i] = IIf(Sellstop,ValueWhen(Cross(Low-Of_entrybar,L), profit); //choose which value to assign to Sellprice

Sellstop = 0; //reset values to 0

BuyPrice = 0;

}

else

Sell[i] = 0;

}







----- Original Message ----- 
From: "Beachie" <beachie41@xxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Saturday, November 06, 2004 9:48 PM
Subject: [trading] [amibroker] Loop help please!


> 
> Ok, need some help please....programming is not my strongest point :(
> Can someone be kind enough to correct/ammend the code I've put together, so that it 
> reflects what I'm *really* trying to accomplish.
> Which is:
> retrieve the "Low" price when the Buy ==1, buy on open next day, set a stoploss that is 
> 0.005 ( forex ) below the low of the bar I entered on. Sell if Close crosses the Stoploss 
> or the Applystop Profit target.
> I've tried different permutations but my head goes to jelly when trying to think in terms 
> of loops etc.
> 
> profit = ApplyStop(stopTypeProfit, stopModePoint,Optimize( "max. profit stop level", 
> 0.002, 0.001, 0.015, 0.0005 ), 1,True );
> 
> trig= Ref(H,-2) > Ref(H,-3) AND Ref(H,-3) > Ref(H,-4) ;
> sl = Optimize("sl", 0.005, 0.001, 0.015, 0.0005);
> Buy = trig;
> ValueWhen(Buy,C); //I know this isn't right. How do I retrieve the value of the Open of 
> the next day?
> BuyPrice= 0;
> Sellstop = 0;
> for( i = 0; i < BarCount; i++ )
> {
> if( BuyPrice == 0 && Buy[ i ] )
> BuyPrice = Valuewhen(Buy,C); // Won't accept an array
> Sellstop = BuyPrice - sl;
> if(Sellstop = 0 && Cross(SellPrice[i], Sellstop) OR profit == 1 )
> 
> /* and here to kicks back with array errora nd I don't know how to assign to SellPrice 
> either the Sellstop or profit price, depending on which was hit first*/
> {
> Sell [i] =1;
> SellPrice[i] = Sellstop OR  proft; ///???????
> Sellstop = 0;
> }
> else
> Sell[i] = 0;
> }
> 
> 
> thanks!! 
> 


[Non-text portions of this message have been removed]



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