Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1004

 

Hello! In Expert Advisor, as one of the trading conditions, I use CCI pivot, but for some reason it does not work. Could you please explain what is the error?

C_1=iCCI(NULL,0,C_period,PRICE_TYPICAL,0);

C_2=iCCI(NULL,0,C_period,PRICE_TYPICAL,1);

C_3=iCCI(NULL,0,C_period,PRICE_TYPICAL,2);


if(C_1 > C_2 > C_3)Opn_B=true;

if(C_1 < C_2 < C_3)Cls_B=true;

 
Ratmirf:

Hello! In Expert Advisor, as one of the trading conditions, I use CCI pivot, but for some reason it does not work. Could you please explain what is the error?

C_1=iCCI(NULL,0,C_period,PRICE_TYPICAL,0);

C_2=iCCI(NULL,0,C_period,PRICE_TYPICAL,1);

C_3=iCCI(NULL,0,C_period,PRICE_TYPICAL,2);


if(C_1 > C_2 > C_3)Opn_B=true;

if(C_1 < C_2 < C_3)Cls_B=true;

if (C_1 > C_2 && C_2 > C_3) Opn_B=true;

if(C_1 < C_2 && C_2 < C_3)Cls_B=true;

 
paladin80:
if (C_1 > C_2 && C_2 > C_3) Opn_B=true;

if (C_1 < C_2 && C_2 < C_3) Cls_B=true;

Thank you very much!
 

Can you please tell me what is wrong here? I want trades to close when they cross 70 downwards (Buy) and 30 upwards (Sell). For some reason trades are closing Buy well below 70 and Sell well above 30. RSI does not even make it to 70 and 30 yet. Thanks!

R_1=iRSI(NULL,0,RSI_Period,PRICE_TYPICAL,0);

R_2=iRSI(NULL,0,RSI_Period,PRICE_TYPICAL,1);

if((R_1 < 70 && R_2 > 70)) Cls_B=true;
if((R_1 > 30 && R_2 < 30)) Cls_S=true;
 
Ratmirf:

Can you please tell me what is wrong here? I want trades to close when they cross 70 downwards (Buy) and 30 upwards (Sell). For some reason trades are closing Buy well below 70 and Sell well above 30. RSI does not even make it to 70 and 30 yet. Thanks!

R_1=iRSI(NULL,0,RSI_Period,PRICE_TYPICAL,0);

R_2=iRSI(NULL,0,RSI_Period,PRICE_TYPICAL,1);

if((R_1 < 70 && R_2 > 70)) Cls_B=true;
if((R_1 > 30 && R_2 < 30)) Cls_S=true;

In the previous post, you had: if(C_1 < C_2 && C_2 < C_3) Cls_B=true; Now you have the same variable changing under a different condition: if((R_1 < 70 && R_2 > 70)) Cls_B=true; Check.

Try this code:

double C_1=iCCI(NULL,PERIOD_CURRENT,C_period,PRICE_TYPICAL,0);
double C_2=iCCI(NULL,PERIOD_CURRENT,C_period,PRICE_TYPICAL,1);
double C_3=iCCI(NULL,PERIOD_CURRENT,C_period,PRICE_TYPICAL,2);

bool Opn_B=false, Opn_S=false;

if(C_1>C_2 && C_2>C_3) Opn_B=true;
if(C_1<C_2 && C_2<C_3) Opn_S=true;

//---
double R_1=iRSI(NULL,PERIOD_CURRENT,RSI_Period,PRICE_TYPICAL,0);
double R_2=iRSI(NULL,PERIOD_CURRENT,RSI_Period,PRICE_TYPICAL,1);

bool Cls_B=false, Cls_S=false;

if(R_1>70.0 && R_2<70.0) Cls_B=true; 
if(R_1<30.0 && R_2>30.0) Cls_S=true;
 

Hello all!!!!

I am sure that has been done repeatedly like this, but maybe someone will suggest a formula for the size of the lot, depending on the funds???

Like if more than 2000 then lot 0.02, if more than 3000 then 0.03, etc.?

 
nikelodeon:

Hello all!!!!

I am sure that has been done repeatedly like this, but maybe someone will suggest a formula for the size of the lot, depending on the funds???

Like if more than 2000 then lot 0.02, if more than 3000 then 0.03, etc.?

There are different formulas for calculations
 
paladin80:

In the previous post you had: if (C_1 < C_2 && C_2 < C_3) Cls_B=true; Now you have the same variable changing under a different condition: if((R_1 < 70 && R_2 > 70)) Cls_B=true; Check it.

Try this code:


Thank you very much for your help! I am figuring out how exactly the RSI EA works. So what is interesting, in the following chart trades are opened in exactly the right place, but they are closed completely in the wrong place (I want trades to be closed at 70 crossing from top to bottom (Buy) and 30 crossing from bottom to top (Sell). Your recommended closing scheme does not work either. I set the RSI period to 2 and am looking at M1. Where is the inaccuracy, I can't figure it out.

R_1=iRSI(NULL,PERIOD_CURRENT,RSI_Period,PRICE_TYPICAL,0);

R_2=iRSI(NULL,PERIOD_CURRENT,RSI_Period,PRICE_TYPICAL,1);


if(R_1>60 && R_2<60) Opn_B=true;

if(R_1<40 && R_2>40) Opn__S=true;


if(R_1<70.0 && R_2>70.0) Cls_B=true;

if(R_1<30.0 && R_2<30.0) Cls_S=true;

 
Ratmirf:

Thank you very much for your help! I am in the process of figuring out how the RSI EA works. So what's interesting, on the chart below, trades open exactly where they should, but they close completely wrong (I want trades to close at 70 crossing from top to bottom (Buy), and 30 crossing from bottom to top (Sell). Your recommended closing scheme does not work either. I set the RSI period to 2 and am looking at M1. Where is the inaccuracy, I can't figure it out.

R_1=iRSI(NULL,PERIOD_CURRENT,RSI_Period,PRICE_TYPICAL,0);

R_2=iRSI(NULL,PERIOD_CURRENT,RSI_Period,PRICE_TYPICAL,1);


if(R_1>60 && R_2<60) Opn_B=true;

if(R_1<40 && R_2>40) Opn__S=true;


if(R_1<70.0 && R_2>70.0) Cls_B=true;

if(R_1<30.0 && R_2<30.0) Cls_S=true;

Are we sure that the last condition is correctly written
 
Vinin:
Are you sure that the last condition is spelled correctly?
That's what I'm thinking. When the RSI passes through the 60 level from bottom to top it opens a Buy perfectly. Everything makes sense to me. R_2 goes behind R_1 and the condition is correct. When it passes through 40 from the top downwards, it opens a Sell position. However, I do not understand why it is not closing where I want, i.e. Buy at 70 from above downwards and Sell at 30 from below upwards. But for my strategy it is important to close the RSI at this level.