below share a code how to get past 49 days amplitude
double dayAmp[50];//有dayAmp[0]
double high[50];double low[50];
datetime normalVolume = D' 2008.12.09' ;
double averageAmp,volumeNow,volumeLast,spread,tick,time;
int start()
//assume will not appear 2 small volume...
{
int daycount =1; int c= 1; double dayAmpSum = 0;
while (daycount<=period)
{
time = iTime(Symbol(), PERIOD_D1, c);
time += 50;
bool a = (TimeDayOfWeek(time)!=6 );
bool b = (TimeDayOfWeek(time)!=0);
if (a && b)
{
//------------volume-----------------------
volumeNow = iVolume(Symbol(),PERIOD_D1,c);
if (volumeLast == 0) volumeLast =iVolume(Symbol(),PERIOD_D1,c+1);
// for first time run, volumeLast is 0
if (volumeNow > volumeLast/3 )
{
high[daycount]= iHigh(Symbol(),PERIOD_D1,c);
low[daycount]= iLow(Symbol(),PERIOD_D1,c);
dayAmp[daycount] = high[daycount] - low[daycount];
dayAmpSum += dayAmp[daycount];
volumeLast = iVolume(Symbol(),PERIOD_D1,c);
daycount++;
}
}
c++;
}
//------------volume-----------------------
Print("dayAmpSum = ",dayAmpSum );
averageAmp = dayAmpSum /period;
Print("average day Amp = ",averageAmp );
spread =MarketInfo(Symbol(), MODE_SPREAD);
tick=MarketInfo(Symbol(),MODE_TICKSIZE);
Print("Spread = ", spread*tick);
Print("spread of daily amplitude = ",spread*tick/averageAmp*100,"%");
}
Files:
//--------CHECK do PEND the order already? //以profit 為準 VS
int buy,sell=0;
if (OrdersTotal() == 0) pended = false;
for (int i=0;i<OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if ( (OrderSymbol()== Symbol() ) && (OrderType() == OP_BUYSTOP) )
buy++;
if ( (OrderSymbol()== Symbol() ) && (OrderType() == OP_SELLSTOP) )
sell++;
}
if ((buy>=1) && (sell>=1)) pended = true;
else pended = false;
if ((buy>= 6) || (sell>=6)) {pended = true;cutrun="yes";}
Print("pended = ", pended);
//buy = 0, see trade operation
int buy,sell=0;
if (OrdersTotal() == 0) pended = false;
for (int i=0;i<OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if ( (OrderSymbol()== Symbol() ) && (OrderType() == OP_BUYSTOP) )
buy++;
if ( (OrderSymbol()== Symbol() ) && (OrderType() == OP_SELLSTOP) )
sell++;
}
if ((buy>=1) && (sell>=1)) pended = true;
else pended = false;
if ((buy>= 6) || (sell>=6)) {pended = true;cutrun="yes";}
Print("pended = ", pended);
//buy = 0, see trade operation
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
i am here to share a chase Trend EA idea, which haven't code success
i hope post 2 code can help u code less in your EA
It's idea is if the price go up past 50 dyas average amplitude, then assume it is up trend, will be instantly(actually I pend the Buy_Stop Order)
also the same condition of sell order, u can see the code ~ ~
AND IT use trailing stop, start to trail
when profit = 50 USD, the put the SL to 0 .
when profit = 100 USD, the put the SL to 50 . (50USD profit are protetced)
That's what it all continue to.
and i wrong some to code this EA and backtest it, to check the best parameter ~~
big thanks