Raw Ideas - page 5

 

Stop loss for EA

Sorry for the above title, what I need is a take profit command. I have no idea how to code but would like to add a Take Profit to this ea. Below is the code please add take profit where necessary. Thanks again

Ray

extern double MaximumRisk =0.02; //%account balance to risk per position

extern double DecreaseFactor =3; //lot size divisor(reducer) during loss streak

extern double Lot.Margin =50; //Margin for 1 lot

extern int Magic =69;

extern string comment ="m icwr ea";

double spread; spread =Ask-Bid;

int slip; slip =spread/Point;

int RequiredWaveHeight,b,s,cnt,ticket;

double rsi,SL,ICWR,ICWRv0,awp1,awp2,active.high,active.low,high.c,high.r,low.r,low.c;

datetime awt1,awt2,a.high.shift,a.low.shift,shift;

int init(){return(0);}

int deinit(){return(0);}

int start(){

PosCounter();

rsi=iRSI(Symbol(),1440,14,PRICE_CLOSE,0);

if(Period()==5) {RequiredWaveHeight=40;SL=50*Point;}

if(Period()==240) {RequiredWaveHeight=150;SL=100*Point;}

ICWR=iCustom(Symbol(),Period(),"ICWR",10,5,3,RequiredWaveHeight,0,0);

ICWRv0=iCustom(Symbol(),Period(),"ICWR v0","ZigZag",10,5,3,"ActiveWave",50,RequiredWaveHeight,0,0);

awt1=ObjectGet("Activewave",OBJPROP_TIME1);

awp1=ObjectGet("Activewave",OBJPROP_PRICE1);

awt2=ObjectGet("Activewave",OBJPROP_TIME2);

awp2=ObjectGet("Activewave",OBJPROP_PRICE2);

if(awp1>awp2) {

active.high=awp1;

a.high.shift=iBarShift(Symbol(),Period(),awt1);

active.low=awp2;

a.low.shift=iBarShift(Symbol(),Period(),awt2);}

else {

active.high=awp2;

a.high.shift=iBarShift(Symbol(),Period(),awt2);

active.low=awp1;

a.low.shift=iBarShift(Symbol(),Period(),awt1);}

if(a.high.shift<a.low.shift) shift=a.high.shift;

else shift=a.low.shift;

high.c=NormalizeDouble(active.low+((active.high-active.low)*0.75),Digits);

high.r=NormalizeDouble(active.low+((active.high-active.low)*0.618),Digits);

low.r=NormalizeDouble(active.low+((active.high-active.low)*0.382),Digits);

low.c=NormalizeDouble(active.low+((active.high-active.low)*0.25),Digits);

if(rsi>50) {

for(int i=0;i<shift;i++) {

if(Closelow.r && Low[1]>high.c && b==0) {

ticket1=OrderSend(Symbol(),OP_SELL,1.0,Bid,0,Bid+20*Point,Bid-30*Point,"expert comment",255,0,CLR_NONE);

OP_BUY,

LotsOptimized(),

Ask,

slip,

Ask-SL,

0,

Period()+comment,

Magic,0,Blue);

if(ticket>0) {

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))

{ Print(ticket); }

else Print("Error Opening BuyStop Order: ",GetLastError());

return(0);}}}}

if(rsi<50) {

for(int ii=0;ii<shift;ii++) {

if(Closelow.r && High[1]<low.c && s==0) {

ticket=OrderSend(Symbol(),

OP_SELL,

LotsOptimized(),

Bid,

slip,

Bid+SL,

0,

Period()+comment,

Magic,0,Orange);

if(ticket>0) {

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))

{ Print(ticket); }

else Print("Error Opening SellStop Order: ",GetLastError());

return(0);}}}}

if(b>0) {

for(int c=0;c<shift;c++) {

if(High[1]<low.c) {

OrderClose(ticket,OrderLots(),Bid,slip,0);}}}

if(s>0) {

for(int cc=0;cc<shift;cc++) {

if(Low[1]>high.c) {

OrderClose(ticket,OrderLots(),Ask,slip,0);}}}

comments();

return(0);}

//+---------------------------FUNCTIONS------------------------------+

void PosCounter() {

b=0;s=0;ticket=0;

for(cnt=0;cnt<=OrdersTotal();cnt++) {

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) {

if(OrderType()==OP_SELL) {

ticket=OrderTicket();

s++;}

if(OrderType()==OP_BUY) {

ticket=OrderTicket();

b++;} }}}

void comments() {

if(MarketInfo(Symbol(),MODE_SWAPLONG)>0) string swap="longs.";

else swap="shorts.";

if(MarketInfo(Symbol(),MODE_SWAPLONG)<0 && MarketInfo(Symbol(),MODE_SWAPSHORT)<0) swap="your broker. ";

Comment("Last Tick: ",TimeToStr(CurTime(),TIME_DATE|TIME_SECONDS),"\n",

"Swap favors ",swap,"\n",

"Daily RSI= ",rsi,"\n",

"Active High: ",active.high,"\n",

"High shift: ",a.high.shift,"\n",

"High Confirm: ",high.c,"\n",

"High Retrace: ",high.r,"\n",

"Low Retrace: ",low.r,"\n",

"Low Confirm: ",low.c,"\n",

"Active Low: ",active.low,"\n",

"Low shift: ",a.low.shift); }

double LotsOptimized() {

double lot;

int orders=HistoryTotal();

int losses=0;

lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/Lot.Margin,2);

if(DecreaseFactor>0) {

for(int i=orders-1;i>=0;i--) {

if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }

if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;

if(OrderProfit()>0) break;

if(OrderProfit()<0) losses++; }

if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,2); }

if(lot<0.01) lot=0.01;

return(lot); }//end LotsOptimized

 

nevermind...

Nevermind..somehow

i downloaded the TEMPLATE catfx and it all showed up...

I dunno

 

quick question..what data INDinverse give you?

I have this graph but can't seem to decipher what info it tells me..

I did a Search but came up short on a description.

THANK U FOR UR SUPPORT

Files:
 

New chart disables EA?

Hello agian,

(This is such a great board, I'll have something to share soon!)

I'm playing around with CodersGuru's "Your First Expert Advisor" example from his MQL4 Course...

I've noticed something that I hope has a solution... After loading the EA on the 30M chart... it Opened a (Short) Order.. I had modified his code to test my Exit strategy (a simple cross on a lower time period)...

The cross came and went (and the printed status, and my code was correct) HOWEVER, I was on the 15M chart at the time... does this mean I de-activated the EA (so my code/logic didn't run)?

If so, is there anyway around this... I'd like to click back and forth to other timeframes... without disabling the EA that is running.

Thanks in advance for the replies.

-charliev

 

System effectiveness proportional to its user growth?

Do you guys believe that a system would gain or lose its effectiveness along with an increasing number of people who apply it?

It seems that many successful traders do not usually share their trading strategies, so there must be a reason for them doing so. Anyone want to crack at this?

 
TheShanghai:
Do you guys believe that a system would gain or lose its effectiveness along with an increasing number of people who apply it? It seems that many successful traders do not usually share their trading strategies, so there must be a reason for them doing so. Anyone want to crack at this?

I heard about this idea that many successful traders do not usually share their trading strategies or share some wrong strategies especially. May be. I do not know. Because the forex is money. I think it is nothing with this effectiveness. It is because not so many successful traders and it is something with brokers.

BTW, I think it is personal. One trader can use some trading strategy and I can not because of my character, habits, timezone etc. So it is personal. Anyway we may discover all the strategies as we are doing already here in the forum.

 

thank you for the feedback. I'll keep that in mind.

 

Follow the trend

Hi,

I've got a simple yet stable system that work for me. I make use of a 34 EMA on close. RSI 7 close. CCI 20 close. Place the EMA on a chart and look at the trend. Start at the 30M and move all the way up to H4 even D1. The trend of the EMA must be the same for all the timeframes. If the trend is right you can enter a trade if RSI is above/below 50 on D1 timeframe and CCI is above/below 100. Stay on the H4 chart when the trade begins, it keep you from seeing the noise in the market and let you close before the time. Put a stoploss in at 80 pips. You can also use the Fib to see if the market has a retracement or not. I like to use a Equidistant channel (A metatrader standard tool) to find the market trend. I keep to that trend until I make my profits. This method is not fool proof but one thing is for sure and it make more sence to me every day and that is I'm not trading against a major trend.

Please experiment with this method on demo and lets build a longer term system that work form the more serious trader.

Roets

 

Default value when Array is Declared

Hello everyone,

What value is placed as the default value in this Array:

double ARRAYA[];

double ARRAYB[];

I want to clear the entire content of these Arrays by doing:

ArrayInitialize(ARRAYA,NULL);

ArrayInitialize(ARRAYB,NULL);

However, setting to NULL causes the Array to be filled with 0 (zero).

Any suggestions?

-charliev

 

Indicator #include in EA?

Hello everyone,

Is there a way to #include a compiled Indicator so that it loads when the EA loads? (Making the EA freestanding as 1 .EX4 file?)

Thanks for the help!

-charliev

Reason: