How to code? - page 54

 

Other question

now my EA like this

if(FastMA2 SlowMA1)

{

ClosePositions();

OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-SLpips*Point,Ask+(45*Point),"",MAGIC,0,Blue);

return(0);

i want to change like this

1. 15minutus timeflame happen buy sign

2. if then 5minutes timeflame MA cross buy sign already ,too

ClosePosition. and get new position

if then 5minutes timeflame MA change sell sign already

wait 5minutes timeflame change buy sign ,

then ClosePosition. and get new position

Please tell me how to write this program.

 
Files:
 

Hello

I am looking for some help I have an EA that I'm using on demo and also learning to code with. I am trying to figure out how to add a comment to the system to show me which of the 4 entry criteria was used to open the position. eg if long2 was used then show long2 signal

any help would be great

cheers

Beno

 
Beno:
Hello

I am looking for some help I have an EA that I'm using on demo and also learning to code with. I am trying to figure out how to add a comment to the system to show me which of the 4 entry criteria was used to open the position. eg if long2 was used then show long2 signal

any help would be great

cheers

Beno

After your condition is met and you use Ordersend() command, just insert a Comment(), Alert(), or Print() statement. Whichever you want to use.

Something like this:

if ( long2 == true)

{

Ordersend();

{

Print(" long2 signal taken ");

}

}

Hope that helps.

 

Thanks Wolfe

I had to laugh I put in what you suggested and it worked sort of but now I only have the comment and no positions opening. any hints

bool Long = MAofRSI11>MAofRSI21 && MAofRSI12VolHL && RSIndex1HL2 && TrStop0.0 && SDLL && ma<Close[shift];

bool Short = MAofRSI11=MAofRSI22 && VolCH>VolHL && RSIndex1HLM && TrStop>Close[shift] && MOMClose[shift];

bool Long2 = MAofRSI11>HLM && MAofRSI12HLM && MAofRSI22VolHL && TrStop0.0 && SDLL && ma<Close[shift];

bool Short2 = MAofRSI11=HLM && MAofRSI21=HLM && VolCH>VolHL && TrStop>Close[shift] && MOMClose[shift];

bool Long3 = RSIndex1-RSIndex2>20<HL2 && TrStop0.0 && SDLL && ma<Close[shift];

bool Short3 = RSIndex2-RSIndex1>20>HL1 && TrStop>Close[shift] && MOMClose[shift];

bool Long4 = zscore>0.0 && ma<Close[shift];

bool Short4 = zscoreClose[shift];

buysig = Long || Long2 || Long3 || Long4;

sellsig = Short || Short2 || Short3 || Short4;

closebuy=sellsig;

closesell=buysig;

if (curprof>=AccountBalance()*ProfitExit/100.0) {

exit=true;

}

if (last>0 && (Time[0]-last)/(Period()*60)>=CancelOrderBars) {

remorder=true;

}

}

void CheckForOpen() {

int res,tr;

//---- sell conditions

co=CalculateCurrentOrders(Symbol());

if(sellsig && lastsig!=-1) {

co=CalculateCurrentOrders(Symbol());

if (co==0) {

if ( Short == true)

if ( Short2 == true)

if ( Short3 == true)

res = OpenStop(OP_SELLSTOP,LotsRisk(StopLoss), Low[shift]-OrderPipsDiff*Point, StopLoss, TakeProfit1);

Print(" Short signal taken ");

Print(" Short2 signal taken ");

Print(" Short3 signal taken ");

Print(" Short4 signal taken ");

}

lastsig=-1;

last=Time[0];

return;

}

//---- buy conditions

if(buysig && lastsig!=1) {

co=CalculateCurrentOrders(Symbol());

if (co==0) {

if ( Long == true)

if ( Long2 == true)

if ( Long3 == true)

if ( Long4 == true)

res = OpenStop(OP_BUYSTOP,LotsRisk(StopLoss), High[shift]+OrderPipsDiff*Point, StopLoss, TakeProfit1);

Print(" Long signal taken ");

Print(" Long2 signal taken ");

Print(" Long3 signal taken ");

Print(" Long4 signal taken ");

}

last=Time[0];

lastsig=1;

return;

}

}

Fixed it Thanks

 

Debugging code

How and where would you use a bit of code like this. I have a Zero divide error that I can't find how the fix.

extern bool DEBUGGING = true

...

if(DEBUGGING && variableName == 0) Print("CodePoint 1 -- This variable is now ", variableName);

... more code

if(DEBUGGING && variableName == 0) Print("CodePoint 2 -- This variable is now ", variableName);

... more code

if(DEBUGGING && variableName == 0) Print("CodePoint 3 -- This variable is now ", variableName);

...

 

can you help me?why there are many mistakes in the code?

this is to calculate SMMA:

for(j=0;j<Bars;j++)

{

for(i=0,sum=0;i<ma_period;i++)

{

sum=sum+Close[j+i];

// buffer[j]=(sum-sum/ma_period+Close[j+i])/ma_period;

}

buffer[j]=(sum-sum/ma_period+Close[j])/ma_period;

}

this is to calculate LWMA

for(j=0;j<Bars;j++)

{

for(i=0,sum=0,sum1=0;i<ma_period;i++)

{

sum=sum+Close[j+i];

sum1=sum1+Close[j+i]*(j+i);

// buffer[j]=sum/ma_period;

}

buffer[j]=sum1/sum;

}

and how to calculate EMA?

 

question on indicators

Hi everyone.

I am stuck on a programming issue. Does anyone know how to use 1 indicator result to change another setting? For example, if the daily stockasti was above 20, I would want a moving average of (x). I tried to get the code working below but to know avail. I don't seem to be able to get the switch or if else command to work eithor.

double fourhrUP;

double daystoch1 = iStochastic(NULL, PERIOD_D1,5, 3, 3, MODE_SMA, 0, MODE_MAIN,1);

double daystoch20 = 20;

if (daystoch1 > daystoch20) four_hrUP = 5 ;

double iMA( string symbol, int timeframe,four_hrUP, int ma_shift, int ma_method, int applied_price, int shift)

 
ajk:
Hi everyone.

I am stuck on a programming issue. Does anyone know how to use 1 indicator result to change another setting? For example, if the daily stockasti was above 20, I would want a moving average of (x). I tried to get the code working below but to know avail. I don't seem to be able to get the switch or if else command to work eithor.

double fourhrUP;

double daystoch1 = iStochastic(NULL, PERIOD_D1,5, 3, 3, MODE_SMA, 0, MODE_MAIN,1);

double daystoch20 = 20;

if (daystoch1 > daystoch20) four_hrUP = 5 ;

double iMA( string symbol, int timeframe,four_hrUP, int ma_shift, int ma_method, int applied_price, int shift)

Where's your MA's variable?

Maybe this could help

double ma4hr=iMA( string symbol, int timeframe,four_hrUP, int ma_shift, int ma_method, int applied_price, int shift);

if the stoch calculation is in the same loop, let say "for(int shift=limit-1; shift>=0; shift--)", the stoch code should be

double daystoch1 = iStochastic(NULL, PERIOD_D1,5, 3, 3, MODE_SMA, 0, MODE_MAIN,shift+1);

CMIIW

 

A Little Help with an Indicator - Coder's Please Look

I am testing an MT4 Broker's Platform that uses Fractional Pips (pipettes) in it's price quotations: For Example on EURJPY they quote as 164.381 instead of 164.38 - This means that the spread has a decimal such as 4.1 pips (instead of 4).

Can anyone tell me how to MODIFY the following code so that the Spread reads properly? Right now a 4.1 pip spread would read as 41.0 in the Indicator. Any help is appreciated.

Dan

//---- spread

Spread=NormalizeDouble((Ask-Bid)/Point,1);

ObjectSetText("Spread Monitor1","Spread:", 10, "Arial", labelColor);

ObjectSetText("Spread Monitor2",DoubleToStr(Spread,1),10, "Arial", clockColor);