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

RE: [amibroker] Price Oscillator



PureBytes Links

Trading Reference Links

Totally wrapped around the axle tonight and need some HELP!!

I'm trying to figure out how to take a routine such as the simple one below:

--------------------------------8<-----------------------------------------

SetOption("InitialEquity", 100000 );

function CMO(Price, Length)
{
    CMOup    = IIf(Price > Ref(Price, -1), Price - Ref(Price, -1), 0);
    CMOdn    = IIf(Price < Ref(Price, -1), Ref(Price, -1) - Price, 0);

    CMOSumUp = Sum(CMOup, Length);
    CMOSumDn = Sum(CMOdn, Length);

    CMOx     = 100 * (CMOSumUp - CMOSumDn) / (CMOSumUp + CMOSumDn);

    return (CMOx);
}

BuyPrice = SellPrice = ShortPrice = CoverPrice = Open;
SetTradeDelays(1, 1, 1, 1);

CmoSig = Cmo(C, 5);

/* Test trigger levels and calc different metrics */

for (CMOLevel = 10; CMOLevel < 50; CMOLevel++)
{
    PositionSize = 1000;
    
    Buy          = Cross(-CMOLevel, CmoSig);
    Sell         = Cross( CmoSig, CMOLevel);

    Short        = Sell;
    Cover        = Buy;
    
}

NumColumns = 1;

Filter = 1;

--------------------------------8<-----------------------------------------

And add code in the for loop to figure out the following metrics:

For each trigger level:
    Number of Shorts within the date range of the test.
    Number of Longs.
    Number of profitable Shorts
    Number of profitable Longs
    Avg Pft% per Bar of the shorts
    Avg Pft% per Bar of the longs

Then I need to take the above and 

     See if all of the triggers were profitable
     Pick the best trigger based on Total Pft % / Bar
     Pick the best trigger based on best Pct winners of Longs + Shorts

Soooo, How 'bout some of you array savants give me some pointers before I go
to out to the pickup truck and get the gun outta the rack in the rear window
and make a big mess that the little woman'll have to clean up?  (feeling
very redneck tonight it seems..!!)

TIA

d
    



Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
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/