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

Re: [amibroker] Help with formula


  • Date: Sat, 23 Jan 2010 01:37:59 -0500
  • From: Keith McCombs <kmccombs@xxxxxxxxxxxx>
  • Subject: Re: [amibroker] Help with formula

PureBytes Links

Trading Reference Links



Anthony --

I have added comments to your code below:
// Anthony.afl

Buy=Cross(C,EMA(C,19));
Sell=Cross(EMA(C,19),C) ;
CumCst=0.00;
poslong=0;
posshort=0;
for (i=1; i < BarCount; i++)
{
    if(Buy[i])
    {
    poslong==1;    // == doesn't set poslong to 1, it stays 0
    posshort==0;   //  use = to set value
    CumCst[i]=0.10;
    }

    if(Sell[i])
    {
        poslong==0;
        posshort==1;    // == doesn't set posshort to 1, it stays 0
        CumCst[i]=0.10; 
//  use = to set value
    }

    if(posshort) // posshort is 0 and code below is never executed
    {
        if(C[i] < C[i-1])
            CumCst[i] = CumCst[i-1] + 0.003;
        else
            CumCst[i] = CumCst[i-1];
    }

    if(poslong) // poslong is 0 and code below is never executed
    {
        if(C[i] > C[i-1])
            CumCst[i] = CumCst[i-1] + 0.003;
        else
            CumCst[i] = CumCst[i-1];
    }
 

Keith,
 
Thanks...but that does not seem to be the problem..when there is a signal
buy or sell...cumCST starts at 0.10 and increments by 0.003 as per the
formula...that is not happening....it must be something else
 
Anthony
 
 
 
 
----- Original Message -----
Sent: Friday, January 22, 2010 10:35 PM
Subject: Re: [amibroker] Help with formula

 

In four places you used == where you should have used >
Anthony Faragasso wrote:

 

Hello,

Could someone look at this please...I can not see the error...

The cumCST should increment up to .13 but it is not happening..

 

Thank you

Anthony

 

Buy=Cross(C,EMA(C,19));

Sell=Cross(EMA(C,19),C) ;

CumCst=0.00;

poslong=0;

posshort=0;

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

{

if(Buy[i])

{

poslong==1;

posshort==0;

CumCst[i]=0.10;

}

if(Sell[i])

{

poslong==0;

posshort==1;

CumCst[i]=0.10;

}

 

if(posshort)

{

if(C[i] < C[i-1])

CumCst[i] = CumCst[i-1] + 0.003;

else

CumCst[i] = CumCst[i-1];

}

if(poslong)

{

if(C[i] > C[i-1])

CumCst[i] = CumCst[i-1] + 0.003;

else

CumCst[i] = CumCst[i-1];

}

if(CumCst[i] >= 0.13)

CumCst[i] = 0.13;

}

per=19;

Smth=2/(per+1)+CumCst;

MovAvg=AMA(C,Smth);

Plot(movavg,"",colorBlue,1);

Plot(C,"",1,64);

 

PlotShapes(Buy*shapeUpArrow,colorGreen,0,L,-20);

PlotShapes(Sell* shapeDownArrow,colorRed,0,H,-20);

Title="cumulative value = "+WriteVal(Cumcst,1.3);



__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___