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

[amibroker] Re: Simple (in practice) Weekly System - help with code please...Anyone???



PureBytes Links

Trading Reference Links

Anyone have any ideas??

Any suggestions would be much appreciated.

Thanks
Sam
--- In amibroker@xxxxxxxxxxxxxxx, "ss_aussie" <ss_aussie@xxx> wrote:
>
> 
> Hi all,
> 
> I am hoping that someone will be able to help me with my code.  I 
am not
> exactly a coder, but have been working on it...
> 
> I am trying to code the following for any market, but would like to 
test
> it initially on Forex;
> 
> Place trades 50 PIPS above OR below the Close for the previous week.
> 
> Open on the Monday OR Tuesday of the trading session for that week.
> 
> If the "Buy" is executed, move the sell up to the previous weeks 
close
> If the "Sell" is executed, move the buy down to the previous weeks 
close
> 
> Use a fixed 30 PIP stop. No profit targets. Let the trade run for 
the
> entire week AND Close
> during the final 30 minutes of the market for the week.
> 
> 
> Example:
> 
> Previous weekly close: 1.9597
> Buy: 1.9647
> Sell: 1.9547
> 
> The following rule is a bit different than most trading systems of 
this
> style:
> 
> If the "Buy" is executed, move the sell up to the previous weeks 
close
> (1.9597 in this case)
> 
> If the "Sell" is executed, move the buy down to the previous weeks 
close
> (in this case likewise 1.9597)
> 
> 
> Here is the code I have come up with so far.  I have found that the 
most
> challenging thing is to get it to flip the trade I.e. if stopped 
out, to
> move the entry again and trading the other way.  I.e. if stopped 
out of
> the initial long position, to move the target entry for going 
short.  I
> can't work out how to make it go short (on same day if the new 
target is
> hit).
> 
> SetOption("InitialEquity",10000);
> 
> SetTradeDelays(0,0,0,0);
> 
> LastWeekClose = TimeFrameGetPrice("C", inWeekly, -1);
> 
> LastWeekOpen = TimeFrameGetPrice("O",inWeekly,-1);
> 
> LastWeekLow = TimeFrameGetPrice("L",inWeekly,-1);
> 
> LastWeekHigh = TimeFrameGetPrice("H",inWeekly,-1);
> 
> WeeklyTarget = LastWeekClose;
> 
> WeeklyLongEntryLevel = WeeklyTarget + 0.0050;
> 
> WeeklyShortEntryLevel = WeeklyTarget - 0.0050;
> 
> BuyStopCrossed = Cross(H,WeeklyLongEntryLevel);
> 
> ShortStopCrossed = Cross(WeeklyShortEntryLevel,L);
> 
> InitialLongStop = WeeklyLongEntryLevel - 0.0030;
> 
> InitialShortStop = WeeklyShortEntryLevel + 0.0030;
> 
> BuyExecuted = IIf(BuyStopCrossed==1,1,0);
> 
> ShortExecuted = IIf(ShortStopCrossed==1,1,0);
> 
> MoveBuy = IIf(ShortExecuted,WeeklyTarget,WeeklyLongEntryLevel);
> 
> MoveShort = IIf(BuyExecuted,WeeklyTarget,WeeklyShortEntryLevel);
> 
> BuyStop = MoveBuy;
> 
> SellStop = MoveShort;
> 
> Buy = Cross( High, BuyStop ) AND (DayOfWeek()==1 OR DayOfWeek()==2);
> 
> Short = Cross( SellStop,Low )AND (DayOfWeek()==1 OR DayOfWeek()==2);
> 
> Sell = DayOfWeek()==5;
> 
> Cover = DayOfWeek()==5;
> 
> BuyPrice = Max( BuyStop, Low ); // make sure buy price not less 
than Low
> 
> SellPrice = C;
> 
> ShortPrice = Max(Sellstop, High);
> 
> CoverPrice = C;
> 
> ApplyStop(stopTypeLoss,stopModePoint,0.0030,1,0);
> 
> I would really appreciate some help on where I am going wrong.
> 
> Thanks,
> 
> Sam
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

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

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

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