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

Re: [amibroker] Re: How do you know what your last trade was



PureBytes Links

Trading Reference Links

Fred,

Please expand. I have tried that with no success. You will get the array not
initialized or similar error if you try to see if youıre on a Buy signal
before you get to the Buy statement. Initializing it such as Buy = 0;
removes the error message, but has no effect; i.e., you canıt know ahead of
time if youıre on a buy or not.

If you have a way, that would be nice.

Thanks.
-- 
Terry


From: "Fred" <ftonetti@xxxxxxxxxxxxx>
Reply-To: amibroker@xxxxxxxxxxxxxxx
Date: Tue, 05 Oct 2004 03:11:27 -0000
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: How do you know what your last trade was


... or ... you can simply check the buy, sell, short, cover arrays ...

One can restate these as often as one wants, the last one of each
counts.  This for example is one way to do equity feedback.

--- In amibroker@xxxxxxxxxxxxxxx, Terry <MagicTH@xxxx> wrote:
> micmus2002,
> 
> Hereıs what I use. All my code above /* The Trading Signals */ is
to decide
> what my conditions for Buy/Sell are and are in a LOOP. In this loop
I
> determine if Iım on a buy or a sell. Then I execute the regular
BUY/SELL
> commands after Iıve figured out whatıs going on day by day in the
loop. Here
> I have used my loop variables to tell me if Iım on a Buy or a Sell.
This
> particular code is always in the market so Short = Sell and Cover =
Buy. You
> may have to extend it if you have separate signals. Watch out for
line
> wraps.
> 
> PS: You need a loop because arrays are calculated as they are
encountered,
> thus you canıt read the Buy array before itıs been computed. Loops
let you
> do that.
> 
> for loop goes here()
> {
>     Your rules for trading go here
>  
>     /*   The Trading Signals   */
>  
>     if (Cond1[I] OR Cond2[I]) newBuy[i] = True;
>     if (Cond3[I] OR Cond4[I]) newSell[i] = True;
>     if (newBuy[i] OR (onBuy[i-1] AND NOT newSell[i])) //IF both are
True,
> Long signal wins!
>     {
>          onBuy[i] = True; //Daily Buy State
>          newSell[i] = False; //In case of both being true due to
rule
> sequencing (Can't happen! But will leave as insurance.)
>     }
>     onSell[i] = NOT onBuy[i]; //If it's not onBuy then it's onSell
>  
>     //Record bar of new Entry whether it is Buy or Sell isn't
important
>     if (newBuy[i] OR newSell[i])
>       entry[i] = i;
>     else
>       entry[i] = entry[i-1]; //continue yesterday's value if no new
signals
> }
>  
> /* End of looping Rules tests and Buy/Sell signals. Now just
execute the
> results */
> 
> Buy = newBuy;
> gainbuy = IIf(OnBuy,(C - ValueWhen(Buy,BuyPrice,1)) /
> ValueWhen(Buy,BuyPrice,1),0);
> BuyStopValue = IIf(newSell,1,IIf(gainbuy <= -7,2,IIf(BarsSince(Buy)
>
> 4,5,0)));
> Sell = BuyStopValue;
> Short = newSell; //A_LiU > 0; //Avoids shorting all D rules...goes
to Cash
> gainsell = IIf(OnSell,(C - ValueWhen(Short,ShortPrice,1)) /
> ValueWhen(Short,ShortPrice,1),0);
> SellStopValue = IIf(newBuy,1,IIf(gainsell <= -4,2,IIf(BarsSince
(Short) >
> 3,5,0)));
> Cover = SellStopValue; //Buy;
> 
> -- 
> Terry
> 
> 
> From: "micmus2002" <micmus2002@xxxx>
> Reply-To: amibroker@xxxxxxxxxxxxxxx
> Date: Tue, 05 Oct 2004 02:34:10 -0000
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] How do you know what your last trade was
> 
> 
> I want to write stop logic, but since its based on a logical test I
> cannot seem to use the applystop function.
> 
> Therefore  it seems I will need to have another Cover /Sell
statement
> which will only be triggered if I already have an opposite position.
> i.e. Cover if am already Short and my stop condition is true, and
> Sell if I am already long and that stop position is true.
> 
> This means I need to know what my current position is, and my
> question is how do I do this. I know Wealthlab has a Position Array
> but I can't find anything similar in AB.
> 
> I am sure there must be a way to do this. Would be grateful if
> someone could provide the code.
> 
> Thanks
> 
> 
> 
> [Non-text portions of this message have been removed]





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

Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html


Yahoo! Groups Sponsor
 <http://us.ard.yahoo.com/SIG=12949g2ik/M=294150.5475417.6555471.1269404/D=g
roups/S=1705632198:HM/EXP=1097032303/A=2380089/R=0/SIG=12adlsi8e/*http://mor
tgages.interest.com/includes/server/icom_campaign.asp?id=10716>
<http://us.ard.yahoo.com/SIG=12949g2ik/M=294150.5475417.6555471.1269404/D=gr
oups/S=1705632198:HM/EXP=1097032303/A=2380089/R=1/SIG=12adlsi8e/*http://mort
gages.interest.com/includes/server/icom_campaign.asp?id=10716>
Select Your State: Alabama Alaska Arkansas Arizona California Colorado
Connecticut Delaware Florida Georgia Hawaii Idaho Illinois Indiana Iowa
Kansas Kentucky Louisiana Maine Maryland Massachusetts Michigan Minnesota
Missippi Missouri Montana Nebraska Nevada New Hampshire New Mexico New
Jersey New York North Carolina North Dakota Oklahoma Ohio Oregon
Pennsylvania Rhode Island South Carolina South Dakota Tennessee Texas Utah
Vermont Virginia Washington Washington D.C. West Virginia Wisconsin Wyoming

Purchase Refinance 

 <http://us.ard.yahoo.com/SIG=12949g2ik/M=294150.5475417.6555471.1269404/D=g
roups/S=1705632198:HM/EXP=1097032303/A=2380089/R=3/SIG=12adlsi8e/*http://mor
tgages.interest.com/includes/server/icom_campaign.asp?id=10716>


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
<mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
*  
* Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> .




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