PureBytes Links
Trading Reference Links
|
Thanks, I understand now!
MagicTH@xxxxxxxxxxx wrote:Bert,
I found the code I used before for trading Long/Short funds. My LSC is
my buy-sell-cash condition. Substitute your own conditions and funds.
//Trading System
RestorePriceArrays();
LSC = IIf(CCTI > CTIa,1,IIf(CCTI < CTIb,-1,0)); //LSC = LongShortCash
Buy = (LSC == 1 AND Name()=="UAPIX") OR (LSC == -1 AND Name()=="UCPIX");
Sell = (LSC != 1 AND Name()=="UAPIX") OR (LSC != -1 AND Name()=="UCPIX");
Short = LSC == 2; //Dummy value to avoid missing Short
Cover = LSC == 4; //Dummy value to avoid missing Cover
--- In amibroker@xxxxxxxxxxxxxxx, Terry <MagicTH@xxxx> wrote:
> Bert,
>
> Since theyıre funds, youıre BUYING both funds. Also, you would never
SELL
> anything, you would SHORT it. SELL just closes your BUY position.
So, you
> need to do something like this assuming you want to always be in the
market
> and your just switching funds (code untested):
>
> Buy = IIf(Cond1 and Name() = "NTHEX") or (Cond2 and Name() =
> "FDRXX"),true,false);
> Sell = "I'm not sure how to get you out of each position. Possibly
if you
> have MaxPositions = 1 it will get handled automatically."
> Short = false; //Not shorting anything
> Cover = false;
>
> > Hello,
> >
> > I would appreciate it if someone can help with the following "PROBLEM
> > AREA" in my code. (See "PROBLEM AREA" below.)
> >
> > Thanks,
> >
> > Bert
> >
> > // -------------------------------------
> >
> > JB_Price = Foreign("NTHEX", "C");
> >
> > Cond1 = JB_Price >= EMA( JB_Price, 20) ;
> >
> > BuyState = Cond1 ;
> >
> > Cond2 = JB_Price < EMA( JB_Price, 20 );
> >
> > SellState = Cond2;
> >
> > // PROBLEM AREA STARTS HERE.
> > //
> > // I HAVE THE 2 FUNDS IN A WATCHLIST AND I USE
> > // FILTER TO SELECT THIS WATCH LIST.
> > // HOW DO I TELL THE AA TO BUY NTHEX AND SELL
> > // FDRXX WHEN SIGNAL IS ON A BUY, AND
> > // TO SELL NTHYX AND BUY FDRXX WHEN SIGNAL
> > // IS ON A SELL.
> > // I KNOW THE FOLLOWING IS WRONG, BUT THE CONCEPT IS
> > // OK.
> >
> > Buy = IIf(Name() == "NTHEX", BuyState, SellState);
> > Sell = IIf(Name() == "FDRXX", SellState, BuyState);
> >
> >
> >
> > 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
> >
> > ADVERTISEMENT
> >
<http://us.ard.yahoo.com/SIG=129bafh11/M=298184.5285298.6392945.3001176/D=g=
rou
> >
ps/S=1705632198:HM/EXP=1093788454/A=2319501/R=0/SIG=11tq0u909/*http://www.n=
etf
> > lix.com/Default?mqso=60185353&partid=5285298>
> >
> >
> > 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/> .
> >
>
>
> --
> Terry
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups SponsorADVERTISEMENT
---------------------------------
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 the Yahoo! Terms of Service.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
[Non-text portions of this message have been removed]
------------------------ 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/
|