| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack (2) | Thread Tools | Display Modes |
|
|||
|
Profit/Loss - 221/3
Hello. An author asserts:System has 3 bad trades and 221 good trades in the last 3 months.
It is needed to correct errors in a code. //+------------------------------------------------------------------+ //| KurkaTrader.mq4 | //| Copyright © 2006, KurkaFund. | //| http://www.kurkafund.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2006, KurkaFund." #property link "http://www.kurkafund.com" //---- input parameters //trading parameters extern int MagicNumber = 12345; extern double Risk = 0.2; //percentag of AccountFreeMargin used to open position extern double TrailingStop = 20; extern double StopLoss = 20; extern double TakeProfit = 150; extern double Trend_Strength_1 = 0.25; //Trend strength, when true is used as a multiplier for entry extern double Trend_Strength_2 = 0.25; extern double Trend_Strength_3 = 0.5; extern double Trend_Strength_4 = 0.5; extern double Trend_Strength_5 = 1; extern double Trend_Strength_6 = 1; //Signal Parameters extern int Ema_1 = 96; extern int Ema_2 = 288; extern int Ema_3 = 864; extern int Ema_4 = 2592; extern int EmaShift = 0; extern int CciPer = 18; extern int CciLagPer = 3; extern int Cci_Level1 = 50; extern int Cci_Level2 = 100; extern int Cci_Level3 = 150; extern int EnvelopePeriod = 2; extern double Percent = 0.0032; extern int OSMAFast = 5; extern int OSMASlow = 30; extern double OSMASignal = 2; int start() { if(Bars<Ema_4) { Print("Not Enough Bars"); return(0); } if(AccountFreeMargin()<(1000*LotSize())) { Print("No Money. FreeMargin=",AccountFreeMargin()); return(0); } { // Additional identifiers to make the code easy. double SarCurrent = iSAR(NULL, 0, 0.02, 0.2, 0); double SarPrevious = iSAR(NULL, 0, 0.02, 0.2, 1); double CCI = iCCI(NULL,0,CciPer,PRICE_CLOSE,0); double CCIPrevious = iCCI(NULL,0,CciPer,PRICE_CLOSE,1); double HighEnvelope1 = iEnvelopes(NULL,0,EnvelopePeriod,MODE_SMA,0,PRICE_ CLOSE,Percent,MODE_UPPER,0); double LowEnvelope1 = iEnvelopes(NULL,0,EnvelopePeriod,MODE_SMA,0,PRICE_ CLOSE,Percent,MODE_LOWER,0); double CloseBar1 = iClose(NULL,0,0); double HighEnvelope1Previous = iEnvelopes(NULL,0,EnvelopePeriod,MODE_SMA,0,PRICE_ CLOSE,Percent,MODE_UPPER,1); double LowEnvelope1Previous = iEnvelopes(NULL,0,EnvelopePeriod,MODE_SMA,0,PRICE_ CLOSE,Percent,MODE_LOWER,1); double CloseBar1Previous = iClose(NULL,0,1); double Stoc = iCustom(NULL, 0, "Zerolagstochs", 0,0); double StocPrevious = iCustom(NULL, 0, "Zerolagstochs", 0,1); double OsMABar2=iOsMA(NULL,0,OSMASlow,OSMAFast,OSMASignal ,PRICE_CLOSE,2); double OsMABar1=iOsMA(NULL,0,OSMASlow,OSMAFast,OSMASignal ,PRICE_CLOSE,1); //Trend EMA's double Ema1 = iMA(NULL,0,Ema_1, 0,MODE_EMA, PRICE_CLOSE, EmaShift); double Ema2 = iMA(NULL,0,Ema_2, 0,MODE_EMA, PRICE_CLOSE, EmaShift); double Ema3 = iMA(NULL,0,Ema_3, 0,MODE_EMA, PRICE_CLOSE, EmaShift); double Ema4 = iMA(NULL,0,Ema_4, 0,MODE_EMA, PRICE_CLOSE, EmaShift); double Ema1Previous = iMA(NULL,0,Ema_1, 0,MODE_EMA, PRICE_CLOSE, EmaShift-1); double Ema2Previous = iMA(NULL,0,Ema_2, 0,MODE_EMA, PRICE_CLOSE, EmaShift-1); double Ema3Previous = iMA(NULL,0,Ema_3, 0,MODE_EMA, PRICE_CLOSE, EmaShift-1); double Ema4Previous = iMA(NULL,0,Ema_4, 0,MODE_EMA, PRICE_CLOSE, EmaShift-1); //Up Trend Calcs double up1 = 0 if (Ema1 > Ema2) up1 = Trend_Strength_1; double up2 = 0 if ((Ema1 > Ema2) && (Ema1 > Ema3)) up2 = Trend_Strength_2; double up3 = 0 if ((Ema1 > Ema2) && (Ema1 > Ema3) && (Ema1 > Ema4))up3 = Trend_Strength_3; double up4 = 0 if ((Ema1 > Ema2) && (Ema1 > Ema3) && (Ema1 > Ema4) && (Ema2 > Ema3))up4 = Trend_Strength_4; double up5 = 0 if ((Ema1 > Ema2) && (Ema1 > Ema3) && (Ema1 > Ema4) && (Ema2 > Ema3) && (Ema2 > Ema4))up5 = Trend_Strength_5; double up6 = 0 if ((Ema1 > Ema2) && (Ema1 > Ema3) && (Ema1 > Ema4) && (Ema2 > Ema3) && (Ema2 > Ema4) && (Ema3 > Ema4))up6 = Trend_Strength_6; //Down Trend Calcs double down1 = 0 if (Ema1 < Ema2) down1 = Trend_Strength_1; double down2 = 0 if ((Ema1 < Ema2) && (Ema1 < Ema3))down1 = Trend_Strength_2; double down3 = 0 if ((Ema1 < Ema2) && (Ema1 < Ema3) && (Ema1 < Ema4))down1 = Trend_Strength_3; double down4 = 0 if ((Ema1 < Ema2) && (Ema1 < Ema3) && (Ema1 < Ema4) && (Ema2 < Ema3))down1 = Trend_Strength_4; double down5 = 0 if ((Ema1 < Ema2) && (Ema1 < Ema3) && (Ema1 < Ema4) && (Ema2 < Ema3) && (Ema2 < Ema4))down1 = Trend_Strength_5; double down6 = 0 if ((Ema1 < Ema2) && (Ema1 < Ema3) && (Ema1 < Ema4) && (Ema2 < Ema3) && (Ema2 < Ema4) && (Ema3 < Ema4))down1 = Trend_Strength_6; //Trend truths used to turn indicators on and off 0=off 1=on bool up_1 = 0 if (up1 == 1) up_1 = 1; bool up_2 = 0 if (up2 == 1) up_2 = 1; bool up_3 = 0 if (up3 == 1) up_3 = 1; bool up_4 = 0 if (up4 == 1) up_4 = 1; bool up_5 = 0 if (up5 == 1) up_5 = 1; bool up_6 = 0 if (up6 == 1) up_6 = 1; bool down_1 = 0 if (down1 == 1) down_1 = 1; bool down_2 = 0 if (down2 == 1) down_2 = 1; bool down_3 = 0 if (down3 == 1) down_3 = 1; bool down_4 = 0 if (down4 == 1) down_4 = 1; bool down_5 = 0 if (down5 == 1) down_5 = 1; bool down_6 = 0 if (down6 == 1) down_6 = 1; // Long entry signals double LongEntry = 0; if (up_1 || up_2 = 1 && up_3 && up_4 && up_5 && up_6 =0) { //zero lag stoch conditions goes here if (OsMABar2 < OsMABar1) {LongEntry = 1; else LongEntry = 0 ;} else LongEntry = 0; } if (up_3 || up_4 = 1 && up_5 && up_6 =0) { if (CCI > Cci_Level1 && CCIPrevious <= Cci_Level1) {LongEntry = 1; else LongEntry = 0 ;} if (CCI > Cci_Level2 && CCIPrevious <= Cci_Level2) {LongEntry = 1; else LongEntry = 0 ;} if (CCI > Cci_Level3 && CCIPrevious <= Cci_Level3) {LongEntry = 1; else LongEntry = 0 ;} else LongEntry = 0; } if (up_5 || up_6 = 1) { if (Ema1 > Ema2 && Ema1Previous <= Ema2Previous) {LongEntry = 1; else LongEntry = 0 ;} if (CCI > Cci_Level1 && CCIPrevious <= Cci_Level1) {LongEntry = 1; else LongEntry = 0 ;} if (CCI > Cci_Level2 && CCIPrevious <= Cci_Level2) {LongEntry = 1; else LongEntry = 0 ;} if (CCI > Cci_Level3 && CCIPrevious <= Cci_Level3) {LongEntry = 1; else LongEntry = 0 ;} if (CloseBar1 < LowEnvelope1 && CloseBar1Previous >= LowEnvelope1Previous) {LongEntry = 1; else LongEntry = 0 ;} else LongEntry = 0; } double ShortEntry = 0; if (down_1 || down_2 = 1 && down_3 && down_4 && down_5 && down_6 =0) { //zero lag stoch conditions go here if (OsMABar2 > OsMABar1) {ShortEntry = 1; else LongEntry = 0 ;} else ShortEntry = 0; } if (down_3 || down_4 = 1 && down_5 && down_6 =0) { //CCI entry conditions need help if (CCI < Cci_Level1 *-1 && CCIPrevious >= Cci_Level1 *-1) {ShortEntry = 1; else ShortEntry = 0 ;} if (CCI < Cci_Level2 *-1 && CCIPrevious >= Cci_Level2 *-1) {ShortEntry = 1; else ShortEntry = 0 ;} if (CCI < Cci_Level3 *-1 && CCIPrevious >= Cci_Level3 *-1) {ShortEntry = 1; else ShortEntry = 0 ;} else ShortEntry = 0; } if (down_5 || down_6 = 1) { if (Ema1 < Ema2 && Ema1Previous >= Ema2Previous) {ShortEntry = 1; else ShortEntry = 0 ;} if (CCI < Cci_Level1 *-1 && CCIPrevious >= Cci_Level1 *-1) {ShortEntry = 1; else ShortEntry = 0 ;} if (CCI < Cci_Level2 *-1 && CCIPrevious >= Cci_Level2 *-1) {ShortEntry = 1; else ShortEntry = 0 ;} if (CCI < Cci_Level3 *-1 && CCIPrevious >= Cci_Level3 *-1) {ShortEntry = 1; else ShortEntry = 0 ;} if (CloseBar1 < LowEnvelope1 && CloseBar1Previous <= LowEnvelope1Previous) {ShortEntry = 1; else ShortEntry = 0 ;} else ShortEntry = 0; } //Entry if (LongEntry>0) { double LongLots,Up_Trend_Score; { Up_Trend_Score = (up1 + up2 + up3 + up4 + up5 + up6); LongLots = (Up_Trend_Score * AccountFreeMargin * Risk * LongEntry); } if(AccountFreeMargin()<(1000*LongLots())) { Print("Your Broke, Free Margin = ", AccountFreeMargin()); return(0); } OrderSend(Symbol(),OP_BUY,LongLots(),Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"Kurka",MagicN umber,0,Blue); return; } if (ShortEntry>0) { double ShortLots,Down_Trend_Score; { Down_Trend_Score = (down1 + down2 + down3 + down4 + down5 + down6); ShortLots = (Up_Trend_Score * AccountFreeMargin * Risk * ShortEntry); } if(AccountFreeMargin()<(1000*ShortLots())) { Print("Your Broke, Free Margin = ", AccountFreeMargin()); return(0); } OrderSend(Symbol(),OP_SELL,ShortLots(),Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"Kurka",MagicN umber,0,Blue); return; } } //Exit bool LongExit = false; { if (OsMABar2 > OsMABar1) LongExit = true; if (CCI < 0 * && CCIPrevious >= 0) LongExit = true; if (CCI < Cci_Level1 * && CCIPrevious >= Cci_Level1) LongExit = true; if (CCI < Cci_Level2 * && CCIPrevious >= Cci_Level2) LongExit = true; if (CCI < Cci_Level3 * && CCIPrevious >= Cci_Level3) LongExit = true; if (Ema1 < Ema2 && Ema1Previous >= Ema2Previous) LongExit = true; if (CCI < Cci_Level1 * && CCIPrevious >= Cci_Level1) LongExit = true; if (CCI < Cci_Level2 * && CCIPrevious >= Cci_Level2) LongExit = true; if (CCI < Cci_Level3 * && CCIPrevious >= Cci_Level3) LongExit = true; if (CloseBar1 < LowEnvelope1 && CloseBar1Previous <= LowEnvelope1Previous) LongExit = true; } bool ShortExit = false; { if (OsMABar2 < OsMABar1) ShortExit = true; if (CCI > 0 && CCIPrevious <= 0) ShortExit = true; if (CCI > Cci_Level1 *-1 && CCIPrevious <= Cci_Level1 *-1) ShortExit = true; if (CCI > Cci_Level2 *-1 && CCIPrevious <= Cci_Level2 *-1) ShortExit = true; if (CCI > Cci_Level3 *-1 && CCIPrevious <= Cci_Level3 *-1) ShortExit = true; if (Ema1 > Ema2 && Ema1Previous <= Ema2Previous) ShortExit = true; if (CCI > Cci_Level1 *-1 && CCIPrevious <= Cci_Level1 *-1) ShortExit = true; if (CCI > Cci_Level2 *-1 && CCIPrevious <= Cci_Level2 *-1) ShortExit = true; if (CCI > Cci_Level3 *-1 && CCIPrevious <= Cci_Level3 *-1) ShortExit = true; if (CloseBar1 > LowEnvelope1 && CloseBar1Previous <= LowEnvelope1Previous) ShortExit = true; } |
|
|||
|
Quote:
> The bad trades have all been 5 mini lots, and some > of the good trades > > have been as high as 36 lots. It should trade > allot more if I can get > > it into an EA. I will make this available to > everone as soon as I get > > it working. I need some help if your willing to > take a look. > > > > Here is what I am trying to do.... > > > > I have 6 trend strengths. Each one uses different > signals for entry > > and exit ( if trend 1 is true use indicator 1 > ect...) > > > > I trade with the trend. signals with the trend are > multiplied b the > > value of the "trend strength" signals against the > trend are traded > > lightly or not at all. Based on EMA crosses "trend > strengths" > > > > Exits are pulled as soon as any of the entry > signals in the oppisite > > direction of the position are active. This usually > gets the peak or > > valley. > > > > Here is what I need help with..... > > > > Entry signals....When trading manually I use CCI. > I would like the > > system to use different signals based on the trend > (Ema Cross). > > > > Questions: > > what signals work best in the following markets? > > 1 through 6; 1 being ranging/trend reversing and 6 > being strong trend. > > How do I do the money management? > > would like the position size to grow as the > signals get stronger. need > > help coding this. > > How do I draw the indicators on the chart? > > How do I stop the program before a scheduled news > event? |
|
|||
|
Quote:
Last edited by Jonathan You; 11-15-2006 at 05:38 PM. |
|
||||
|
Kurka Trader
I did not know that anyone on this board was working on this code......
There are a few working versions out there now but none that I have seen capture the manual trading system that I set out to do... Here are a few points that make the system work, hopefully it helps. -The trends are calculated on the 1hour chart, using EMA8, EMA24, EMA72 and EMA216. -The only entry / exit signals used from that chart are the EMA crosses. (8<>72 and 8 <>216) These signals are also used to close all open positions in the oppisite direction. The Rest of the entry /exit signals are calculated on the 5 min chart. -CCI, Stoch, SAR, Envelopes,OSMA,HIGH Low entry bars. -Different entry/exit signals are used for different trend calculations. example: CCI works best when trend 3 and 4 are true. 0 stoch works great when 1 or 2 are true. -When an entry signal (5min) is true. it is then checked against the 1 hour chart to determine, 1 if it is with the trend (EMA cross preminitions) and 2 size of position to take. -Signals against the major trend are traded lightly or not at all. Signals with the trend are traded heavy. Major problems with the code: 1... Size of position number of trades. I would like to play around with the number of simeotanious trades to allow. 3 at a time seems to work pretty good but adjusting this has not been tested. The point being, we cannot have 3 open positions at a trend 6. Need some code to limit the total size of open positions to (risk * trendstrength)/ max trades. this would allow a set number of trades for each trend, and they would all be the same size. 2... Junk signals. Need to validate signals on the 5 min chart . I use the OSMA. if cci signals long, check to make sure OSMA is going long. then go to 1 hour chart for size. 3... Dont know why but there seems to be a problem going long in the code. 4... Stoplosses/trailing stops need to be managed like a scalper system. I always move the stoploss to break even after 10 pips and then trail it by 10 after that. with a strong trend this usually ends up closing the position on a very large bar at the peak or valley. in ranging conditions or trend 1 AND 2 this has to be a scalper system or it turns on you. If you have any questions I can be reached on skype: kurkafund (my mic is broken but we can chat, will order a new mic today) |
|
||||
|
other source code
if you would like to see the other code that I have please email me kurkafund@yahoo.com and I will send it to you ..... it is to many charactors to post here.
|
|
|||
|
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/expert-advisors-metatrader-4/4595-profit-loss-221-3-a.html
|
||||
| Posted By | For | Type | Date | |
| Kurka Profit/Loss 221/3 | This thread | Refback | 03-11-2008 01:43 PM | |
| Kurka Profit/Loss 221/3 | This thread | Refback | 03-06-2008 02:47 AM | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| EA to close positions after profit/loss hit | james2ko | Expert Advisors - Metatrader 4 | 1 | 05-22-2007 04:03 AM |
| Stop Loss/Take Profit problem | caldolegare | Metatrader 4 | 4 | 02-17-2007 05:27 AM |
| Employ Someone and profit from Loss | tony hadley | General Discussion | 1 | 01-08-2007 07:37 AM |
| How do I set default Stop Loss / Take Profit | astro | Questions | 8 | 06-13-2006 11:55 PM |