[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 218

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
{
Price1 =(iClose(Symbol_1,0,0) - iClose(Symbol_1,0,f)) / MarketInfo(Symbol_1, MODE_POINT)
Price2 = K*(iClose(Symbol_2,0,0) - iClose(Symbol_2,0,f)) / MarketInfo(Symbol_2, MODE_POINT);
Spread = Price1 - Price2;
Print ("Price1="+Price1, " Price2="+Price2);
if (Spread==0){t=f; break;}
}
Price12 = (iClose(Symbol_1,0,0) - iClose(Symbol_1,0,t)) / MarketInfo(Symbol_1, MODE_POINT);
Price22 = K*(iClose(Symbol_2,0,0) - iClose(Symbol_2,0,t)) / MarketInfo(Symbol_2, MODE_POINT);
Spread2 = Price12 - Price22;
if (MathAbs(Spread2) >= razdvizka && Spread2 < 0) { open trade }
I want to fix the bar where the spread was equal to zero and control the spread from it
Please advise what to do if:
In the tester is working fine, all according to plan, but on the realsk does not open the transaction.
P.S. Really need some help, it's a matter of life or death
Please advise what to do if:
In the tester is working fine, all according to plan, but on the realsk does not open the transaction.
P.S. Really need some help, it's a matter of life or death
has been replaced by MODE_TRADES?I'm not an expert, maybe there is a problem?
What's wrong with my maths?
My currentPrice >= profitLine means that if profitLine == or >, right?
But it works for me if > by at least one point.
Have you looked at the FAQ?
Yeah, well... didn't think of that. Thank you. (chuckles)
Dear experts, the question about the indicator is removed, the solution came quite unexpectedly, I duplicated the calculations, and oops.... Everything is working.
But I have another one, how it worked, I would like to understand. The code is attached:
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
extern int PerMa = 5;
extern int Shift = 0;
extern int Step = 15;
double ABuf45[],ABuf[],ABuf5[],ABuf15[];//,Stark[];
double Stark;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{ Stark=0;
//---- indicators
// IndicatorBuffers(4);
SetIndexBuffer(0,ABuf);
SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i,n;
//----
i=Bars-counted_bars-1;
while(i>=0)
{ RefreshRates();
//----
double Ma15=iMA(NULL,0,21,0,MODE_EMA,PRICE_CLOSE,i);
double Ma45=iMA(NULL,0,50,0,MODE_EMA,PRICE_CLOSE,i);
double Ma=iMA(NULL,0,PerMa,0,MODE_EMA,PRICE_CLOSE,i);
//double Ma1=iMA(NULL,0,PerMa,Shift,MODE_EMA,PRICE_CLOSE,i+1);
if(Ma>Stark+Step*Point&&Ma15>Ma45){Stark=Ma;}
if(Ma<Stark-Step*Point&&Ma15<Ma45){Stark=Ma;}//else{Stark=Stark;}
ABuf[i+Shift]=Stark;Comment(Stark);
if(Ma>Stark+Step*Point&&Ma15>Ma45){Stark=Ma;}//else{Stark=Stark;}
if(Ma<Stark-Step*Point&&Ma15<Ma45){Stark=Ma;}//else{Stark=Stark;}
ABuf[i+Shift]=Stark;//Comment(Stark);
//----
i--;
}
return(0);
}
Withdrawn. I made up all kinds of nonsense. It turned out to be much simpler. I took the Stark variable out of the start function, so it wouldn't reset on every tick.
sig1"signal is given , BUY command is triggered and SELLSTOP pending order is placed below BUY order.
When the BUY position is closed, the SELLSTOP is also deleted.
But what happens when this BUY is not closed, and the next BUY, etc. is opened.
This SELLSTOP which is set first has to be somehow figured out in order to close it after the first BUY has been closed.
In addition, if the price breaks through the pending one and then it closes without a loss, the pending one has been set in the same place as its predecessor.
-----------------------------------
thiswill not solve the problem because after the sell is closed, a new sell with a different masterwill open and it will be deleted.
After closing the buy I don't know how.
sig1"signal is given , BUY command is triggered and SELLSTOP pending order is placed below BUY order.
When the BUY position is closed, the SELLSTOP is also deleted.
But what happens when this BUY is not closed, and the next BUY, etc. is opened.
This SELLSTOP which is set first has to be somehow figured out in order to close it after the first BUY has been closed.
In addition, if the price breaks through the pending one and then it closes without a loss, the pending one has been set in the same place as its predecessor.
-----------------------------------
thiswill not solve the problem because after the sell is closed, a new sell with a different masterwill open and it will be deleted.
after the buy is closed, I don't know how.
Well... you use the same Select to check...