//+------------------------------------------------------------------+ //| Firebird - MA envelope exhaustion system | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, TraderSeven" #property link "TraderSeven@gmx.net" //----------------------- USER INPUT extern double MA_length = 10; extern double slip = 0; extern double Lots = 1; extern double TakeProfit = 30; extern double Stoploss = 2000; //extern double TrailingStop = 5; extern double PipStep = 30; //----------------------- SETUP VARS //----------------------- MAIN PROGRAM LOOP int start() { double PriceTarget; double AveragePrice; int flag; int OpeningDay; double Tester; double Stopper=0; int cnt=0, total; total=OrdersTotal(); if(total==0) OpeningDay=DayOfYear(); OrderSelect(total-1, SELECT_BY_POS); double LastPrice=OrderOpenPrice(); OrderSelect(total, SELECT_BY_POS, MODE_TRADES); flag=0; //if(OrderSymbol()==Symbol()) //{ //if((iMA(NULL,0,MA_length,0,MODE_SMA,PRICE_OPEN,0)*1.02)=(LastPrice+(PipStep*Point))||total==0)) // Go SHORT -> Only sell if >= 30 pips above previous position entry if((iMA(NULL,0,MA_length,0,MODE_SMA,PRICE_HIGH,1)*1.02)=(LastPrice+(PipStep*Point))||total==0)) // Go SHORT -> Only sell if >= 30 pips above previous position entry { OrderSend(Symbol(),OP_SELL,Lots,Bid,slip,Bid+(Stoploss*Point),Bid-(TakeProfit*Point),0,0,Red); flag=1; //LastPrice=Bid; } //if((iMA(NULL,0,MA_length,0,MODE_SMA,PRICE_OPEN,0)*0.98)>Ask && (Ask<=(LastPrice-(PipStep*Point))||total==0)) // Go LONG -> Only buy if >= 30 pips below previous position entry if((iMA(NULL,0,MA_length,0,MODE_SMA,PRICE_LOW,1)*0.98)>Ask && (Ask<=(LastPrice-(PipStep*Point))||total==0)) // Go LONG -> Only buy if >= 30 pips below previous position entry { OrderSend(Symbol(),OP_BUY,Lots,Ask,slip,Ask-(Stoploss*Point),Ask+(TakeProfit*Point),0,0,Blue); flag=1; //LastPrice=Ask; // } } //----------------------- CALCULATE AVERAGE OPENING PRICE total=OrdersTotal(); AveragePrice=0; if(total>0) { for(cnt=0;cnt Day() // Trailing stop -> trailing or S/R or pivot target // Realistic stop loss // Avoid overly big positions // EUR/USD 30 pips / use same value as pipstep // GBP/CHF 50 pips / use same value as pipstep // USD/CAD 35 pips / use same value as pipstep //----------------------- OBSERVATIONS // GBPUSD not suited for this system due to not reversing exhaustions. Maybe use other types of MA // EURGBP often sharp reversals-> good for trailing stops? //