[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 40

 
What is wrong here? Why doesn't a trade open on the intersection of two MAs?
int Period1 = 20;
int Period2 = 30;
int MA1_1,
    MA1_2,
    MA2_1,
    MA2_2;
//----
MA1_1=iMA(NULL, 0, Period1,0,MODE_SMA,PRICE_CLOSE,0);

MA1_2=iMA(NULL, 0, Period1,0,MODE_SMA,PRICE_CLOSE,3); 

MA2_1=iMA(NULL, 0, Period2,0,MODE_SMA,PRICE_CLOSE,0); 

MA2_2=iMA(NULL, 0, Period2,0,MODE_SMA,PRICE_CLOSE,3);

if (MA2_2 > MA1_2 && MA1_1 > MA2_1) // пересечение машек  
   OrderSend (Symbol(), OP_BUY, 0.01, Ask, 3, Bid-30*Point, Bid+300*Point);

if (MA2_2 < MA1_2 && MA1_1 < MA2_1) // пересечение машек  
   OrderSend (Symbol(), OP_SELL, 0.01, Bid, 3, Ask+30*Point, Ask-300*Point); 
 
forexnew:

Now I see. Suppose the software is to calculate if there has been a top-up/withdrawal in the last 24 hours. I am attaching the indicator. You only need to enter the balance that was at the beginning of the calculation time period and the number of days of calculation. I hope I understand you correctly.



Thank you for the whole indicator. Nothing is clear yet... :-Р

I will have to look into it and see.

P.S. "Fill/withdrawal" is a deposit from outside, but not a profit/loss as a result of trading. Your indicator shows profit even though there were no external deposits...

 
vovan-gogan:
What is wrong here? Why at the intersection of two MAs a trade is not opened?


Variables like double. You work on close prices, so you don't use zero1 bar, so try it - with TP, SL, volumes - you decide.

int Period1 = 20;
int Period2 = 30;
double MA1_1,MA1_2,MA2_1,MA2_2;
//----
MA1_1=iMA(NULL, 0, Period1,0,MODE_SMA,PRICE_CLOSE,1);

MA1_2=iMA(NULL, 0, Period1,0,MODE_SMA,PRICE_CLOSE,3); 

MA2_1=iMA(NULL, 0, Period2,0,MODE_SMA,PRICE_CLOSE,1); 

MA2_2=iMA(NULL, 0, Period2,0,MODE_SMA,PRICE_CLOSE,3);

if (MA2_2 > MA1_2 && MA1_1 > MA2_1) // пересечение машек  
   OrderSend (Symbol(), OP_BUY, 0.1, Ask, 3, 0, 0);

if (MA2_2 < MA1_2 && MA1_1 < MA2_1) // пересечение машек  
   OrderSend (Symbol(), OP_SELL, 0.1, Bid, 3, 0, 0); 
 

Благодарю Вас за целый индикатор. Пока еще ничего не понятно... :-Р

Буду разбираться и смотреть.

"доливка/снятие" - это пополнение счета извне, но не прибыль/убыток в результате торгов. У Вас в индикаторе показывает прибыль, хотя доливок извне не было...

 
Help me find a function that determines at different timeframes, which candle was last bullish or bearish?
 
What canthe error 133 be connected with? On a demo at broker N everything works normal. but on a real (at broker N) orders do not open write error 133.
 
Shniperson:
Error 133, what can it be related to? On a demo at broker N all works normally. but on a real (at broker N) warrants do not open write error 133.

ERR_TRADE_DISABLED 133 Trade is disabled.
 
nuan:
Help me find a function that determines on different timeframes, which candle was last bullish or bearish?
iOpen, iClose
 
Your account has a limit on the ilunga lot
 
ilunga:

ERR_TRADE_DISABLED 133 Trade is disabled.
No. It says "error opening sell position: 133 (or bay position)
Reason: