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

Re: [amibroker] Loop help please!



PureBytes Links

Trading Reference Links

OK, even my jellied brain saw the logic flaw in the previous pseudo code re: Valuewhen(Buy 
etc etc). Have corrected.



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 = Open[i+1] ; // read *next* value of array after buy signal to get the "Buy on 
open, delay 1 " value

 Low_of_entrybar = Low[i+1] - 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 sellstop 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>

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



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/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/